Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

How timely!

https://stackoverflow.blog/2021/02/22/choosing-java-instead-...

I do believe that there is nothing better tuned for performance vs developer productivity than the JVM.

The language semantics may be a question for personal distaste..but then you do have Kotlin (https://jooby.io/ ) which ranks fairly near the top on techempower benchmarks https://www.techempower.com/benchmarks/#section=data-r20&hw=...



sort by: page size:

I think any of the JVM languages like Java, Kotlin, Clojure, Scala, Eta, etc.

The JVM as far as I know is still the runtime king, faster then Go.


> "so it's actually something not that non-special."

That is not totally true, This is a mix of 2 things, using the JVM (which like you said is being tuned and optimized for heavy loads) + using a true asynchronous and reactive programming (and IO) model built on great technologies such as (in this specific case: Kotlin, Eclipse Vert.x and Netty).

As an experiment if you would pick another random set of libraries (imagine a servlet container) achieving the same results would not be so trivial, see for example:

https://www.techempower.com/benchmarks/#section=data-r17&hw=...

And observe that Eclipse Vert.x is on the top for these reasons while other JVM frameworks are far behind.


I think the best benchmark for this is to look at the industries where performance matters and see what they are using. Take high-frequency trading where lowest latency makes the most money. I don't see many using the JVM. AFAIK it's all assembly, C and C++. If they could use the JVM and have faster code, they would be doing so.

Somehow the landscape of low-latency Java doesn't include other JVM languages so I don't think it's easy to achieve with Scala or Kotlin.

They have in practice been slower because they try to be higher level, more ergonomic languages than Java. There aren't many performance-first JVM languages yet I think (Fortress maybe? They cited JVM problems when they wrapped up though).

In benchmarks I've seen, Java already smokes Go on any benchmark except the second or so it takes the JVM to start up.

I'm not aiming this just at you, but I think many people (node.js users in particular come to mind) don't realise just how good the JVM is, performance-wise. I'm not a great fan of Java the language, but the JVM is top class.


As per that list Java is still faster for most of the benchmarks. Massive effort has gone into the JVM too, for the last 20+ years.

If you really want to nerd snipe, write an optimized version in a non-JVM language to compare to the fastest Java one. But that's kind of boring anyway, we've seen this play out a thousand times.

I still appreciate the intention of seeing how far we can squeeze performance of modern Java+JVM though. Too bad very few folks have the freedom to apply that at their day jobs though.


The idea of improving runtime speed and benchmarking has really bifurcated into single threaded and parallel programming universes. Most platforms have O(10) cores now so it's an order of magnitude question, but exploiting that is a problem that few languages are helpful at. JVM is much better for that than JSVM though.

(But usually the much bigger speed problem is in the programming phase, better to optimize for programmer performance than runtime performance or risk not delivering anything due to time/money limitations)


The performance of the JVM was definitely a fair criticism in it's early years, and still is when writing performance-critical applications like databases, but it's still possibly the fastest managed runtime around, and is often only a margin slower than native code on hot paths. It seems the reputation has stuck though, to the point that I've seen young programmers make stock jokes about Java being slow when their proposed alternative is Python

Extremely interesting. Since we're bench marking it with C++, is it safe to assume it performs much better than the JVM?

Very exciting initial results. The JVM simply is the most optimized runtime available right now. And Java is the dynamic language with best performance. Can't fail to notice Ruby is the slowest even on JVM. If you continue on this path and refine your APIs to be more user friendly, this would be the next big asynchronous server out there!

I've played both with frameworks on JVM, python and node.js. Of course speed is not all there is, productivity is usually more imporant; still this benchmark is nice reminder to people that JVM is one wonderful peace of software out there.

And you can achieve better performance with JVM as well. Its just about how you write that Java (or use Clojure) or something.

"Fast" is subjective. "Fast enough for X" is better, but still subjective unless you have benchmarks. That said, I agree Java is good enough for, say, long running web-services where you take the JVM start-up hit once.

http://www.techempower.com/benchmarks/


One thing you may be missing is that a lot of the work usability over the past decade was not with Java itself, but rather other JVM languages.

As far as performance there is no doubt that the modern JVM is quite fast. Vert.x benchmarks are consistently on par with Actix and other low level frameworks.


While I agree Java is almost never the fastest, I'll still object it's extremely hard to meaningfully benchmark these things. It's hard to benchmark even within the same language.

There are so much hidden state in the JVM. Like are you running out of TLAB space? How aggressively has the code been optimized? Does JVM elide any object creations? It may be tempting to try to compensate for these things, to isolate the benchmark from the statefulness of the JVM, but that is also isolating the results from any sort of practical applicability because real world code exists in the context of a stateful JVM.

It's also difficult to generalize benchmarks of allocation costs alone because it's rare for code to only be allocating stuff and this isn't something anyone is optimizing for. The GC will choke if you don't give it some breathing room. You'll get resource contention that realistically wouldn't be there in real-world scenarios because real code doesn't (typically) just allocate objects for minutes on end.


> If what's needed is speed, neither Java nor C# are optimal choices

"Speed" is relative. If you mean throughput or scalability (2 different things), then the JVM or the CLR may be exactly what you want due to the ease with which one can juggle with multi-threading on multi-core processors.

Single-threaded performance is becoming less and less interesting and dealing with multithreading or with asynchronous I/O in lower-level languages, such as C/C++, is an extreme pain in the ass - because for example, C/C++ doesn't come with a memory model by itself (i.e. you can get fucked even when running with a different Glibc version) and the poster child for async I/O, libevent, has been plagued for years with concurrency issues, leading to a whole generation of insecure web servers.

The JVM, .NET and managed runtimes in general are great choices for going forward, because not only they come with memory model guarantees and a sane standard library - but having higher-level bytecode under the hood that can be generated at runtime means that either the runtime or the libraries running on top can repurpose that bytecode at runtime for optimal execution. Like for example, you could target the GPU when dealing with parallel collections.


Interesting that all the comparisons were with server frameworks. As if anybody ever cared about a few hundred megabytes of overhead on a server. Hell, even a bloated JVM implementation fits in most server L3 caches.

On the desktop, laptop, phone, or embedded environment, the JVM is heavy. It starts up slow, jars carry around ridiculous amounts of dead dependencies, garbage collectors require immense amounts of tuning, etc. And we shouldn't really expect otherwise. If you can't even keep your VM in cache, how are you supposed to have fast application code?

Specialty closed source JVM vendors have done wonders in terms of improving this problem...but it's still an uphill battle. AOT native compilation down to machine code is becoming more popular because of the proliferation of resource-constrained environments, and it will take time for new languages/compilers to take over, but take over they will.

next

Legal | privacy