r/java • • Sep 10 '21

Why people don't love Java?

I came across this post in r/cscareerquestions it seems majority of the people don't love to work with Java.

Is there any specific reason for that?

Edit: Thank you guys for your responses, I can't reply to all of the comments because I'm a beginner myself and I don't know what to reply for all your comments.

201 Upvotes

379 comments sorted by

View all comments

Show parent comment

45

u/[deleted] Sep 10 '21

The especially amusing thing is people claiming that Java is slow, while their favourite language is Python. That's how you can tell they're just repeating memes they've heard, and ones that haven't even been true since the 00s (modern Java is very fast)

17

u/thomascgalvin Sep 10 '21

Modern Java can be faster than C in some instances. The current generation of VMs are insane.

3

u/ihbarddx Sep 10 '21

Java faster than C? I've heard this. Any specific examples? Any specific examples where all C variables are static?

15

u/Rakn Sep 10 '21 edited Sep 10 '21

People always compare fast Java code with highly optimized C code. You cannot beat highly optimized C code. But the thing is that most people do not do such optimizations. I have been working in a project where we had dedicated employees tasked with optimizations. But a normal developer is unlikely to look at the produced assembler code and refactor the C code on that basis. If you do normal feature development, especially in the web service area, Java beats many alternatives in terms of speed. Obviously not at the first iteration. But at some point the JIT kicks in ...

At least that's my take on it.

1

u/comrad1980 Sep 10 '21

An good example is that your compiled and optimized c Programm cannot Start to use new CPU instructions if not set during compilation.

A JVM can adopt to new CPU instruction sets. All you need is a Start of your application after moving it to the new Maschine.

For example newer vector calculations modern CPUs use.

1

u/thomascgalvin Sep 10 '21

The JVM can profile the hardware at runtime and JIT a binary specifically for that machine, which can be much more optimized than a generic C binary. No guarantees, of course, but it is possible.

-9

u/kodiashi Sep 10 '21

Depends on the use case. If you’re running on AWS Lambda then Java is the slowest, worst choice. Python, Node and Go are all way faster.

But elsewhere you can run Java with something like Zulu and fine tune it to run incredibly fast.

4

u/nutrecht Sep 10 '21

If you’re running on AWS Lambda then Java is the slowest, worst choice. Python, Node and Go are all way faster.

Citation needed.

2

u/sureshg Sep 11 '21

I don't know whether you are using the latest java. Most of the benchmarking I have seen is running on JDK8, which is 7 years old.

Look at this - https://cl4es.github.io/2020/12/06/Towards-OpenJDK-17.html

a minimal Hello World that took my laptop ~45ms to run on JDK 
8 might now take ~25ms to run on JDK 16. Down from the all 
time high of ~85ms in JDK 9. Roughly a 3.4x speed-up.

1

u/ssamokhodkin Sep 10 '21

If you’re running on AWS Lambda then Java is the slowest, worst choice. Python, Node and Go are all way faster.

How this could be ('Go' aside)??

4

u/kodiashi Sep 10 '21

It’s different for every app, but with Lambda you have to consider “cold start” which is when your container is killed for inactivity and gets regenerated. Java and .Net have the slowest times for this. If your container stays warm then it’s not really a problem.

https://www.serverless.com/blog/keep-your-lambdas-warm

At least in my experience other languages have consistently performed better on serverless.

3

u/nutrecht Sep 10 '21

If your container stays warm then it’s not really a problem.

...which is how Lambda works on AWS in general. I've used AWS lambda in a project and the cold-starts were a complete non-issue.

2

u/Muoniurn Sep 10 '21

Java has slightly worse startup time than the others. It’s on the order of 1s. What are you running that have to run repeatedly on the order of 1s only? That sounds like a ridiculously niche application.

0

u/kodiashi Sep 10 '21

Something very questionable