Hacker News new | ask | show | jobs
by leshow 3327 days ago
I tend to agree. Sure, Kotlin is much more terse than Java. But looking at it I can't help much miss language features I've gotten used to in Rust, Haskell et al. I'm sure it's a wonderful language and an improvement over Java but there's nothing that excites me about it.

Hey, at least they've got nullable types? That's a big win over Java right there.

1 comments

> Hey, at least they've got nullable types? That's a big win over Java right there.

Can you elaborate what you mean by nullable types?

You can set Object variables to null and with primitives you can do the same with their boxed alternatives (Integer) but I assume you mean something different?

Like the lack of types which can't be null? I can see how that's useful

non-nullable*, Swift calls them optional types I believe. They use the same syntax for it, if you want your type to include "bottom" you add a ?

In Kotlin/Swift by default all types do not include "bottom" or "null". You add a ? to the type to indicate you may use that value, then the compiler will validate you're checking for the existence of null before you use the type.

It's one approach... I prefer the Haskell approach with a simple Maybe/Option type.

I think they meant to say that Kotlin has non-nullable types.

The Kotlin page does a good job of explaining it if you aren't familiar. It's the single most important feature that makes Kotlin worth using over Java in my opinion: https://kotlinlang.org/docs/reference/null-safety.html