[Grace-core] Strings

Lex Spoon lex at lexspoon.org
Tue Jan 27 09:33:21 PST 2015


Nice thoughts, Michael.

In general, it's extremely useful to programmers to have a data structure
holding a finite sequence of Unicode code points. That data structure is
conventionally called a string. There are certainly also other text-related
data structures that are useful to implement and provide.

For a PL that will compile to Java or JavaScript, it's probably best to
match their string type. Otherwise it will be necessary to convert between
the two types all over the place. It's hard to imagine a string library
that is so much better that it's worth the complexity of wrappers and
conversions that crop up when juggling two kinds of strings.

Go does not have that constraint, and they went with narrow, byte-based
strings. That strikes me as a good choice. Java, JavaScript, and the
Microsoft foundation libraries all use wide strings, but it hasn't worked
out very well in practice.

I expect programmers will be happy using code points as the default level
of abstraction. Whether you need to look at grapheme clusters depends on
the problem, and you can always do that explicitly when you need to.

Lex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailhost.cecs.pdx.edu/pipermail/grace-core/attachments/20150127/a6eb7e5a/attachment.html>


More information about the Grace-core mailing list