How to Build Java Applications Today: February 15, 2021
A guide to "compareTo()", native Java applications installers with "jpackage", an interview with the Java Language Architect, Snyk’s Java ecosystem survey, and 20 years "Agile Manifesto".
Introduction
This is issue #22 of my weekly newsletter, “How To Build Java Applications Today”. The newsletter complements my site betterprojectsfaster.com. There you can find my tutorials, conference talks, JUG talks, articles I wrote for other sites, and blog posts.
Last week, I spent most of my spare time again on my new project - and taxes. 😫 I’ll dedicate next weekend to my JavaLand talk. So betterprojectsfaster.com won’t get big updates in the next weeks, either.
Weekly Links
Java
A Guide to Implementing the compareTo()
Method
From all those “methods that our IDEs generates for us”, compareTo()
is the one we’re most likely to fiddle with. Why? Because we need it to sort objects. Well, how hard can it be?
Quite a bit, actually. Or so this article argues: First, there are the mathematical rules for compareTo()
. Then there’s the consistency with equals()
. And finally, we got Comparator
, the alternative to Comparable (
which defines the´ compareTo()
method). As a bonus, the article also dives into sorting collections.
Native Java Applications Installers with jpackage
All Java applications run in Kubernetes these days. At least that’s the impression we get when we look at all the tweets, talks, and other trending topics. Terrific! But what if we still need to install Java applications onto Linux, Windows, and Mac the old-fashioned way? A native installation package would be nice! You know, an rpm
on Linux, a Windows exe
, or a dmg
on macOS. And could it come with its own JRE, please?
Yes, there is such a tool: jpackage
. It’s derived from a JavaFX installation tool. It landed in preview in Java 14. And in Java 16, it leaves that preview status behind. So in a mere four weeks, we can use it in production! On the latest version of Oracle’s Inside Java podcast, a leading member of the jpackage
project spills the beans! I guess spilling beans comes naturally to a Java podcast…
Audio podcast or video podcast
An Interview with the Java Language Architect at Oracle
Quick: Who is the Java Language Architect at Oracle? James Gosling? Wrong, long gone from Oracle, and at Amazon now. Jonathan Schwartz? Well, that’s a bonus point for knowing the ponytailed, former CEO of Sun. But that’s even more wrong! No, the answer is Brian Goetz. Brian who? Unlike the other two guys, he doesn’t even have a Wikipedia page!
But the name may ring a bell - if you ever read the book “Java Concurrency in Practice“. That’s his! It also led him to Sun eventually. At Oracle today he decides “in what direction the Java programming model moves“. In this wide-ranging interview, he tells us which Java feature he’s most proud of (lambdas), which feature he’s looking forward to the most (“the bigger picture for pattern matching“), and which feature is most neglected (generics). And he thinks that Go’s concurrency model “is actually quite error-prone”. Trash-talking other programming languages is tight!
Snyk’s Java Ecosystem Survey 2021
It’s that time of the year again: Security company Snyk is asking us how we build Java applications today. And unlike my little newsletter of that name, this survey has thousands of participants! 2,000, to be exact, in 2020. This sounds like a somewhat representative slice of Java developers. That’s why last year’s winners weren’t all that surprising - Java 8, Spring, IntelliJ, with Kotlin and OpenJDK on the rise.
So please take five minutes to fill out the survey. It’s just 11 multiple-choice questions, plus your name and email address (both optional).
Software Development
20 Years of “The Agile Manifesto”
Just four core values and twelve principles: When 17 guys met in a ski resort in February 2001, they forever changed the way we all develop software. What do I think is the most important part of the Agile Manifesto? The name, of course - agile! That was genius! Wait, what? Let me explain.
Agile development is just one way of developing software, waterfall/conventional is another. Eventually, somebody in our organization decides or approves which of these “things” to use - without knowing much about them. So they say to themselves: “One thing is called ‘agile’. I don’t know what it is, but it sure sounds good! ‘Agile’ is fast and nimble. Isn’t that what we want to be? And agile sounds like startup and Silicon Valley, like fun and foosball tables, like late-night pizza and giving a damn. How can you not like agile!? We all want to be agile! I guess we go with agile!”
That’s called framing. “Agile” immediately puts a stake into the ground: Agile is good. And so the competition is not agile, not good". Not convinced yet? Imagine it was called “The Incomplete Manifesto”. You know, as in “leadership is about making decisions with incomplete information”. And boy do we have incomplete information when building software! But now, without more context, would you pick something “incomplete” over something “complete”? Yep, I didn’t think so, either.