Visitar URL original
Why String? · Issue #38 · theam/aws-lambda-haskell-runtime · GitHub
Skip to content

Why String? #38

Open
Open

Description

@axman6

There's a lot of usage of "strict" Strings in the package. Is there a good reason not to use Text? Particularly since there's a dependency on Aeson (and probably others), Text is already an indirect dependency. using !String just forces the list constructor, and leaves the tail of the list unevaluated (and also causes an under the hood conversion from Text to String within Aeson).

Activity

  1. NickSeagull commented on Jul 5, 2019

    @NickSeagull
    Contributor

    We were using Text before String (we dont use String in our projects generally), but we found that using Text was a tiny bit slower somehow (I guess because we were doing lots of conversions). There wasn't any thorough benchmarking. But we will do it in the near future, so we can have much better data on that. And if needed, we will switch over to Text again :)

  2. jacobstanley commented on Aug 14, 2019

    @jacobstanley

    I just came to ask exactly this, measurement ftw.

    Have you tried ByteString? My gut says Text UTF-16 can be problematic for sure when you're not doing a lot of string manipulation. Especially since aeson reads utf8 bytes via attoparsec (if I recall correctly) so it needs to be converted back to that anyway.

  3. NickSeagull commented on Aug 17, 2019

    @NickSeagull
    Contributor

    Yeah, this was going to be the next step @jacobstanley . But still, there are no benchmarks yet 😅 , it'd be great to have something to measure that

  4. axman6 commented on Apr 9, 2020

    @axman6
    Author

    Any update on this? I can't see any way in which String would be faster than Text, since the String needs to be parsed from a Text in the Aeson Value type. I'd really like to try moving some of out lambdas to the native runtime but seeing things like this makes me worry about the project.

  5. NickSeagull commented on Apr 9, 2020

    @NickSeagull
    Contributor

    The decision of using String was due to what was said above. Most of the inputs are provided by AWS as environment variables, which is read as a String by default, having to convert back and forth between Text and String was troublesome because there were so many unnecessary conversions.

    seeing things like this makes me worry about the project

    In what way? If your worry is about exposing String to the public API, it could be easily changed.

  6. axman6 commented on May 6, 2020

    @axman6
    Author

    Sorry for the late reply on this, and apologies for my misunderstanding. I had forgotten how much was passed to the native runtime as Strings from env vars. I should look into making a version of System.Environment which uses ByteString, to avoid the conversion to String all together...

  7. axman6 commented on May 6, 2020

    @axman6
    Author

    If you can bare the dependency on the unix package, you can use https://hackage.haskell.org/package/unix-2.7.2.2/docs/System-Posix-Env-ByteString.html to grab the env vars. Personally I'd prefer to have these as ByteStrings and make conversions to other types if I need them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions