Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Option[X] is a crock. It's forcing you to write same bulky if-statements that you need to write for null checks.

I want something like NOT NULL in SQL. Can't static typing make it completely impossible that I'll get a null in a situation where it should be completely impossible?

For instance if something is typed as a collection, I'd like to never see null, I'd rather always get an empty collection. If I have to test for None, I'm just adding more bulky code where errors can hide, particularly when the type inference system in Scala is always doing strange things behind my back.

In my mind, automatic conversions make the problem worse in Scala, not better. Code "just works" for the programmer in certain situations no matter how inconsistent people are in the types they use.

The trouble I see is that Scala programmers seem to be pretty random if they're going return an Array, a java.util.List or a scala.util.List. This is really a pain in the ass when I'm trying to access some Scala objects from Java and I don't have automatic conversion available. I'm also sure that these different choices have all kinds of effects when you consider inheritance, variance, type inference and all that. It adds to the problem of spooky action at a distance in Scala.



You have never looked more than 5 seconds at Scala, right?

Option[X] is only a crock if you haven't understood it. Stop thinking of it as a "null check", start as thinking of it as a collection which can either hold 0 or 1 elements and then you are on the right track.

null in Scala mostly exists for Java compatibility.

Re: Collections ... you haven't looked even _once_ at it. All collections return an empty collection or None, based on the operation. There are maybe 2 methods in the whole Scala standard library which return null, and both are _not_ in the collection framework.

This is so unbelievable misinformed... I can't believe it you have no problem showing this level of ignorance publicly.

"type inference system in Scala is always doing strange things behind my back" ... Example please.

"Automatic conversions" WTF?

"The trouble I see [...]" this is so much pure bullshit.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: