News for hackers. Stuff that matters.
Re:In Defense of Scala. Response to “I Don’t Like Scala” by kasey_junk on Wednesday January 29, 2014 @10:30PM (#7148910)
Not sure how familiar you are with the Scala syntax, but that code actually has null pointer problems. The apply function turns Options into null pointers. They've given me the worst of both worlds, not only do I get null pointers, I get to have extra garbage created to accomplish it.
Re:In Defense of Scala. Response to “I Don’t Like Scala” by azth on Thursday January 30, 2014 @04:05PM (#7153358)
Yep I get that point. However, how would you avoid extra allocations and maintain safety (no nulls)?
Re:In Defense of Scala. Response to “I Don’t Like Scala” by kasey_junk on Thursday January 30, 2014 @10:43PM (#7155110)
I actually have no problem with the extra allocations if they maintain safety (that's not quite true, I actually need to break safety occasionally).

The problem is that the incoherent design of the collections library means that it is not clear to the programmers of the default mutable hash map lookup what they are striving for.

If they were striving for performance they would use a model that allowed for NPE against safety, that had allocation semantics that were sensible. Conversely, if safety was the overriding concern they wouldn't allow for the NPE.

Instead, in one of the most central data structures of the language we get unreasonable behavior. This is clearly a sign of bad design, thus reputing the original assertion that the Scala collections library were a good example of type programming.

PS: To trivially answer your question, they should have inverted the implementation here. A NPE throwing method for lookup wrapped with option sugar would make way more sense than the inverse.

Re:In Defense of Scala. Response to “I Don’t Like Scala” by azth on Saturday February 01, 2014 @01:58PM (#7162838)
Makes sense, thanks for your answer :)