News for hackers. Stuff that matters.
Re:Kotlin becomes second most popular language on the JVM by vips7L on Thursday February 06, 2020 @09:30AM (#22256181)
Modern Java is actually quite good. The main three things that Kotlin offers, in my eyes, are Data classes (in preview in JDK 14), Coroutines (should be coming soonish with loom), and nullable reference types (not big enough for me to switch).

Outside of Android I wouldn't choose Kotlin.

Re:Kotlin becomes second most popular language on the JVM by wrmsr on Thursday February 06, 2020 @12:16PM (#22257946)
I've found Optional<> to at least ~help~ with the null issue - as we still don't have value types it still does come with a runtime penalty but most of the code I write and deal with these days has a no-null policy: if it's optional it's Optional<>, everything else defaults to sane defaults or 'empty' (usually immutable) objects. There will of course always be nulls in legacy and performance sensitive code but it is at least ~something~.
Re:Kotlin becomes second most popular language on the JVM by gambler on Thursday February 06, 2020 @11:27AM (#22257362)
>Modern Java is actually quite good.

Lambdas can't handle checked exceptions, which are the most common exceptions in the system.

There is no way to extend Stream with your own methods.

Still 8 primitive types to wrestle with.

Just to name a few issues. And there are lots and lots more.

The language is simply not extensible enough to write anything elegantly.

Re:Kotlin becomes second most popular language on the JVM by vips7L on Thursday February 06, 2020 @12:05PM (#22257816)
Just handle your catched exceptions? It's not that hard.

  () -> {
     try {
       // do work
     } catch (IOException ex) {
       throw new UncheckedIOException(ex);
     }
  }

I also agree with Goetz that extension functions aren't something we need.
Re:Kotlin becomes second most popular language on the JVM by int_19h on Thursday February 06, 2020 @11:09PM (#22263150)
What's the point of even having checked exceptions, if you're going to have an unchecked counterpart for every one of them just so that you can flow them through lambdas?
Re:Kotlin becomes second most popular language on the JVM by pjmlp on Thursday February 06, 2020 @01:10PM (#22258502)
Not only isn't hard, one can write a generic utility method.

Regarding extension methods, while they are nice, with import static it just a matter where the extended type comes, big deal.

And from experience in .NET world, hunting them down isn't always fun, even if they are just Ctrl+F12 away.

Re:Kotlin becomes second most popular language on the JVM by cryptos on Friday February 07, 2020 @06:18AM (#22264940)
It is not hard but cumbersome, ugly and ruins readability when used a lot.
Re:Kotlin becomes second most popular language on the JVM by lmm on Thursday February 06, 2020 @08:10PM (#22262270)
> Lambdas can't handle checked exceptions, which are the most common exceptions in the system.

You can do exactly the same thing that Kotlin would do for you and just rethrow them as runtime exceptions. It's one extra wrapper call; not great, but not a huge overhead either.

> There is no way to extend Stream with your own methods.

That's just syntax sugar; all it's actually doing is calling a static method, which you can still do in Java.

> Still 8 primitive types to wrestle with.

You can just ignore them and use the object versions everywhere, and then it's not a problem.

There are a bunch of irritating warts in Java, but irritating warts alone are not worth switching language over.

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
  }
Re:Kotlin becomes second most popular language on the JVM by lllr_finger on Thursday February 06, 2020 @10:01AM (#22256426)
I would tout sealed classes as well, although I think Java has a proposal that's getting traction.

For back-end service/API type things in an enterprise setting, Kotlin is a good value proposition. There's also probably some truth to the idea that one reason modern Java is adding these things is because of Kotlin's existence.