Java turned 28 this week! Here are my 28 favourite features/APIs in it.
What are your favourite features/APIs comment below?
Sharat Chander π§@sharat_chanderβοΈβοΈπππ₯³π₯³ππβοΈβοΈ
Happy Birthday, #Java! 28 amazing years!
What's your favorite Java memory or photo? Post now and use the #28YearsOfJava hashtag!
Stay connected: dev.java
βοΈβοΈπππ₯³π₯³ππβοΈβοΈ15:38 PM - 23 May 2023
1. Collections
Java 2 introduced the collections framework.
"The collections framework is a unified architecture for representing and manipulating collections... It reduces programming effort while increasing performance"
P.S. Oh yeah! I used generics \o/
2. Non-Blocking Input Output (NIO)
Java 4 introduced NIO (New Input/Output) API. They were high level abstraction APIs designed to provide efficient operations on the low-level I/O operations. Later on Java 7 extended these non-blocking I/O for filesystem access.
3. Generics
Java 5 came with Generics. Hate it or love it. IMHO this is one of the key features to be released at that time. It reduced bugs and added an extra layer of abstraction over types.
4. Annotations
Annotation was another feature Java 5 came with.
"Annotations, a form of metadata, provide data about a program that is not part of the program itself. Annotations have no direct effect on the operation of the code they annotate."
5. Varargs...
Java 5 also introduced Varargs. They provided a short-hand for methods that support an arbitrary number of parameters of one type.
SafeVarargs & Variable arguments in Java | by sendilkumarn | Medium
sendilkumarn γ» γ»
sendilkumarn.Medium
6. Concurrency
Java 5 also improved concurrency.
"APIs under java.util.concurrency, these APIs have been designed to support concurrent programming, and all execution takes place in the context of threads"
7. Enhanced For-Each Loop
I loved this enhanced for-each loop when it was released. It was easy and who cares about the index when all you need is the value.
8. Garbage Collection Improvements
Java 6 is all about performance there were huge performance improvements for the core platform and even on Swing. It is in Java 6 we saw a few new GC algorithms too.
9. TimSort
Java 7 replaced MergeSort[1] to TimSort[2] for the Collections and Arrays sorting π
10. Lambda
Java 8 is an amazing release. Project Lambda is the pinnacle of this release.
11. <Optional>
Java 8 introduced Optional to prevent us from NPE.
"A container object which may or may not contain a non-null value. If a value is present, isPresent() will return true and get() will return the value."
12. Functional Interface
Lambda's are amazing and they organically lead to Functional interfaces.
"A functional interface in Java is an interface that contains only a single abstract (unimplemented) method."
13. JShell
Java 9 brought in JShell.
"JShell is a REPL tool, which evaluates declarations, statements, and expressions as they are entered and immediately shows the results. The tool is run from the command line."
14. Modules
Remember Zigsaw from Java 9.
"The Java Platform Module System specifies a distribution format for collections of Java code and associated resources"
15. Vars
Java 10 released with much awaited Local Variable Type inference a.k.a "var". The verbose Java becomes inferred Java.
16. Faster Release cycles
Major release every 6 months. Reduced the release cycle duration. No long wait for newer version and features.
17. Flight Recorder
Java 11 came with Flight Recorder, which provided a low-overhead data collection framework for troubleshooting Java applications and the HotSpot JVM.
18. Single File Source
Java 11 allowed us to launch single file Java programs via Java command.
Java HelloWorld.java
19. RIP Applets
Java 11 bid farewell to Java Applets / Java Web Start / JavaFX and others.
20. Switch Expressions
Java 12 came with switch expressions
21. GC - Shenandoah
Java 12 also introduced a new GC algorithm named Shenandoah. This amazing algorithm provided consistent pause time irrespective of your heap size.
22. Text Blocks
Java 13 came with Text Blocks. Multi-line texts made easy.
23. Pattern Matching
Java 14 launched with Pattern Matching for instanceof
JEP 305, Pattern Matching for instanceof simplifies the common case of an instanceof test being immediately followed by cast (see the code snippet)
24. Records
Java 14 also launched with Records.
Records allows easy creation of simple immutable Tuple-like classes.
25. Sealed Classes
Java 15 introduced sealed classes.
My blog post that talks about sealed classes and interfaces - https://sendilkumarn.com/blog/java-17
26. Vector API/SIMD
Java 16 came with Vector API.
"Single instruction, multiple data (SIMD)"
27. Virtual Threads
Jumping to Java21, it finalized and introduced virtual threads to the java platform.
"Virtual threads are lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications."
28. Community
Last but not least! The amazing community of #java β€οΈ
What are your favorite features of #java comment below?
@java turns 28 today!
twitter.com/Sharat_Chanderβ¦
Here is a thread on my favorite Java features/APIs/releases π§΅21:44 PM - 23 May 2023Sharat Chander π§ @Sharat_ChanderβοΈβοΈπππ₯³π₯³ππβοΈβοΈ Happy Birthday, #Java! 28 amazing years! What's your favorite Java memory or photo? Post now and use the #28YearsOfJava hashtag! Stay connected: https://t.co/7WRXM7EvX8 βοΈβοΈπππ₯³π₯³ππβοΈβοΈ https://t.co/jj3AM0yKbT
Top comments (4)
For some strange reason, sealed classes are considered a funny way to enabled/disable inheritance. But the ability of sealed classes to restrict inheritance is a secondary feature. The main purpose of sealed classes is the creation of the sum types. Before sealed classes, the only way to create sum types in Java was to use enums. But they have limitations (for example, each type has exactly one immutable instance, enums canβt be generic, etc.). Sealed classes fill this gap. And only here the ability to limit inheritance gets really useful. For example, now one can implement
Optional<T>
as a sealed interface which has exactly two implementations -Some<T>
andNone<T>
and the whole implementation is protected from extension and/or inheritance, hence protected from incorrect or malicious use. An example of such an implementation can be found hereAnother advantage of such an implementation is that it is suitable for pattern matching:
I agree! I have mentioned that in the blog post itself.
"Both Record and Sealed classes are algebraic data types (ADT). ADTs are a fancy way of saying composite types (the type formed by combining other types). Record classes are product types. Sealed classes are sum types.
Being sum type, the Sealed classes make it easy for the compiler to understand its various type forms."
Two notable ones are: (1) Language feature improvements in Java 7, like the try-with-resources and exception handling (e.g., multi-catch) made the coding simpler. (2) Importantly, the Java 8's Streams (and its integration with collections, file i/o, etc., ) and the new date and time APIs.
Oh yeah! Try With Resources is another one!