K
Keith Thompson
glen herrmannsfeldt said:Do you like the way Java treats arrays better?
Among other things, they do have a length that goes along with them.
I don't know Java well enough to have much of an opinion.
Java's mechanism likely involves some extra overhead relative to the C
approach. That's probably fine given the kinds of applications Java
targets. C is a substantially lower-level language, and I'm glad it
exists (for things like writing Java byte-code interpreters).
(Disclaimer: I don't know what language the Java byte-code interpreter
is written in.)
It would be interesting to have a language that's on a similar semantic
level to C, but that doesn't have C's odd treatment of arrays and
pointers. Such a language might not have arrays as first-class types,
but it wouldn't pretend to do so by adding special-case rules. It might
have the same underlying semantics as C, but with different syntax to
express its semantics.
I haven't given much thought to what it would look like.