Hacker News new | past | comments | ask | show | jobs | submit login

Adding an `Option` type to an existing language doesnt really solve many problems unless you can also somehow remove it's existing support for `null.

Java added `Optional` and while it makes interacting with newer API's clearer, there is nothing preventing you from passing a null Optional.

I think if you are designing a language from scratch, you should avoid null, but nullable types are a good feature for existing languages.

Having written a fair bit of kotlin, I have found the ergonomics of it's nullable type system to be really nice.




Language culture matters. Scala has both `Option` and `null`, but there's a strong culture of "`null` is only for Java interop", so you very rarely see a `null` in the wild from libraries, or wonder whether it'd be valid to pass it in.


Interestingly, Scala 3 is adding union types as well as explicit `null`s:

https://dotty.epfl.ch/docs/reference/other-new-features/expl...

I think that the expectation is that idiomatic Scala code will mostly still use `Option`, while `null` will be used for interoperability with Java, JavaScript or Scala libraries that happen to use `null`.

In any case, I am very much looking forward to these additions.


Your username is so incredibly relevant here that I had to check if this was a novelty account.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: