What kind of string type to support?
1. Only one type, which is UTF-8.
- operations like toLower() and slice() will be expensive
- when the string is actually arbitrary bytes there is no way to give
an error when character based operations are used.
2. Support an utf-8 string type and byte string
On both ASCII functions can be used, e.g. asciiToLower()
+ separate meaning of byte sequence from character sequence
- when only ASCII text is possible, operations like toLower() and slice()
are still expensive
3. Support an utf-8 string type, an ascii string type and byte string
+ separate meaning for the three types
+ possible to use efficient operations
- three types make it more difficult for the programmer
Choice 2: Strings are used very often, it's worth making them efficient.