r/java • • Jul 30 '21

What is the future of Java?

I'm not asking like is java going to die or will Java be relevant in future. I'm just curious to know about the future of java. What are the upcoming things coming in java that can change the future of it.

173 Upvotes

123 comments sorted by

View all comments

258

u/kartik1712 Jul 30 '21 edited Jul 30 '21

Java will stay relevant in the forseeable future. Lots of awesome work is going on under various OpenJDK projects to improve Java.

Project Loom is working on making it easier to leverage concurrency through virtual threads etc. This will make writing server side applications which are already a Java stronghold easier.

Project Valhalla is working on bringing value based classes (aka user defined primitives) to Java and the JVM.

Project Panama is working on making interop with native libraries and memories simpler. It will also introduce the Vector API to help developers leverage SIMD.

Together, Valhalla and Panama will make Java even more relevant for big data, machine learning and artificial intelligence.

Project Amber is working on bringing new language features (prominently pattern matching) to Java,

There are also ongoing projects like Lilliput which aim to improve the JVM and as a result as languages running on the JVM.

Recently, projects have been also proposed to support Wayland graphics in Java and improving startup times using CRIU and related technologies (Project CRaC).

All in all, the future of Java is exciting and awesome!

32

u/SKiisM_ Jul 30 '21

You forgot to mention GraalVM 20.2 that just came out. In general GraalVM is waaay faster than OpenJDK and slowly making its way to more and more enterprise production projects. Also JDK 17 LTS is coming out mid September with a few cool features but nothing too significant (in my small brain opinion)

7

u/oweiler Jul 30 '21

GraalVM is faster for certain workloads (esp. short running apps, like Lambda functions and CLI apps) but slower for others (basically everything long running, because there's no JIT compiler at runtime (yet)). And GraalVM has a bunch of limitations, esp. when you're not using a framework like Quarkus and Micronaut.

7

u/GavinRayDev Jul 30 '21

but slower for others
(basically everything long running, because there's no JIT compiler at runtime (yet)).

I'm not sure I follow. Graal has multiple modes of execution, and none of them lack a JIT compiler as far as I understand 🤔

Building the GraalVM compiler as described above means it is executed in the same way as any other Java code in the VM; it allocates in the HotSpot heap and it starts execution in the interpreter with hot parts being subsequently JIT compiled. The advantage of this mode is that it can be debugged with a Java debugger.

However, it has some disadvantages. Firstly, since it uses the object heap, it can reduce application object locality and increase GC pause times. Additionally, it can complicate fine tuning options such as -Xmx and -Xms which now need to take the heap usage of the compiler into account. Secondly, the compiler will initially be executed in the interpreter and only get faster over time as its hot methods are JIT compiled. This is mitigated to some degree by forcing the GraalVM compiler to only be compiled by C1 (i.e., -Dgraal.CompileGraalWithC1Only=true) but this comes at the cost of slower compilation speed.

To address these issues, the GraalVM compiler can be deployed as a native shared library. The shared library is a native image produced using SubstrateVM. In this mode, the GraalVM compiler uses memory separate from the HotSpot heap and it runs compiled from the start. That is, it has execution properties similar to other native HotSpot compilers such as C1 and C2.

5

u/oweiler Jul 31 '21

Sorry I've only had native images in mind. I've totally forgotten that GraalVM is also a drop-in replacement for Hotspot.