[erlang-questions] Strings and Text Processing
Thu Jan 3 14:11:36 CET 2013
I do most certainly agree with your comments. The requirement for text processing is almost entirely a boundary consideration - made quite common owing to the number of text-based protocols and file formats out there. The provision of codecs that transform from string to the internal data representation, and then from the internal representation out to a string is a not-infrequent requirement of the code. Decoders are frequently far harder to write than encoders - and as I noted, made harder still when using erlang strings than when using binaries.
On Jan 3, 2013, at 3:36 AM, Jesper Louis Andersen <jesper.louis.andersen@REDACTED> wrote:
> On Dec 29, 2012, at 3:08 PM, Steve Davis <steven.charles.davis@REDACTED> wrote:
>> 2) If not, I wonder if there's any way to change our minds about "strings" as we enter 2013?
> There is :)
> A String is often a notoriously bad way to represent data. Think about it: a string is really just a sequence of bytes with some interpretation (utf8 is common). The problem is that people tend to keep their data represented as strings where other data structures are better for the purpose. A Comma-separated file for instance is better represented as a list of tuples or a generator of tuples (and/or records).
> The reason you don't usually need a lot of syntactic sugar for manipulating strings are simply that you shouldn't be manipulating strings too much in the first case. A language like Perl is good for processing directly on text, but the weakness is that it has a harder time at structuring data like you should do in Erlang (Or ML or Haskell or …). I have a hunch that most of the critique is really due to the fact that people are trying to write in the style of a different language in Erlang.
> Jesper Louis Andersen
> Erlang Solutions Ltd., Copenhagen
More information about the erlang-questions