Table of Contents
- 1 The origin stories: where it all began
- 2 Interpreted vs. compiled: what’s the difference?
- 3 Data types: checking explained
- 4 A few myths to bust
- 5 Class-based or prototype-based programming?
- 7 Where and when to use both
- 8 The popularity contest
- 9 The final dots on the i’s
The origin stories: where it all began
The project for Java started in 1991 and was originally called Oak. However, this name was already registered for another company, so the creators replaced it with Java (as in coffee, consumed by them in great amounts) and released the first version in 1995. It got popular rather quickly, as it was based on C-style syntax which a lot of developers were already familiar with, plus, it promised the WORA (Write Once, Run Anywhere) principle.
Interpreted vs. compiled: what’s the difference?
As you write Java code in an Integrated Development Environment (also known as IDE), it gets compiled into bytecode. A human cannot read it, but a machine can, hence, a Java Virtual Machine (JVM) will be able to run it easily. The before-mentioned WORA principle actually relates to this as well: using a compiled language means making changes is basically rebuilding the program. Needless to say, this can be a complicated process and require using special software. Thankfully, Java code is compiled first and run later, so you can see the structural issues at once.
Data types: checking explained
Java, on the other hand, takes the road less traveled and uses static checking. This means the data types will be verified during compilation, and you will be able to catch most type errors earlier. If the compiler is aware of the data types you used, the code usually runs faster and eats up fewer resources.
A few myths to bust
You might think that static type checking is something that occurs in compiled languages, and dynamic checking works in interpreted ones. In most cases, it is indeed true, but here’s the thing: while a language can use static or dynamic type checking, a language implementation can be compiled or interpreted. This means that while Java is usually compiled, there could technically be an implementation that will be interpreted. However, it will still use static type checking.
Class-based or prototype-based programming?
Can you run Java in the browser? Yes and no. If you have used the world wide web for more than a few years, you might remember the time when you had to download and install a Java browser plugin to see any interactive or dynamic elements. Those were called Java applets and used somewhat widely. However, they are virtually extinct by now. As HTML5 provided a chance to embed media to your webpage directly, there was no need for potentially insecure third-party applets. Therefore, Java falls short among the browser users now.
Where and when to use both
As a language of general purpose, Java has a slight edge here. It should be your first choice if you’re looking into creating enterprise software and applications for Android systems. It is rather popular in the financial and trading sectors, as well as big data and scientific applications. For example, systems for natural language processing are often written in Java. The WORA principle also makes it perfect for embedded systems, such as Java cards used in SIM cards.
The popularity contest
What makes Java so popular? Well, first of all, it’s the fact the Java Virtual Machine is extremely cross-platform. The ability to use Java on each operating system and its portability is a huge plus to a developer. It is also backwards compatible, which eliminates the issues that may come with system updates. Last but not least, the long-lasting popularity of the language has also resulted in a huge user community, which simplifies learning it from scratch nowadays and offers massive support when issues arise.
The final dots on the i’s