By @wagslane (twitter)
Java – Brief History
In 1991, James Gosling of Sun Microsystems created Java. Sun Microsystems wrote software for many different devices. Eventually, re-compiling or restructuring code to run on various CPU architectures became too time-consuming.
Fun Fact: The founding team had a hard time thinking of a good name for their project, and while out for coffee, decided to name the language after their coffee.
Java is a general-purpose programming language that allows developers to run code on any device. It compiles code into Java-specific byte code, then the Java Virtual Machine (JVM) converts that byte code into machine compatible code. Because it compiles code in this way, Java becomes completely cross-platform. This is a major contributing factor to Java’s success.
Java rose quickly to fame and adoption mostly due to its cross-platform nature and object-oriented programming (OOP) pattern. OOP was and remains popular due to the ability to reuse code and think about entities within a program as hierarchies of types. Java is a king of the OOP design pattern. It requires that everything in the program be a class, even the main function!
- Optional semi-colon line endings
- Objects and classes but with limited encapsulation
- Single-threaded (Callback based, no concurrency)
- Not seen as competition because web development was “not serious development”
- Monopolizing browser programming, again, because other projects didn’t see browser scripting as a serious programming
Many developers considered “front-end” development to be for artists and designers. After all, “It’s just styling and templating, right?”
This was the case for a long time. However, in the last decade, front-end development has become just as serious as backend development. Single page apps, and frameworks like Angular, React, and Vue, have pushed logic that used to be controlled by the backend directly into the user’s browser.
Runtimes, Speed, and Benchmarks
Java Virtual Machine (JVM)
The JVM compiles code (.java files), into compiled classes (.class files). These class files make up a complete compiled Java program, with the requirement that one of the class files has a “main” function as an entry point. Class files are typically archived and distributed together in a .jar file. Due to this, is it easier for users to download a single executable file.
The JVM runs faster than interpreted languages like JavaScipt because it compiles code to machine code before runtime. The JVM is slower than most natively compiled languages. This is because it misses out on architecture-specific optimizations, and still has to do JVM –> CPU conversions at runtime.
NodeJS – V8 Engine
As you can see in the following benchmarks, Java fairly consistently performs better than Node in regards to memory and CPU:
Classes and OOP
In Java, everything is a class and OOP is enforced in a authoritarian manner.
Threading and Concurrency
In Java concurrency is readily available and you can read more about it here: https://howtodoinjava.com/java-concurrency-tutorial/
You can experiment and play around with these ideas here:
– How to Cache Images – React Native Expo (Managed)