String type is an alias for
[Char] (i.e. a linked list of
Chars). Does any other language use an implementation of strings like this?
Yes. Erlang does the same, as well as quite a few other functional programming languages.
Using strings as a list of chars makes them very easy to pattern match and reason about. However, their performance is relatively bad:
- accessing the nth character in a string takes walking through all n-1 items before it. This is thus linear in time.
- appending strings is slow for the same reason (you need to loop through all characters of the first string)
- in a linked list, you need to store both a character and a pointer to the next character. This takes a lot more memory (for each character, you need both the character itself plus a pointer to the next memory location, which on most systems actually takes more space than the character itself).
Also, Unicode, where one grapheme might consist of multiple characters, has made them even less practical, as this makes the pattern matching on characters very awkward again.
Often, these languages also have other ways to deal with strings that are faster, but harder to manipulate. For instance, Haskell has the Text type, and Erlang has Binaries that can be treated as strings.
"abc" syntax in Prolog is usually a shorthand notation for a list of character codes, i.e.
[97,98,99], which is also the case in Erlang. See this question for details. When a Prolog implementation supports a custom string type (e.g. ECLiPSe/SWI/YAP), there are predicates to convert from and to lists of character codes.