Hacker News new | ask | show | jobs
by muhehe 638 days ago
Is java still popular? Though I'm not a big fan of it I wouldn't mind using, but I'm after somewhat recent changes in licensing I'm not even sure I can. I don't fully understand the changes and I'm afraid of oracle coming after me :).

Can anyone explain current caveats and/or limitations with current licensing?

4 comments

>Can anyone explain current caveats and/or limitations with current licensing?

You can pretty much ignore the FUD posts about Java licensing. There are long winded replies to why it is FUD, but the short answer is it is trivially not a problem. It only applies if you use the Oracle JDK and want a certain type of support. Most of the world doesn't, instead using one of the other free JDKs.

Java is *not* popular in the reddit, HN, etc memesphere. In the real world it remains incredibly popular and a huge number of organisations continue to pick it as their language of choice for back-end development.

Java is more open than ever. Those random “scary” bullshit posts appear here and there but — OpenJDK is the standard reference implementation, and it has the same license as the Linux kernel. Different vendors give you builds of this same source, with some patches here and there, and they might provide support for their versions. One of these vendors is Oracle, who gives away the freemium OracleJDK. The latest LTS release is free to use with support, until the next one comes along, plus one year. But you would read more about different support services if you would need that - the same stuff is available for linux. In general, you can use any of these builds interchangeably, it doesn’t really matter. Like, intellij will offer you to download basically any of them.

So yeah, Java is insanely popular (top 3 language, among JS and Python, only their orders change depending on sane metrics (not you tiobe)), and is completely free with multiple vendors. Also, it’s pretty bullshit to consider Oracle any worse than other companies - they are the ones who completely opensourced OpenJDK and are responsible for 95+% of all the commits.

Java has a huge legacy code bases that depend on it but for new stuff Kotlin is probably the better choice. It is fully compatible with Java, which means you can add Java libraries and import them in your Kotlin code and use, inherit, overwrite functions and classes but also gives all the features of a nice modern language. I haven't used it for a serious project but it felt great from what I saw so far.

Android switched to it as the default as well.

Kotlin has a lot of really nice language features and it's Java interop is a big sell, but after digging into the details I'm pretty pessimistic about it's long term success for a few reasons.

They seem to be attempting to move away from the JVM, preferring it's own multiplatform native compilation which is significantly less battle tested and, last I checked, still suffers from serious performance issues. This is a shame too because Oracle has put a lot into the development of GraalVM, which is a great solution for native compilation of JVM languages, but Kotlin still wants to tread it's own path for some reason. It creates a weird fracture in the ecosystem where some libraries only support either multiplatform or the JVM, and I'm pretty sure Java can't even be used in multiplatform projects.

Another big issue is that idiomatic Java code can often feel clumsy to use from Kotlin: for instance Kotlin function types don't map nicely to functional interfaces and the syntax for AutoClosable/try-with-resource statements is awkward. I can only see this getting worse in the future, as Java continues to develop new features and standard library APIs that are designed FOR JAVA. An example of this already happening is Java's in preview structured concurrency API. It makes heavy use of try-with-resource and offers duplicate but not necessarily compatible functionality to Kotlin's own coroutine API.

Also build times... They have gotten better but they are still much worse that any plain Java project and Java build times are already not great.

I'm also a bit skeptical about Kotlin multiplatform, but I haven't seen it become an issue so far. Spring e.g. fully supports Kotlin (and so do tools like Gradle) and I've never had any issue with things not working.

Calling Java code from Kotlin may not always be 100% idiomatic but it's still by far the best interop between two different languages that I've ever seen (compare that e.g. to Scala). The interop is more than good enough to be viable for a migration scenario where old stuff is written in Java and new things are written in Kotlin - I definitely wouldn't recommend keeping writing both new Java and new Kotlin code, though.

Build times can be an issue (though hopefully improved with the new compiler), but incremental compilation helps (something that maven unfortunately sucks at, so it's better to use gradle). And in any case, the compiler does more (useful) work in Kotlin, so I think it's ok that it takes a bit longer.

Java is superior to Kotlin from Java 21 onwards, esp with virtual threads and no function coloring and far shorter compile times. Kotlin has the advantage of lower verbosity of-course, but that is not an advantage when code browsing at 3am.

Kotlin styles also differ considerably unlike Java which is far more uniform in comparison.

I think the idea behind Kotlin is that you don't have to do code browsing at 3 am, because you've already finished all your work by 5 PM.
You might have finished your work but not your project compilation - would need to set an alarm clock at night.

Threads like the below are surprisingly common even after several improvements in recent years.

https://discuss.kotlinlang.org/t/compiling-kotlin-is-x100-sl...

Perhaps, but probably don't attract many users like it used to be. For backend, some switched to Go. And on Android, some already switched to Kotlin.