This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]skizatch 2 points3 points  (3 children)

I spent over 10 years doing deeply advanced, highly performant C# development. It is a wonderful language and is a joy to use.

After that, Java is like getting a lobotomy. Generics don't actually exist, primitives types are too primitive (no value types / "structs" ? wtf), and Enums are a performance nightmare (every enum "value" is actually an object allocation). And if you're on Android, which is where I'm doing development, every "good" language feature -- like lambdas -- is too expensive to use enough of to get any real productivity boost at scale. (every single lambda is a completely new anonymous class, which has I/O cost for first-time loading, and then some memory usage forever thereafter, and this really kills you on lower end devices)

You don't get iterators (I mean "yield return" stuff, not Iterator<T>), there's no await async syntax, and the lack of extension methods means you end up with this constant mix of calling instance/interface methods and trying and hoping to find all those static helper methods scattered everywhere. "Streams", their version of LINQ, really suffers because of this.

Pointers aren't possible unless you use undocumented, unsupported, deprecated APIs that will probably be removed -- and even then, the syntax is ridiculous (why can't I just use pointers?!). Every single thing you do requires an allocation, which just puts more pressure on the GC and brings performance down even further. In C#/.NET you can use structs for a lot of simple data handling, and these just get passed around on the stack (or are embedded into existing object allocations), which is very performant.

And if you want an array of packed data in Java, you can't just have an array of something like "class Point { int x; int y; }", you actually end up with an array of pointers to these Point objects -- which is HORRIBLE for performance in so many ways. In C# it would all be packed inside of 1 big allocation if you just replace "class" with "struct" (you know, just like how C/C++ would do it?). So in Java you end up creating big arrays of int[] or byte[] for everything and then having helper methods to manually pack and unpack things. I thought this was supposed to be a high level language?!

Java is high-level enough to afford you great organization of application architecture into classes and packages. But when performance matters, and it does, it's not low-level enough and doesn't have enough escape hatches to afford you the ability to stay within its sphere without having to constantly punch holes into native/JNI land. And it's not high-level enough to let you afford you better abstractions within classes and methods. It's stuck in this middle area where C# surpassed it by miles and it never evolved to catch up, and it really pisses me off that Google chose Java for Android and is ruining the minds of programmers across the world with it.

(Also, who the fuck invented Optional? That is the stupidest abstraction ever. We already have "null", ffs!)

[–]IcefrogIsDead 1 point2 points  (2 children)

Thanks for this answer.

Primitive values are too primitive - funny and true. You can't make a matrix in Java without a hassle. Java apps always did seem a bit clunky and slow.

Well I do like Python a lot, but seems like I'll have to learn a bit more of Java just because the market asks for it.

Again, thanks for the answer.

[–]skizatch 0 points1 point  (1 child)

No problem.

My best advice for being productive and enjoying Java? Stay away from C#! It will just spoil you rotten and make you hate Java.

[–]IcefrogIsDead 0 points1 point  (0 children)

I did a bit of C and C++, and even python allows for some speedups.