1. History of the versions of Java
Java's history begins in 1991, when a group of Sun programmers decided to create a language for small devices: TV remote controls, coffee makers, toasters, bank cards, and so on.
Manufacturers of these devices used very different processors to control their products, so it became very important to be tied to the architecture of a particular processor or OS.
Java's creators decided to break the problem into two parts: Their programs would be compiled not into the machine code for a specific processor, but into a special intermediate code. In turn, that intermediate code would be executed by a special program called a virtual machine.
Most programmers refer to a computer as a machine.
C++ was taken as the basis for Java language and was greatly simplified and standardized. If C++ let you do something 10 ways, then Java retained only one of them. In some ways it was like the transition from hieroglyphs to an alphabet.
The first version of Java was released in 1996. Since that time, Java began its triumphant march around the world, which, in turn, stimulated the evolution and growth of the language itself. Today, millions of libraries and billions of lines of code are written in Java, and new versions of Java are released every 6 months:
|Name||Year||Number of classes|
|Java SE 6||2006||3,793|
|Java SE 7||2011||4,024|
|Java SE 8||2014||4,240|
|Java SE 9||2017||6,005|
|Java SE 10||2018||6,002|
|Java SE 11||2018||4,411|
|Java SE 12||2019||4,433|
|Java SE 13||2019||4,515|
Although versions of Java were released regularly, they did not all carry equal significance for programmers: Java has evolved in fits and starts.
2. Java 2
The first big leap forward occurred with the release of JDK 1.2. It had so many innovations there that Java's creators renamed it Java 2 Platform Standard Edition or J2SE 1.2 for short.
The main innovations were:
- The Swing library for working with graphics
- The JIT compiler, which accelerated execution of Java programs
- A huge set of collections
- Full Unicode support: Japanese, Chinese and Korean.
Today, these innovations do not seem so big, but every big project grows out of a small one. Java wouldn't be as popular today if a small group of programmers hadn't kept improving the language 20 years ago.
3. Java 5
JDK 1.5 was released in September 2004. It also introduced a lot of innovations, so it couldn't help but deserve a new name: instead of versions 1.5, 1.6, and 1.7, they decided to use 5.0, 6.0, and 7.0. So, the full name of JDK 1.5 was Java 2 Standard Edition 5.0
This update included things without which the language's further development would not have been possible.
Annotations. Half of the major modern frameworks are built on annotations, from Spring and Hibernate to JUnit.
Generics. Generics have taken the power of collections (and much more) to new heights. The code has become simpler, more compact and safer.
Autoboxing/unboxing is automatic conversion between primitive types and their wrapper types. This made it much easier to write and read code, and made collections even more popular.
foreach loop now accounts for at least half of all loops that programmers write. And, of course, it is indispensable when working with collections.
The enum is another nice new feature. It allows many things to be beautifully simplified.
These are not all the innovations: hundreds of new classes were added. The important thing is that they were just the right innovations, and gave another powerful boost to Java's popularity.
4. Java 6
Java 6 is remembered for a large number of small improvements and the abandonment of the number 2 in the name: it was no longer "Java 2 Standard Edition 6.0", but simply "Java Standard Edition 6.0".
Here are some of the interesting innovations:
The Java Compiler API made it possible to call the Java compiler directly from the code. That means your program could now generate text representing class code, compile it by calling methods of the Java Compiler API, and then immediately start calling the methods of the compiled class. There are whole areas of development where this ability greatly simplifies life.
5. Java 7
Java 7 was released in July 2011. There were supposed to be many improvements in it, but the programmers only managed to add a small part of what was planned. In particular, they added things like:
A new library for working with data input and output. Known as the New Input Output API, it is located in the
The Java compiler's automatic type inference at compile time let programmers write less code. The compiler got smarter, and that was just the beginning.
The switch statement gained the ability to use strings as case values.
Automatic resource management also improved significantly: With the
try-with-resources construct, a Java program can close data streams for you when they are no longer needed.
There were many other changes, but they are not so important at our current stage of learning Java.
6. Java 8
Java 8 came out in March 2014 and was Java's strongest recent update.
Above all, programmers remember it for its addition of lambda expressions and functional interfaces (the
@FunctionalInterface annotation). We will examine them at Level 21. Your code will never be the same again.
Streams were also added for collections, which, in combination with lambda expressions, made it possible to write code much more compactly. Although not always much more readable.
And the third big change was Java 8's introduction of a whole new API for working with dates and times — the Date Time API. We'll study it in the near future.
7. Java 9
Java 9 was released in September 2017. From that time, Java's creators have decided to release new versions more frequently — every six months. They were probably impressed by the approach adopted by the developers of the Google Chrome browser.
The Java 9 release focused more on the internals of the Java machine. The most significant thing it brought to ordinary programmers was the ability to divide a program into modules. This is very convenient when you have tens of thousands of classes or when your code dynamically unloads plugins.
But it will probably be of little use to us in the near future.
8. Java 11
Six months after the release of Java 9, Java 10 came out, and another six months later, Java 11 came out.
A lot of small improvements were made during this time, but you will mostly likely remember only two:
It added support for Unicode 10. Now you can use emojis in your Java programs. You can work with them in the same way that you work with the boolean type:
Type inference was improved, and the
var keyword, which you are sure to like, appeared.
Now you can write the following:
var str = "Hello";
And the compiler converts this to:
String str = "Hello";
But there were also some losses. Java's creators dropped libraries such as JavaFX, Java EE, and CORBA from JDK 11.
9. Importance of compatibility
When a new version is released, programmers quite often want to start from scratch. After all, who wants to fix a bunch of old bugs when they are absolutely positive how the code should have been written from the very beginning?
But history doesn't support such an approach. Every time programmers release a new version of a program, 90% of its users are using an old version. They can use or ignore the program's new features, but what users hate is when something that used to work well stops working.
Many great products have died when programmers released new versions that were not compatible. Or simply when they made major changes. For example, the idea of abandoning the Start button in Windows 8 did not appeal to users. The release of Windows 10 brought back half of what was removed in Window 8.
What's more, Windows lets you run programs written 20 years ago for Windows 95 or even written 30 years ago for MS DOS 3.0 — they will work. This is one of the reasons why Windows remains popular.
And Java wouldn't be as popular as it is if its developers didn't care about compatibility. Any time there is a new version of the Java machine, a new version of the SDK, or major changes to classes, all the Java code written since January 1996 continues to work.
This is usually achieved by only adding new methods, classes, and packages, without removing anything. This approach has its pros and cons.
On the one hand, Java drags around a bunch of baggage in the form of old, suboptimal, and unnecessary code. On the other hand, your project written in Java 11 can always use a library written in Java 8 that uses libraries written in Java 5 and Java 2. This hodgepodge of code will work just fine.
With the C++ language, libraries compiled for both 32-bit and 64-bit platforms cannot be used in the same project. And you'll have a huge headache if you suddenly discover that the
char type used in one library uses one byte, while another uses two bytes.
So, Java's creators decided not to remove anything, but only to add new classes and packages. But how do they let programmers know that there is a new worthy alternative to an existing suboptimal solution?
To do this, they came up with the
If some method or class is deprecated, this annotation is added next to its declaration. It means that programmers are discouraged from using the code.
You can still use a deprecated class or method, but it is not recommended.
And how often do people do things that are not recommended? Almost always 🙂
Many classes have been deprecated for 20 years — they have been used and are still being used. People are familiar with them or they are just convenient. But there is a risk that they will be removed at some point, so it is better not to use them.
All modern IDEs, including IntelliJ IDEA, can handle the
@Deprecated annotation. The names of deprecated classes and methods are displayed using
strikethrough formatting. Something like this:
Date date = new Date(); int day = date.
Deprecated classes are very popular and often found in code, so we will look at some of them soon.
GO TO FULL VERSION