By @wagslane (twitter)
Java – Brief History
Java was created in 1991 by James Gosling of Sun Microsystems. Sun Microsystems wrote software for many different devices, and re-compiling or restructuring code to run on various CPU architectures became 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. Code is compiled into Java-specific byte code, then the Java Virtual Machine (JVM) converts that byte code into machine compatible code. When code is compiled in this way, Java becomes completely cross-platform, which 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, and 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, but 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, which makes it easier for users to download a single executable file.
The JVM runs faster than interpreted languages like JavaScipt because code is compiled to machine code before runtime. The JVM is slower than most natively compiled languages 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 fascistic 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:
Thanks For Reading
Lane on Twitter: @wagslane
Lane on Dev.to: wagslane
Download Qvault: https://qvault.io