Why do languages like Java distinguish between string and char while others do not?
Bottom line is that is just how the language designer decided to make it. It's hard to get too much further than that.
However, one point about C, which is generally considered a lower-level language in that the syntax more accurately reflects the nature of the data and tasks being performed. Treating a character as a string would be a level of abstraction that would be uncharacteristic of C. It would make it less clear what the data is like under the covers. And it would almost certainly add overhead when all you needed was a character.
Note that C-type languages do support single character strings, and so you really have the best of both worlds in my opinion.
I've noticed that languages like Java have a char primitive and a string class. Other languages like Python and Ruby just have a string class. Those languages instead use a string of length 1 to represent a character.
I was wondering whether that distinction was because of historical reasons. I understand the language that directly influenced Java has a char type, but no strings. Strings are instead formed using char* or char[].
But I wasn't sure if there was an actual purpose for doing it that way. I'm also curious if one way has an advantage over another in certain situations.
Why do languages like Java distinguish between the char primitive and the string class, while languages like Ruby and Python do not?
Surely there must be some sort of design concern about it, be it convention, efficiency, clarity, ease of implementation, etc. Did the language designer really just pick a character representation out of a hat, so to speak?