Java
In the previous post we were testing if Java’s Virtual Threads aren’t used in a way that makes them pinned. It’s because we want our Platform Threads (especially those in the ForkJoin Pool Co.) to keep carrying more and more new Virtual Threads, instead of keeping the engine running while VTs are pinned. (At least as long as we can’t provide our own thread pools to carry VTs.)
Spoiler alert: we’re going to use Testcontainers and Toxiproxy today!
How to enable Virtual Threads? During my talks about Java 19 (which have the mandatory part dedicated to Virtual Threads), I’ve been asked: how do I enable Virtual Threads in the JVM? quite a few times.
This question carries an assumption that there’s some kind of switch, which has to be activated or hit to “magically” turn good ol' Threads into Virtual Threads. AFAICT there is no such thing right now, and I rather doubt there will be one in the future.
When I have time to talk about Java for more than one hour, it’s a Deep Dive (I call it “What’s new and noteworthy?") When I have less than forty minutes, we can barely touch the surface, hence it’s called then “Surfing Modern Java”. Anything in between, like regular-size talk, is more than surfing, but less than deep dive, hence “Sailing Modern Java”.
For such a talk I usually cover one or two latest releases, sometimes mentioning what’s ahead of us, trying to sneak in as many code demos as I can.
Let’s be honest: we’ve been waiting for the Virtual Threads quite some time. We’ve been waiting eagerly, we’ve seen names changing (they’re not fibers folks), but here there finally are: Virtual Threads.
Some say the Project Loom is the biggest change Java has seen since version 8, lambdas, and streams. Some say it’s even bigger than that. Discussion aside, they are a huge change, it seems.
I remember how we were excited (I was still at the university back then), that we could finally use some real Threads in Java on Windows.
Hey, there are two major Java versions released every year! We don’t have to wait 3 years or so for new features anymore. Isn’t that cool? 😉
Java was supposed “to be slow”. However, Java turns out to evolve so fast, that next releases aren’t just version bumps, but might significantly change the rules of the game. That’s a good reason to check out what’s new in Java.
To name a few changes:
“You can never understand one language until you understand at least two.” – Geoffrey Willans
For years, I’ve been developing mostly in JVM languages. Sometimes in other C-derived languages, which was both cool and easy.
A few months ago (due to a career shift) I had to learn Go rapidly. While technically Go has keywords looking similar to C, many things are simply different and even unheard of in C-based OOP languages.
Modern Java is really awesome when it comes to “Hello, World!” demos. It’s also cool for a sophisticated systems and algorithms, provided their authors write code which obeys a few fairly simple contracts and avoids obvious traps.
There are a few mantras regarding recent features of modern Java, such as:
records can replace JavaBeans everywhere you never need to write hashCode() for records pattern matching with instanceof is the best tool for equals() just ignore --illegal-access and set it to permit synchronize (new Long(42)) is the best for monitoring and so on.
Another (half a) year has passed, another major Java™ version has been released. Java was supposed “to be slow”. However, Java turns out to evolve so fast, that next releases aren’t just version bumps, but might significantly change the rules of the game. That’s a good reason to check out what’s new in Java. We’re going to cover:
Records, where and how to use them, apart from DTO/VO Pattern matching with instanceof A.
What do I think about Lombok?
I think it’s a nice island, and I wish to visit it one day.
What do I think about Project Lombok?
Well, I’ve been asked this question so many times, I’ve decided to write this post. Its main purpose is to be able to paste the link and back up, because the (yet another) discussion might be so intensive, that fists will be shaken and heads will roll… There are three assumptions here:
Another (half a) year has passed, another major Java™ version has been released. Java was supposed “to be slow”. However, Java turns out to evolve so fast, that next releases aren’t just version bumps, but might significantly change the rules of the game. That’s a good reason to check out what’s new in Java. We’re going to cover:
Records, where and how to use them, apart from DTO/VO Pattern matching with instanceof A.