Re:Teaching D from Scratch: Is it a viable first language?
by nerdponx on Wednesday December 29, 2021 @09:32PM
(#29732860)
Better yet, stop calling them "strings". Call the type "text".
[ Parent
| on HN ]
Re:Teaching D from Scratch: Is it a viable first language?
by dmkolobov on Wednesday December 29, 2021 @11:30PM
(#29733606)
I am writing an l-system evaluator, and have explained the concept to non-programmer friends of mine several times now. I've found myself explaining the concept of "strings" over and over, so I've switched to calling it "text" in those situations.
As a reasonably experienced programmer, however, this terminology makes me uncomfortable. To me, "text" implies a sequence of words written in a human language, rather than a sequence of arbitrary characters. It hints at structure which may not be present in a string.
Re:Teaching D from Scratch: Is it a viable first language?
by chriswarbo on Thursday December 30, 2021 @01:58AM
(#29734379)
I like the distinction made by Haskell:
- A Byte (AKA Word8) is 8 bits. It has no inherent meaning.
- A Character (AKA Char) is a Unicode code point.
- A ByteString is a sequence of Bytes. It has no inherent meaning.
- A Text (AKA String) is a sequence of Chars.
In particular, Char != Byte and String != ByteString; we can juggle bytes without having to care about encodings; and we can manipulate text without having to care about its representation.