News for hackers. Stuff that matters.
Re:Kotlin becomes second most popular language on the JVM by watt on Thursday February 06, 2020 @11:42AM (#22257519)
Null safety is the one big win for Kotlin. https://kotlinlang.org/docs/reference/null-safety.html
Re:Kotlin becomes second most popular language on the JVM by vips7L on Thursday February 06, 2020 @12:14PM (#22257928)
I agree, but like I said it's not enough for me to switch. I use Optional<T> whenever I need to return null. The only outlier there is the JDK which most devs should know when it's returning null to you.
Re:Kotlin becomes second most popular language on the JVM by dajohnson89 on Thursday February 06, 2020 @01:38PM (#22258821)
isn’t optional just replacing the null check with if(optionalRef.isPresent)??

i kinda get how this is safer, but clients can just call optionalRef.get() without checking, and boom there goes the safety. compiler warnings be damned.

Re:Kotlin becomes second most popular language on the JVM by vips7L on Thursday February 06, 2020 @01:43PM (#22258891)
Optional is just signaling to the user that they should check.

You could also do this in Kotlin and boom there goes the safety:

  fn nonNull(): String {
    val s: String? = null
    return !!s
  }