How to Build Java Applications Today: April 26, 2021
Kubernetes & Service Mesh fundamentals, PostgreSQL as an OLAP database, collaborative programming in IntelliJ, Google’s new programming language Logica, Gradle 7.0, and GraalVM 21.1.
This is issue 33 of my weekly newsletter, “How To Build Java Applications Today”. I read all the Java newsletters, so you don’t have to! And I try to entertain you a bit while presenting Java news.
Quote of the Week
It is not because things are difficult that we do not dare, it is because we do not dare that they are difficult.
This week was primarily devoted to my start-up, “Your Home in Good Hands”. The mobile app that I’ve worked on for six months is now used in pilot mode. It holds up well so far! The number of users will expand a lot in May. So I got my work cut out for me! 😅
And my third InfoQ news article got published. It’s about the OSGi Working Group (WG; previously named “OSGi Alliance”). After shipping the OSGi Core Release 8 in December, the OSGi WG is now incubating at the Eclipse Foundation. Talking about a dry topic!
Issue 32 from April 19, 2021
Last week’s issue had just one embarrassing mistake: It said “Spring Spring Boot” in the summary section that got mailed. That’s one less mistake there than issue 31. Yay, progress!
Frameworks & Services
Kubernetes & Service Mesh Fundamentals
Organizations and cloud vendors quickly standardize on Kubernetes to deploy software. Sooner or later, we Java developers will run Kubernetes on our machines. So what’s Kubernetes, and how can we run it?
An excellent pair of podcasts from Software Engineering Radio answers these questions. Here’s my explanation of Kubernetes: We describe in Yaml what we want - like 3 Spring Boot containers, five microservice containers, and two database containers. Kubernetes then makes this happen: It runs the containers in so-called pods (typically one pod per container). If a pod fails, then Kubernetes creates a new one.
Things get interesting with so-called sidecars: These containers run alongside our own containers inside a pod. Why? To add cross-cutting concerns, like logging or access controls, to our applications.
Service Meshes take the sidecar idea to the next level. They help our Spring Boot pods find the right database pods (service discovery) and further improve health monitoring, security, and other aspects.
Now here’s the big “But”: Kubernetes is complicated to set up. So only invite this complexity into your world if you can really benefit from it! Fortunately, everybody and their dog are working on abstraction layers on top of Kubernetes. Hopefully, you can use one such abstraction when the time comes for you!
Did you know that the best way to run Kubernetes these days is Docker Desktop? And that you can run Docker Desktop in Windows 10 now on Windows 10 Home? Though in typical Microsoft fashion, it’s a complicated installation process. 😉
PostgreSQL as an OLAP Database
If our Java programs run in a big organization, chances are that their data is stored twice: In a relational database/NoSQL datastore and in a data warehouse. That adds complexity & cost. What if we could do away with the data warehouse and just store all data in one place?
That’s exactly what PostgreSQL proposes: Being both a transactional software back-end (On-line Transaction Processing - OLTP) and a data warehouse (On-line Analytical Processing - OLAP). Well, how hard can it be? Very hard, as it turns out: OLTP databases access data in rows, OLAP often in columns. So PostgreSQL needs to add column access to the rows.
Even if you don’t use PostgreSQL for OLAP, it’s well worth a look anyhow. For 13 years, I lead a software product that ran on MySQL (it probably still does). But I’m pleased with PostgreSQL as my “new database”: Small, fast, advanced, and extensible.
Code With Me: Shared Programming in IntelliJ IDEA
A host with a JetBrains IDE, such as IntelliJ IDEA, can share their code with up to 50 guests through Code With Me. Guests don’t need a JetBrains IDE; they download a small program instead. They can then edit and run the code that remains on the hosts’ computer. That’s useful for pair programming, code reviews, training, workshops, and probably many more scenarios.
Sounds great, so what does it cost? The Community Plan is free and gives us 30-minute sessions with up to three guests. The premium plan has no session time restriction and allows for up to 50 guests. It starts at $5/month for individuals. But at least for now, developers with an active JetBrains IDE subscription (such as IntelliJ IDEA Ultimate) get the premium plan for free. Sweet!
Over The Fence
Google’s new Programming Language Logica
Another week, another programming language by Google: “Logica” is the name. It’s a SQL successor that is “more concise and supports the clean and reusable abstraction mechanisms that SQL lacks”. Logica compiles into SQL, so it uses the same approach as Sass or Typescript.
Now I’m not convinced by the examples that Google’s announcement contained. For instance, here’s a SQL query they want to replace:
SELECT comment_text FROM comments WHERE user_id = 5;
And they replace it with this:
MagicComment(comment_text:) :- comments
(user_id:, comment_text:), MagicNumber(x: user_id);
That’s not even complete - we need to define these magic numbers, such as:
Maybe I’m just not smart enough to understand and see the benefits here. But I guess I’m really just too old, having written SQL for 30 years…
If Logica is your cup of tea, then Google’s tutorial is the spoon you need! Ouch - that sounded better in my head.
Whenever a new major version of Gradle is released, developers all over the world hold their collective breath and ask: How will my build break this time? Based on my use of Gradle 7.0 with a Spring Boot 2.4 project, I can say: Surprisingly little! How did they manage to do that?
By kicking the can down the road: Gradle 6.x warned me that “deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.”. Gradle 7.0 also warns but now says my build will be incompatible with Gradle 8.0.
What else is new, apart from breaking fewer builds?
Gradle 7.0 fully supports JDK 16, has faster incremental builds, and runs natively on Apple’s M1 Macs. And from the “too little, too late” department: Gradle now supports the Java Module System. You know, that part of Java that was to revolutionize how we write Java code but ended up as a JDK implementation detail instead?
Anyhow, Gradle 7.0 does seem to compile my Spring Boot application faster. And it didn’t break anything for me - so I’m a happy camper!
Talking about the nail in the coffin of the Java Module System: GraalVM has a new release. Unlike Gradle 7.0, the JDK 16 support in GraalVM 21.1 is just experimental.
The other headline feature is “faster warmup”: Multi-tier compilation performs fewer optimizations initially so it can start faster. Because some optimizations now run later, we also get “later peak performance”. But you don’t find that term in the release notes!
If you need to worry about download sizes: The GraalVM downloads are now smaller because Node.js isn’t included in the base downloads anymore.
Karsten Silz is the author of this newsletter. He is a full-stack web & mobile developer with 22 years of Java experience, author, speaker, and entrepreneur. Karsten got a Master’s degree in Computer Science at the Dresden University of Technology (Germany) in 1996.
Karsten has developed software in five European countries and the US. In 2004, he co-founded a software product start-up in the US. During power outages, the software protected TV, Internet, and phone services for 50 million North American cable TV households. Karsten led product development for 13 years and left after the company was sold successfully.
Karsten has worked as a contractor since 2017. He co-founded the UK SaaS start-up “Your Home in Good Hands” as CTO in 2020.