Why Do We Have To Compile Java?
Some developers vomit when they realise Java code has to be compiled.
Other languages like JavaScript avoid this pain, so why Java?
Back in 1991, a crazy clever guy called James Gosling was trying to figure out the best way to run software on consumer electronic devices. Ideally without rewriting or recompiling the code for each type of device.
You guessed it. What he came up with was Java.
You compiled the source code into bytecode, which could then be run on any device with a Java Virtual Machine.
Write once, run anywhere (that has a JVM).
Catchy, huh?
All the Java developers I know use it to write web applications, mainly APIs. These are normally packaged up in a Docker image, which is another write once, run anywhere technology.
This raises the question of why we still use a compiled language to write these types of applications.
Whether a language is compiled or not doesn’t matter when it’s running inside a pre-built Docker image.
I suspect it’s because some of us are comfortable using Java and love its statically typed predictable nature compared to other modern languages.
What do you think?