Hacker News new | ask | show | jobs
by jjjeii3 1937 days ago
Why are desktop Java apps are always so slow? Applications written in other languages (C#, C++, etc.) are much much faster. Even VS Code, written in JavaScript is faster... I tried hundreds of applications and this was always the case and not just with certain applications.
3 comments

It's not really Java as a programming langage, you can have light and fast Java code, nor the JVM, it's a pretty fast virtual machine that is just very memory hungry by default. In my opinion it's the community and the philosophy around Java. It's usually a bit over engineered and performances are not taken into account very often. Take eclipse as an example, from a software design point of view it's great and a very advanced. You can for example play with the eclipse modeling framework and it's in another league compared to VS code plug-ins.

However the end user doesn't really care about the beauty of the Eclipse meta meta model and think more about why it takes so long to start or why it uses to much memory compared to notepad++.

Also while Vscode is written in typescript/javascript, it uses V8 for the javascript VM which is very fast.

Web Browsers are built on multithreaded rendering - Paint, Layout and Main threads. It works really well, but on legacy or native everything is done on the single main thread and everything is jammed into 16ms of a single thread.

For example why iOS is so fast? It renders everything in separate process. (This is why Flutter will always be a garbage by reimplementing this in main thread).

I bet it just too much and too old to rewrite to new shiny things.

My best analogy for this is to think of Java as like a truck and other languages as like vans (C++) or motor scooters (python, etc). Past a critical threshold Java has absolutely amazing performance (sits in same league as C/C++) but if you imagine driving a large truck around town ... you are constantly starting and stopping, turning into alley ways etc - a truck is not going to do too well. But if you actually have to deliver 50 tons of goods, good luck on the scooter. And a well designed Java app can behave like a scooter but its not the default setting because most people in enterprise settings have truck-like problems.

However the slowness of Java on the desktop is a bit overblown by people's past experience I think .... improvements to garbage collection and hotspot optimisation, and elimination of applets have certainly made a big difference to the type of stalls that used to make people say these things.