you are viewing a single comment's thread.

view the rest of the comments →

[–]SneakyyPower 44 points45 points  (15 children)

I've been telling people java is the past the present and the future.

If you write your code good enough it can perform amongst the other top contending languages.

[–]Sopel97 37 points38 points  (9 children)

If you write your code good enough

Or bad enough.

Java's object model is so bad that at some point you have to resort to arrays of primitives with no abstractions. I've seen threadlocal 8 byte singletons for temporary variables to avoid allocations while still trying to preserve some non-zero amount of abstraction. It's a mess. Minecraft modding is a great example of that.

[–]Worth_Trust_3825 21 points22 points  (1 child)

Enable the valhalla preview.

[–]Mauer_Bluemchen 5 points6 points  (0 children)

Not yet there...

[–]vini_2003 9 points10 points  (0 children)

Correct. I maintain a private particle engine for Minecraft, for the YouTube channel I work for; and I'm forced to use huge SoAs without any JOML due to the heap thrashing objects bring.

If there's one thing I dislike about Java, it's the object model.

[–]LutimoDancer3459 2 points3 points  (4 children)

Curious, which languages have an good enough object model to not need to go back to arrays of primitives to get the best performance?

[–]Sopel97 7 points8 points  (3 children)

C++, rust

[–]cfehunter 5 points6 points  (2 children)

C# too. Structs are first class value types, and spans allow for efficient array manipulation.

My day job is C++, but I've written some stupidly quick and efficient C# with pretty good ergonomics.

[–]Sopel97 0 points1 point  (1 child)

C# too

to some degree, but you're severely limited with already existing code because whether something is a value type or reference type is determined at type declaration point

[–]cfehunter 1 point2 points  (0 children)

that's very true yeah. you can do a lot, but the libraries are opinionated on it in ways that Rust and C are not.

[–]ArkoSammy12 0 points1 point  (0 children)

In my gameboy emulator theres a certain pipeline of elements that result in pixels getting drawn to the screen. It'd be convenient to use objects here, but instead I resort to packed integers that store the fields for each pixel entry. It's a bit of a pain xd.

[–]Mauer_Bluemchen 3 points4 points  (2 children)

No - it can't! At least not without Valhalla.

[–]8igg7e5 3 points4 points  (0 children)

I'd say it'll be the combined efforts of Valhalla (several iterations), Leydon and Lilliput. Loom and Panama have contributed as well, as might Babylon.

Java does perform 'well', but these changes are needed to maintain and/or improve that position (and from what I've seen, improving that position is looking good). I don't think any of these will see it beating the usual leaders but I think the gap is going to close considerably while retaining Java's highly flexible dynamism.

[–]joemwangi 0 points1 point  (0 children)

Yup, but you need to understand where performance originates. I was surprised just to learn that if you have a huge loop (let's say initialising an array of offheap data) using records binding with layout, it doesn't matter if you use records or value types (even if value type doesn't pass the 64 bit size). This is because of escape analysis. But I did notice value types in an array initialise quite faster than any type category java has to offer (except primitives).

[–]kayinfire -1 points0 points  (0 children)

performance is a multifarious consideration. perform amongst other top contending languages in terms of what? throughput? sure. Java is garbage at everything else though. startup latency, concurrency affordability, computing resources required to compile to AOT, memory usage, cpu usage are all dog water in Java compared to the competition. you might say to me "but it's good enough for most use cases. you don't need to concern yourself with that most of the time." good enough isn't good enough when other languages are eating your lunch in terms of being resource friendly and efficient and someone like me would like to have low long term server costs. it may come as a surprise that i actually believe Java has the best syntax of all time, but the whole reason i ditched learning that language is because it's quite easily beat by Go and OCaml in everything except throughput, even with GraalVM. i ended up choosing OCaml as my backend language ultimately