News for hackers. Stuff that matters.
Re:Teaching D from Scratch: Is it a viable first language? by gavinray on Wednesday December 29, 2021 @06:21PM (#29731432)

  > "The features that I found the kids handled well were basic types like ints and strings (though what a funny name “string” is, that took a while to sink in)"
I have so ingrained in my brain the association of "string" to a text variable type that I didn't even consider the fact the name is bizarre.

It really doesn't make sense at first sight, and this is something I probably would not have realized until someone asked me "Why do they call it a 'string'?"

Fun read. D rocks.

Re:Teaching D from Scratch: Is it a viable first language? by doovd on Wednesday December 29, 2021 @06:26PM (#29731475)
Well, if you learn about chars and then realise a string is a "string" of chars, then it's not so bizarre. If we're starting with ints before introducing floats, then why not start with chars before introducing strings.
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".
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.

Re:Teaching D from Scratch: Is it a viable first language? by dmkolobov on Thursday December 30, 2021 @02:08PM (#29740154)
Definitely appreciate how careful Haskell is about the distinction: it's where I first started having these thoughts!
Re:Teaching D from Scratch: Is it a viable first language? by nicoburns on Wednesday December 29, 2021 @08:03PM (#29732245)
Well, not all languages have chars. And even in those that do, strings are not always made up of them (e.g. in Rust, char is 32 bits and strings are utf8).
Re:Teaching D from Scratch: Is it a viable first language? by girvo on Wednesday December 29, 2021 @10:24PM (#29733168)
We only apply that to strings though. float[] isn't a string of floats. And lots of languages have strings that aren't arrays of chars too, so I don't really think that's it either.

Where does string come from. How odd.

Re:Teaching D from Scratch: Is it a viable first language? by housecarpenter on Thursday December 30, 2021 @08:09AM (#29736411)
You do still hear people speaking of a string of bits, as well as a string of characters. I think the word "array" tends to be preferred for lists of numbers, since in its original sense in mathematics it was (and is) a synonym for "matrix". For lists of arbitrary objects I guess "array" won out by random chance, more or less.
Re:Teaching D from Scratch: Is it a viable first language? by girvo on Thursday December 30, 2021 @08:16AM (#29736458)
Really? Fascinating. I’ve not heard anyone call them that in my 20+ years of programming!
Re:Teaching D from Scratch: Is it a viable first language? by fnord77 on Wednesday December 29, 2021 @09:58PM (#29733031)
then why isn't an int array called a "string" of ints?