4 ms·
Java high-performance programming would be significantly improved by generics over primitive types. Writing performant code in Java feels like writing Fortran o
by xmcqdpt2 3y ago
Java high-performance programming would be significantly improved by generics over primitive types. Writing performant code in Java feels like writing Fortran or C.
You end up using libraries like fastutil, which is "generic code" templated by C preprocessor macros,
https://fastutil.di.unimi.it/ https://fastutil.di.unimi.it/
- MrBuddyCasino 3y ago> Java high-performance programming would be significantly improved by generics over primitive types. This is planned as phase two of Project Valhalla [0]: The second phase will focus on generics, extending the generic type system to support instantiation with inline classes (which will include primitives), and extending the JVM to support specialized layouts. [0] https://cr.openjdk.org/~briangoetz/valhalla/sov/01-background.html https://cr.openjdk.org/~briangoetz/valhalla/sov/01-backgroun...
- xmcqdpt2 3y agoSure and I'll be happy to use it when available assuming I'm still working with JVM applications then. Meanwhile I'll still be stuck with fastutil-style templating for another ten years and it kinda sucks. (Scala has specialization and value classes and opaque types so that covers a fairly big range but they make interop with Java tricky.)
- dtech 3y agoProject Valhalla has been announced 9 years ago and nothing relevant is in the JDK yet, I don't think this will be relevant for day-to-day Java for several more years at least.
- MrBuddyCasino 3y agoProbably, but "nothing relevant is in the JDK yet" is not quite fair. Several sub-projects are in "Preview Feature" [0] status, which is defined as "a new feature of the Java language, Java Virtual Machine, or Java SE API that is fully specified, fully implemented, and yet impermanent". This includes JEP 401 "Flattened Heap Layouts for Value Objects" [1, JEP 402 "Enhanced Primitive Boxing" [2], and I think also "Value Objects" [3] and "Universal Generics" [4]. It is a huge task with many dependencies and requires careful design. It feels like it might finally make it in the next long term release. [0] https://openjdk.org/jeps/12 https://openjdk.org/jeps/12 [1] https://openjdk.org/jeps/401 https://openjdk.org/jeps/401 [2] https://openjdk.org/jeps/402 https://openjdk.org/jeps/402 [3] https://openjdk.org/jeps/8277163 https://openjdk.org/jeps/8277163 [4] https://openjdk.org/jeps/8261529 https://openjdk.org/jeps/8261529