3 ms·
I'm biased in the matter, but I have to agree. There are a number of problems with it. Arrays are covariant, and object is the base class of everything. I'm su
by jesserayadkins2 10y ago
I'm biased in the matter, but I have to agree. There are a number of problems with it.
Arrays are covariant, and object is the base class of everything. I'm surprised that nobody's noticed that already (it's unsafe: arrays should instead be invariant).
It doesn't seem like there are any first class functions, and there's no tuple class either. I don't find any mention of mapping/selecting/reducing within standard collections.
For all (heh) the boasting about the type system, covariant arrays produce other problems too. If you have a function that takes an `Array[nullable Int]` and send it `Array[Int]`, the type system doesn't say anything about it. That means you could get into problems down the line. It's also possible to take a nullable Int and do `.as(Int)`
`var v = 1 / 0` causes FPE and core dump and dumps an ugly compiler stack trace.
The documentation about abort also mentions that there's no stack trace for it.
I don't think there are standalone functions with generic typing either, just classes with generic types. I suspect that their virtual types are probably unsound, but haven't tried working with them.
- catnaroek 10y ago> Arrays are covariant, and object is the base class of everything. I'm surprised that nobody's noticed that already (it's unsafe: arrays should instead be invariant). The real problem is that most languages don't actually give you arrays, they just give you mutable cells containing arrays of mutable cells. Remove mutable cells from the picture, and you'll see how wonderfully covariant array types are. Arrays are really second-class values in the vast majority of languages. The litmus test for first-class-value-ness is “Do I need to worry about the identity of the object that holds this value?” The answer should be “no” if the value is first-class. > `var v = 1 / 0` causes FPE and core dump and dumps an ugly compiler stack trace. Exceptions don't make much sense for handling programming errors like division by 0. What is your program supposed to do? Fix itself? > I suspect that their virtual types are probably unsound, but haven't tried working with them. They are indeed unsound, for pretty much the same reason covariant method arguments are unsound in Eiffel. I have an example here: https://news.ycombinator.com/item?id=11752071 https://news.ycombinator.com/item?id=11752071