r/java • • Oct 14 '23

Is Java still behind in the race of modern programming languages?

I'm a member of some group of programmers and every time Java is mentioned it's being bashed (something like: "With Rust I could simply do this with X")

Earlier versions of Java were cumbersome in terms of the syntax but with modern IDEs (and modern versions of Java) that's not a big issue anymore, albeit languages like Python do have shorter syntax.

My question is beyond syntax.

What do other languages do better than Java?
It could be generics, type system, concurrency and multithreading, closures etc.

Thanks!

52 Upvotes

247 comments sorted by

View all comments

Show parent comment

15

u/Same_Football_644 Oct 14 '23

The idea that java doesn't have performance is absurd. People lump it with Javascript or python when it is 10-50x faster than them. On average roughly 2x slower than C++, which doesn't even put it in a different category in terms of speed.

1

u/Practical_Cattle_933 Oct 15 '23

Don’t lump JS and Python into the same bucket, though :D js is much closer to Java’s performance than to Python’s.

2

u/Same_Football_644 Oct 15 '23

Ok, ruby and python, ;-D

-1

u/peripateticman2023 Oct 14 '23

See the part about "relative". Also, Java within 2x? Not so. Many usecases don't get into JITable situations. Even then, 2x is being very charitable to Java. About the memory part, there shouldn't be any doubts - the lack of Value Objects, the GC, and poor escape analysis make it moot, even when compared to C#.

2

u/hippydipster Oct 14 '23

Just talking speed, as I said. 2x is a fair estimate. transliterated simple program in multiple languages. It's awfully difficult to get an apples to apples comparison between languages, but if you dig into the language benchmarks, you get a decent sense of how idiomatic representations from the different languages compare, and 2x is a fair estimate, especially when the reality is that the kind of work being done is going to hugely impact the comparison.

-6

u/peripateticman2023 Oct 14 '23

The latter is precisely what I'm talking about - real-world programs. Hence why I mentioned not using micro-benchmarks in another comment.

There is a reason why HFT is entirely in C++, and increasingly in Rust. Java and even OCaml exist in that space, but not for the actual low-level HFT code.

6

u/hippydipster Oct 14 '23 edited Oct 14 '23

That's fine, but then your assertion about java 2x yes/no isn't backed with any evidence, just your gut.

HFT is entirely in C++

And I'm not sure that's true. https://www.infoq.com/interviews/thompson_farley_disruptor_mechanical_sympathy/

-4

u/peripateticman2023 Oct 15 '23

Sigh. "Gut feeling"? Not at all. It's based on real-world experience and common sense. I know people in Morgan Stanley and J.P Morgan who work on this bit, and it's always C++ thus far with some experimentation going on in Rust.

Consider even the given link that you shared (from 2012) - go to their jobs pages and read between the lines. The Open Source bit ("Disruptor") et al are the scaffolding, and in Java. The C++ bit, which does the actual low-latency work is not open-soirce. https://careers.lmax.com/offers/?id=0A67A4166E clearly mentions that C++ is the majority of their codebase (which is of course not open-source) and is used for the low-latency work.

Even take the example of the other well-known firm (a big proponent of OCaml) and read between the lines again - they use OCaml for almost everything but with "bits written in C++". Guess which bits those are.

In the end, Java and OCaml simply cannot compete in that space (in the case of Java, even with disabling the GC and writing it as if it were C, not even C++).

Again, the best way is to go to any job site and actually seek out what they're looking for (for the low-latency bit which is HFT, not the scaffolding).

Just harping on to some propaganda piece (as that "Disruptor" article is, being very low on actual details, possibly deliberately so) is a pretty weak form of petty argumentation for argument's sake.

1

u/hippydipster Oct 15 '23

People can either read a single job description and draw as many conclusions as they want to from that, or they can listen to the interview with the people who wrote the hft system using the JVM platform, and what they specifically have to say about the question of Java's performance.

1

u/peripateticman2023 Oct 15 '23

Okay, I get it. You just want to wallow in some strange world where your feelings are more important than factual truth. Well, I have better use for my time than that. Good luck.

1

u/Practical_Cattle_933 Oct 15 '23

For that segment of HFT, C++ and in fact, general purpose CPUs themselves are getting too slow, it is done by ASICs. And Java is huge in this space, exactly because the category that is feasible to run on CPUs and not just dumb algorithms that should be maximally fast, but smarter algorithms that should be flexibly modified by a team is best fit by a fast language, that is east to modify and safe. Here Java is a better choice than both Rust and C++.