News for hackers. Stuff that matters.
Re:The Unsound Playground: Java and Scala's Type Systems are... by Groxx on Sunday November 27, 2016 @05:34PM (#13052019)
Without generics (this is java 1, remember) it seems like a reasonable tradeoff. Otherwise[1] you can't have array-modifying polymorphic code at all - how would you write a "reverse this array" function, for instance? You'd need one for every kind of array you want to reverse. Or a "copy" function - even if you're given a properly-sized-and-typed array to put the values in, you can't make a function that'd work on anything except a single type.

You could force every array-function-caller to cast their args to e.g. `Object[]`, but that seems like it'd require more work for even less safety. Though I'd love a read-only concept in Java, for read purposes :|

[1]: I think. If I'm wrong, someone please correct me!

Re:The Unsound Playground: Java and Scala's Type Systems are... by RHSeeger on Sunday November 27, 2016 @08:40PM (#13052841)
You could define what an array accepts vs returns separately (input vs output). Admittedly, you're pretty much into generics (good ones, not what Java has) at that point.

Edit: Could use a better word for "good" that sounds less dismissive, but I couldn't think of one. Java's generics are lacking in certain areas, unfortunately.

Re:The Unsound Playground: Java and Scala's Type Systems are... by MrBuddyCasino on Monday November 28, 2016 @04:09AM (#13054283)
Generics in Java are pretty complicated already, so much so that very few developers fully understand them. I'm not sure the gain in complexity would be worth the added safety.

I'd like to see examples in languages where this is possible, if there are any?