Hacker News new | ask | show | jobs
by jmarlow47 49 days ago
It's really refreshing to see the pace of Java development pick up so much over the past few years.

The last few years of server-side has been on Kotlin for me, however, modern Java is looking more and more like anything I'd need in a language.

5 comments

I never fully switched to Kotlin. It’s good, but not good enough. I also like the direction Java has been evolving in over the last 10 years, to the point that a JVM server is actually lighter than a Node.js server :)
What wasn't "good enough" for you in Kotlin?

Sure, Java is slowly getting most of the features and sometimes even in a better form because they control the runtime (virtual threads arguably just work). But IMO Java is still incredibly verbose, Kotlin's type system is just better and I've genuinely never come across anything that would be easier to do in Java. Even virtual threads can be used from Kotlin.

For me, Java 8 was tolerable. Also used IJ a lot and it hides Java verbosity and reduced a lot of typing. That's why I didn't really see the need to switch. For better or worse, these days I don't even open IJ and just use VSCode + AI Badger mostly to review my changes. Language matters even less.
I don't think Kotlin has fully fledged pattern matching with destructuring yet (like in Java's records) does it?
No it doesn't, but it also doesn't need it. Whereas in Java you write:

  if (obj instanceof Point(double x, double y)) {
      foo(x,y)
  }
Kotlin with its smart cast feature lets you do

  if (obj is Point) {
    foo(obj.x, obj.y);
  }
I would never use the proposed style for Java. This is simpler and easier to understand for anyone with basic knowledge of Java. Readability is more important than fancy features:

if (obj instanceof Point p) {

    foo(p.x(), p.y());

}
I’m so glad they made that change. So much better than the old days.

I love Java and I’m so glad it’s kept improving so much despite all the turmoil in its ownership.

I see no reason other than Android, where Android engineers live in the past and don't bother to support modern Java, other than when Kotlin starts to lose the amount of Java libraries able to run on Android.

Many years ago I learnt that mastering the language that goes alongside the platform is quite valuable versus the languages that come and go.

Hence why despite my rants, I keep my C knowledge up to date, as it is the language of UNIX, same with JavaScript on the Web, Erlang on BEAM, and naturally Java on the JVM, even though Scala and Clojure are much cooler.

Elixir developers outnumber Erlang 2 to 1, I think you'd do well with Elixir.
First of all I like Erlang, given its Prolog influence, secondly without BEAM and Erlang there is no Elixir.
> see the pace of Java development pick up so much over the past few years.

I don't think that is a fair assessment. Java / JVM has been steadily progressing in the past 10 - 15 years. From languages to different part of JVM. It is only getting the sense development being picked up because HN and other social media are finally getting the clicks and interest again. The pendulum swing back because of all of different reasons.

And in reality a lot of these recent landed improvement were 5 - 10 years in the making.

I still don't like its syntax though. But I am not even sure if it is even an issue in AI driven development era.

Java 8 (early 2014) is where Java got interesting again. Lambdas and streams fundamentally changed the language. java.time was a very big deal too.
Yah but why? The things it was good at doesn’t really matter nearly as much post AI.
> Yah but why? The things it was good at doesn’t really matter nearly as much post AI.

Pretty much the opposite. Those who disliked it usually cited having to type too much due to class verbosity and variable verbosity (the former has merit, the latter was purely a choice).

If you no longer need to type in any of the code, what better than a language with a blazing fast and scalable runtime, with excellent debugging and monitoring support.

Most importantly IMO the JVM ecosystem has lots of solid, battle-tested, enterprise-grade frameworks like Spring and Quarkus, which do all the heavy lifting for those kinds of applications. The code can still be verbose, but that is solved by LLMs, as you said.

Rust has all the individual bits you need as libraries (web server, database access, etc.) but you have to wire it all together yourself. Sure LLMs can do that too, but how do you know the LLM did it correctly? There could be complex interactions between the individual libraries.

Using a complete framework solves that, you know its bits will work together correctly. It also makes the code structure of different applications look more similar, which probably helps LLMs understand it better too.

Also, I think too many people mistake Rust's type system for what is actually common across all languages with a Standard ML linage.

Thus anyone without issues using a GC language, regardless of which GC shape, has already plenty of choice on the JVM, not only the frameworks.

But if you want "blazing fast" performance then there are other languages like Rust that the AI can write, and Rust runs basically everywhere Java does these days (and more) except perhaps Android, for which there are still ways around it.
Incidentally, Java seems faster on the server side than Rust in several benchmarks I've seen and tried locally - yes to be taken with a grain of salt, but point being that Rust is not the be-all performance aspiration - there are some really good Java One 26 and Devoxx 26 talks pertaining to the importance of well spec'd languages like Java and runtimes like the JVM in the age of AI. And this is without talking about things like monitoring and observability.
Cold start times matter, especially for things like server functions.
> Rust runs basically everywhere Java does these days (and more)

I don't follow Rust as much as I wish I could if I had more free time.

What platforms are supported in Rust that don't support Java?

Does Rust have diagnostics, monitoring and debugging support anywhere near JVM quality?

Primarily embedded, for which Java is basically unsupported for many use cases. Rust does have diagnostics and monitoring but it's debatable if they're as good as the JVM although again some places Java can't even run.
Plenty of embedded vendors have Java implementations.

PTC, Aicas, microEJ, Ricoh, Xerox, Cisco, and several M2M vendors.

The first three even have bare metal variants, where the runtime is the OS.

Naturally they aren't targeting ESP32, Arduino, PIC class of devices.

Many of us know how to write blazing fast code with Java, first step is embrace the ecosystem, followed by actually understanding algorithms and data structures.

Most rewrite language X in Y are justifications after the fact, when the real reason is language Y was cool for whatever reason.

Sure but they asked specifically "if you no longer need to type in any of the code" so that's where it gets confusing. If you don't need to write it then why still pick Java? There isn't much benefit over Rust, and lots of cons such as slow cold start time comparatively.
For complex enough and long-running application your run-of-the-mill Rust (so probably what AI would generate) will likely be slower than your run-of-the-mill Java.

I know this is a heresy in some online religious groups pretending to care about engineering but that's reality.

I doubt that. How can you measure what average is and what the performance is? Any benchmarks? If not then it's just he-said-she-said.
> For complex enough and long-running application your run-of-the-mill Rust (so probably what AI would generate) will likely be slower than your run-of-the-mill Java.

That phrase "complex enough" seems to be quite load bearing.

At which point does complexity reach the tipping point where a Java implementation becomes faster? From my experience, the more complex the application, the more enerprisey the Java code becomes, relying heavily on dynamic capabilities that make it slow even by Java standards.

Quite the opposite. Java is almost all about an optimising runtime with deep telemetry, and it helps with exactly the things AI needs the most help: https://youtu.be/fXBGBovpH88
I now manage a team writing languages on the jvm. I have found the jvm ecosystem terrible for observability. Examples;

- junit parallelisation - how are shards handled? how do you balance the tasks across forked processes? What is the bottleneck? Options are 1) pay someone for better tooling or 2) write your own

- long pauses in garbage collection - how do you know which objects are causing the pauses? the options; 1) profiling 2) analysing heap dumps that you periodically capture 3) add metrics or gc logging

- what is the performance bottleneck? options 1) profiling

Sure AI can do this stuff, but it's painful and time consuming

Contrast it to Elixir on the BEAM;

- exunit parallelization - basically free and because you don't have coupling due to OOP. mocks are basically an antipattern

- long pauses due to gc? They just don't happen - everything is isolated and can be cleaned up in parallel.

- performance bottleneck? Open inspector and see what is doing all the reductions, and if any of the inbox queues are backlogged. You don't have to profile, you can just look in production - memory? Open inspector and sort processes by size descending. Again no profiling needed

JFR is what you'd use for everything you need to know. It's depth and breadth are unmatched.

> Contrast it to Elixir on the BEAM;

Java is in the same performance class as C++. BEAM is wonderful in its own way, but it's not even in the same performance class as Go.

BEAM was designed for some interesting resilience in distributed systems. The JVM was designed to address the performance issues that programs in C++ and other low-level languages suffer from when they get large and/or are maintained/evolved for a long time.

> long pauses due to gc? They just don't happen - everything is isolated and can be cleaned up in parallel.

GC pauses in the JVM have been optional for a few years now. ZGC doesn't have GC pauses.

We're talking past each other a bit. I was just trying to give examples of where observability on the jvm isn't that great, because you were were stating it's where AI needs the most help.

The parent was saying these new features don't matter as much post-AI and i think I agree with them. The AI can just write in rust if you need to optimise a hot loop, but if you need observability, you could do worse than the BEAM.

> GC pauses in the JVM have been optional for a few years now. ZGC doesn't have GC pauses.

yeah that's a fair comment, zgc is a lot better for pauses. I'd still say that it pulls along a fair bit of incidental complexity - it encourages you to allocate a fair amount of memory to your heap, which isn't ideal in this world of kubernetes and microservices. If you leave on uncommit (returning memory to he OS periodically) you get extra latency penalties which are just as painful as garbage collection stalls IMHO.

BEAM's observability is very good, but JFR is unmatched. We're not talking about debugging, but about low-overhead deep telemetry (or "always on, in-production profiling"). eBPF helps, but it doesn't come close (e.g. dynamic allocations are much expensive in low-level languages than in Java, but even if you probe malloc, it doesn't tell you the type of the object allocated).

> The AI can just write in rust if you need to optimise a hot loop

Why would it when it could just write it in Java? The JVM was invented not because we couldn't write code in C++ but, among other things, to optimise things (especially around memory management and inlining) that low-level languages have trouble optimising in a large class of applications. If you're after the best performance, then you'll ask AI to use a low-level language when a low-level language offers better performance, and to use Java for applications when Java offers better performance.

Java isn't a performance compromise. It offers different tradeoffs that could make some programs significantly slower than low-level languages in some cases and significantly faster than low-level languages in others. That's the point of the approach taken by the JVM: to offer optimisation opportunities that aren't available in low-level languages. People who think low-level languages always offer better performance are people who have not had much experience with low-level languages. I originally came to Java from C++ because Java has optimisation opportunities that low-level languages don't (they have to compromise on performance in some situations for the sake of low-level control) that matter in certain but very common kinds of programs.

> zgc is a lot better for pauses

It has no real GC pauses. It does have minuscule pauses for synchronisations, but those are an optimisation, and they're no worse than OS jitter. In other words, if ZGC's pauses are a problem for you, then you won't use a non-realtime kernel, as you'll get similar pauses even in a C program on the same OS.

> I'd still say that it pulls along a fair bit of incidental complexity - it encourages you to allocate a fair amount of memory to your heap, which isn't ideal in this world of kubernetes and microservices.

It really doesn't. All of our GCs are optimised for a natural rate of allocation. They do discourage pooling objects to artificially reduce allocation rates, though, but it's easier to not pool than to pool.

> If you leave on uncommit (returning memory to he OS periodically) you get extra latency penalties which are just as painful as garbage collection stalls IMHO.

You get such stalls and worse with C++ or any other low-level language.