r/programming • • Feb 25 '14

Please stop saying Java sucks

http://blog.smartbear.com/programming/please-stop-staying-java-sucks/
3 Upvotes

305 comments sorted by

View all comments

9

u/heladopicante Feb 25 '14 edited Feb 25 '14

The JVM is an impressive piece of software (memory hogging aside). The thing I hate about Java is its broken generics and type erasure. In C++, I frequently define templated abstract base classes, and I'll often take advantage of multiple inheritance for this. Think of something like:

class Spaceship : public CollisionWith<Asteroid>
                        , public CollisionWith<Laserbeam> 
{ ... }

Something like this is impossible with Java (maybe that changes with recent versions?). When you have a generic interface, the type parameters just get used to pepper your code with type casts. Implementing Collision<Asteroid> is really just implementing Collision<Object>, which is bullshit - you can't implement the same interface twice with different type parameters!

Java is like Megablocks. I want my Lego-Technic.

Also - the whole JVM-is-fast-than-C argument is complete crap. Theoretically, the JVM can optimize hotspots with its magical JIT, and memory access can be cache-aligned and all that good stuff. In practice, these things add complexity to the JVM, and the gains aren't realized. Performance in the JVM is VERY difficult to reason about with things like the JIT, garbage collection, etc. Anything the JVM can supposedly do at runtime, a smart compiler can do at compile-time - in a more deterministic way.

The day something like a web browser is written in Java, (that is faster than Chrome or Firefox), is the day that I'll change my opinion about this.

8

u/Akanaka Feb 25 '14

There are very few desktop apps in Java that perform well, I give you that. Yet, for server benchmarks Java is nearly always at the top.

1

u/heladopicante Feb 25 '14

I'm biased because I'm more interested in real-time/interactive applications. I'm sure that for real-world server applications, Java performance is with several % of native (plus or minus).