Live data from Hacker News

Don’t call it a comeback: Java is still champ

github.com

491–500 of 557 posts

Re: Don’t call it a comeback: Java is still champ

#491
post #64

Earlier quoted context omitted.

> but I think it'll slowly move the way of COBOL and FORTRAN That could be true of any language that's achieved great popularity, but in 2022 Java is the language that dominates server-side development (by plurality, not majority), it is a technological leader in areas of compilation, garbage collection, and low-overhead in-production profiling, no other single language looks posed to seriously challenges Java's domi…

Aren't most of those benefits from the JVM rather than Java itself?

First of all, what most people call "the JVM" is really called Java. Java = libraries + VM + tools + language. Of the ~8 MLOC in the JDK, the Java language compiler and Javadoc make up around 200KLOC; the VM makes up about 1.5M. What is sometimes colloquially known as "the JVM" is really everything except the language, of which the actual JVM is pretty small.

Second, while the JDK is pretty modular (e.g. you can use the runtime and tools but not the frontend compiler as "JVM languages" do), we design every feature by looking at the platform as a whole. E.g. the relatively new records feature is implemented in the language, libraries, and VM. That's why some newer Java platform languages have more baggage than the Java language, because their features are not harmonious with the direction of the libraries and VM (e.g. Kotlin's coroutines and data classes).

Finally, it is true that back in the '90s, James Gosling set out Java's strategy to put most innovation in the runtime and keep the language very conservative (he called it "a wolf in sheep's clothing"), and we follow that strategy to this day, because it's turned out to be very successful. While there are lots of programmers who want more adventurous, feature-rich languages -- and many of them hang out here -- the vast majority of programmers don't. Many more people complain that the Java language is changing too quickly than changing too slowly. So it is thanks to the conservative language that the platform is so popular, which allows us to have the resources to innovate in the runtime.

So while <10% of people using Java do so with another language (no single alternative language has gained more than 5% of the platform's ecosystem) -- and we're happy we can accommodate everyone -- the conservative language is a necessary component of making the runtime state-of-the-art. A combination of an innovative runtime and a conservative platform is what most people want, and that combination is the main benefit.

Re: Don’t call it a comeback: Java is still champ

#492

Earlier quoted context omitted.

Old school xml based Spring is horrible and if that was your only exposure, I understand your aversion. But spring-boot has an almost zen like quality once you get that it favor convention over configuration. When I was a Java developer, I'd usually use spring-boot with the following dependencies to make the experience better: - lombok: to generate the boilerplate: constructors, getters, setters, equals, hashcode...…

Sorry, but the popularity of tools which generate boilerplate for you is, in my opinion, one of the biggest indictments of the whole ecosystem.

It's worth noting that these days the "Java ecosystem" includes languages like Kotlin which eliminate all that boilerplate, and in fact are impressively boilerplate free. So you don't have to use stuff like Lombok.

Of course it's ambiguous because Java can mean both the language, and the wider ecosystem of libraries, languages, JVMs, tools etc.

Re: Don’t call it a comeback: Java is still champ

#493

Earlier quoted context omitted.

What's your take on Kotlin? Neatly solves a ton of these issues.

I’ve looked at Kotlin but haven’t used it. It seems like it was designed carefully, and conceptually, I think Jetpack Compose is pretty cool. Is there a (non-Spring-like) Kotlin server-side framework you would recommend taking a look at?

https://ktor.io/ for Kotlin server side. It's not as large/complete as Spring Boot but you may find it preferable.

Re: Don’t call it a comeback: Java is still champ

#494
post #472
post #455

Earlier quoted context omitted.

Yes, the scandalous SCO lawsuit and subsequent Linux patent racket make it impossible to believe M$'s Linux fud.

What

Google "SCO lawsuit Microsoft". For years around the same time Microsft also extorted huge sums from Red Hat and Suse Linux for unproven patents which they claim Linux source code infringed. The two companies figured it would cost them less to pony-up rather than fight M$ in court.

Re: Don’t call it a comeback: Java is still champ

#495
post #44

Earlier quoted context omitted.

Have you explored Kotlin? It's really not just for Android.

I have, it's a nice language but I didn't like the mental tax of translating Java code to Kotlin in my head whenever I had to read up on how to do something I do intend to dig into it a bit more once I feel like I have mastered Java

> I have, it's a nice language but I didn't like the mental tax of translating Java code to Kotlin in my head whenever I had to read up on how to do something

You can always let your IDE also do some of the work, at least for a quick reference: https://www.jetbrains.com/help/idea/get-started-with-kotlin....

Of course, when you get into slightly different idioms or design pattern implementations, things might require a bit more mental effort and manual work.

Re: Don’t call it a comeback: Java is still champ

#496

Earlier quoted context omitted.

> I once worked on a Java-based server at Google This is kind of a fair comment, but kind of not, because Java performance and GC internals have really advanced a lot in the last decade. It would really help if you qualified approximately when this was. > Sadly the garbage collection debate is full of people who want GC to be the answer to everything Good point. I think more recently, the Java world is very aware of…

I agree with all this. Java is a great application programming language. But bullen was arguing that Java is the best for servers of all types, which is what I object to.

It's worth observing that ZGC can actually do sub-millisecond pauses. That didn't exist when you were at Google and it's still pretty new (and low throughput until they make it generational). But it's definitely on the edge of being able to handle even that sort of demanding latency requirement, at least as long as you aren't overloading the servers.

Re: Don’t call it a comeback: Java is still champ

#497

Trouble with java is that it does not scale up or down in terms of ram. Minimum RAM for a sever doing something normal over tcp is measured in gigabytes. Big servers > 16gb get difficult to manage at runtime. You have to scale with more VMs. You can write useful C servers that are very small, especially if you compile with musl. And run the same code for 1000kcc (not a typo) When you have big arrays of memory storing…

> Minimum RAM for a sever doing something normal over tcp is measured in gigabytes.

Some of my Java services run with around 256-512 MB of RAM per instance, in Spring Boot containers (though Quarkus and Dropwizard can be even more conservative outside of enterprise bloat situations).

That said, I'm inclined to agree in general, as I've seen monolithic Spring applications that refuse to run with anything less than 2-4 GB of RAM given to them.

Perhaps even worse yet, there's no way for you to properly cap the resource usage within containers so you'd end up with more aggressive GC inside of containers but without OOM issues, when they're given a memory limit. -Xmx regularly gets exceeded because that's only a part of the equation and the creators of JVM didn't really think of a case where you should be able to give the whole thing a number of MB/GB it's allowed to use, which would never be exceeded, whatever it takes.

> My other gripe os that "write once run anyway" is no longer close to true, since Oracle. Mac, Linux x64 and Windows 64 are your only sane options.

Agreed, then again with most "business" software running in x86 OCI containers seems like the only sane option. Though I guess it depends on the environment that people have grown accustomed to and how they've been burnt in the past (e.g. I'd never want to use package managers or worse yet, extract random tar/zip archives for "business" software, never install Tomcat on the system directly etc., only use containers that are 1:1 the same in all environments where they're run).

Of course, web dev is just a part of the greater picture, so there's lots of nuance there as well. Personally, SIM cards running Java seems like insanity to me, though: https://en.wikipedia.org/wiki/Java_Card

Then again, I'd say the same about Python implementations that are geared towards embedded setups, personally even Go seems like a better fit if someone didn't want to use C/C++/Rust, though platform support would still be a relevant question.

Re: Don’t call it a comeback: Java is still champ

#498

Earlier quoted context omitted.

Erlang is not as peformant as Java, but there are plenty of reasons to prefer the former to the latter: - a much better concurrency model, that gets you parallelism for free just by adding cores - no global gc pauses, low-latency - fantastic operational tools (trace debugging, remote shell, etc.) - Erlang/OTP gives you great middleware out of the box, including including queues, pub-sub, service monitoring, database,…

> no global gc pauses, low-latency Java also has this for at least a few years now. G1GC and ZGC in JDK17 offer no global stops unless absolutely necessary, and ZGC even has latency targets.

Not quite.

G1 offers pause time goals so you can balance throughput or latency but it still has global pauses.

ZGC doesn't because it doesn't pause your app. Its design doesn't allow any tradeoffs there.

Re: Don’t call it a comeback: Java is still champ

#499
post #405

Earlier quoted context omitted.

Malloc and friends have much more CPU overhead than a modern GC, so if you do choose all of these, brace yourself to a really micromanaged programming.

That's a common wisdom, but there is little if any evidence to support it. True GC costs are simply more hidden and harder to measure. A malloc/free pair might be slightly slower than Java's new (not by much really - go measure), but invoking `new` is not the only cost of GC. https://arxiv.org/abs/2112.07880 Also modern low pause GCs have way higher CPU overhead than the old STW ones. Try to set a low pause GC pause…

Your point on low-latency GCs is indeed fair (read barriers vs write barriers), and I should have probably specified ref counting where the overhead is much more apparent (and is a fairer comparison).

But regarding malloc-only, fragmentation also comes into picture which does have a non-negligable effect. And while Java does like to “heap”-allocate, it happens foremost on thread-local buffers and are used pretty much as an arena allocator. Even without escape analysis, these are very cheap all around.

Re: Don’t call it a comeback: Java is still champ

#500

Earlier quoted context omitted.

> Java's GCs are incredible and you have a menu of algorithmic options can these options be used in separate parts of a single app ? e.g. the app I'm developing in C++ has parts that do realtime audio, others that do GPU rendering, others that do classic Qt Widgets GUI, others that do offline computations on datasets - and they all have different performance characteristics and need different memory management scheme…

If Java had isolated heaps then C++ would become redundant in every aspect except memory efficiency.

Actually it does if you use the GraalVM Native Image AOT compiler. It's a sort of pseudo-JVM that gets linked into your app and provides the following features:

1. Instant startup due to AOT compilation and a cached heap. Can start faster than C!

2. No warmup.

3. Can create native code shared libraries.

4. Offers isolates, which are segregated heaps that do GC separately but run in-process and which can communicate with each other.

The tradeoffs are that unless you buy the more advanced edition, peak performance is lower due to lack of JIT profiling, you may need to write configs and do other fiddling to ensure the AOT compilation doesn't miss any code that's accessed via reflection, it takes a long time to compile, and you can't dynamically load bytecode (which some libraries do behind the scenes transparently).

Post reply on HN