DEV Community

Karsten Silz
Karsten Silz

Posted on

How to Build Java Applications Today: July 12, 2021

TL;DR

TIOBE Index July 2021, Spring blesses GraphQL, tuning Hibernate’s query plan cache, GitHub previews AI coding assistant, Quarkus 2.0.1, Spring Cloud Hoxton.SR12, and a terrible chart.


README

This is issue 44 of my weekly newsletter, “How To Build Java Applications Today”. I read all the Java newsletters, so you don’t have to! And it’s “Java news with a smile”.

If you like my newsletter, then subscribe to it on Substack! Or read it on dev.to, the Java Cafe, or Medium. Even better: Share it with people who may be interested.


Quote of the Week

If everything seems under control, you're not going fast enough‌.
Mario Andretti, American race car driver (born 1940), encourages us to release faster. Or so I think.


Stand-Up

My host country England lost the European Football Championship to Italy last night (that’s soccer for my US readers). Adding insult to injury: The final game was in London, and England lost in a penalty shoot-out, as they have so often in the past.

And yes, the United Kingdom has four different football teams: England, Wales, Scotland, and Northern Ireland. Except for Northern Ireland, all took part this time.

I can relate to the pain: When Germany hosted the Football World Cup in 2006, Italy defeated us Germans in the semi-final and went on to win (against France, also in a penalty shoot-out). BTW: England lost in a penalty shoot-out against Portugal back then…


Code Review

Issue 42 from June 28, 2021

I wrote about the Scala 3 release - eight years in the making - two weeks ago. Want to hear more? Then listen to Java Pub House podcast episode 97! Dean Wampler, the author of the just-published O'Reilly book “Programming Scala” book, explains what’s new in Scala 3.


Two weeks ago, I also wrote about “Java Applications in the Windows 11 App Store”. And last week, I told you that you can download a preview. What I forgot to mention is that The Verge, like many other sites, has a video preview of Windows 11.


Bookmarks

Java

TIOBE Index July 2021: Java Strikes Back - For Now

When we last looked at the popular monthly programming language ranking, Python placed ahead of Java two months in a row (see issue #40). Well, this month, Java recaptured second place with 11.17%, a hair ahead of Python at 10.95%. But C at the top is only ahead of Python by 0.67%, so expect frequent changes in the first three spots over the next few months.

The good news: Java can bounce back! The bad news: The long-term trend for Java is “down”. Check this TIOBE graph: Java fell from 26.5% in June 2001 to 11.2% today, which is a loss of 58%.

Good news again: Java has a shrinking slice of a growing pie because the number of software developers grows every year. And more good news: In a world of microservices, it’s easier for us to write our code in Java, even if another team writes their code in Python, TypeScript, or C#.

TIOBE Index July 2021


Frameworks & Libraries

Spring Blesses GraphQL

GraphQL a statically typed query language for APIs that has advantages over JSON REST APIs. Spring now integrates GraphQL with a project predictably named Spring GraphQL. It’s the successor of the GraphQL Java project that has existed for six years.

No matter if you use Spring or not: An official Spring project lends credibility to GraphQL. So if you already use GraphQL: Good for you! If not: Why not learn it?

A Spring GraphQL 1.0 milestone is available now. The 1.0 release will probably arrive early next year. That’s why Spring GraphQL will have to wait two more Spring Boot releases before it gets included there - in May 2022, if this year is any indication.

Talking about Spring Boot: Given the expected version jump of the Spring framework from 5.3 to 6.0 this fall, I thought Spring Boot would follow suit and go from 2.5 to 3.0. Well, I was wrong: The announcement talks about Spring Boot 2.6 and 2.7. 😒

Announcement


How to Tune Hibernate’s Query Plan Cache

Chances are, our Java projects use Hibernate to access data sources. Did you know that Hibernate needs to compile queries and store them in a cache with a default size of 2048 entries? I didn’t either.

Now, if our application uses more queries, then performance will suffer: Preparing JPQL queries from scratch takes five times as long as using a cached version. And preparing native SQL queries is 50% slower.

We can fix this with the setting hibernate.query.plan_cache_max_size. Read the article below for more details on the benchmarks and how you can check and measure Hibernate’s Query Plan Cache.

Article


Tools

GitHub Previews AI Coding Assistant

We humans can screw things up a lot. But if we believe in science-fiction movies like “Terminator 2”, then we need a machine to truly create a mess. Now here’s our chance to make a bigger mess in our code than usual: Use a machine to write code!

The machine I’m talking about is GitHub Copilot, an “AI pair programmer”, as GitHub calls it. In the example, a human enters this:

// Determine whether the sentiment of text is positive
// Use a web service
async function isPositive(text: string): Promise<boolean> {
Enter fullscreen mode Exit fullscreen mode

And the machine writes this code:

  const response = await fetch(`http://text-processing.com/api/sentiment/`, {
    method: "POST",
    body: `text=${text}`,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
  });
  const json = await response.json();
  return json.label === "pos";
}
Enter fullscreen mode Exit fullscreen mode

The Copilot works best with Python, JavaScript, TypeScript, Ruby, and Go. But I assume that Java is among the “dozens of languages” that it also knows.

So how the heck does this work?

As the example suggests, the Copilot analyzes comments (English only for now) and method names and then creates the method body. GitHub trained it with - you guessed it - code from GitHub repositories. This works because if we developers excel at something, it’s expressing succinctly what our code is to do, writing comments, and naming things.

Haha! Just kidding, of course: We developers typically suck at these three things. If that’s how the Copilot got trained, then our jobs are safe for now! 😅

There are more questions beyond “Does it work?”: Will Copilot add “bugs faster than the speed of thought” (nice heading)? Or is it the “new Stack Overflow” (also a nice one)? Will it add open-source into proprietary projects? Or violate licensing notice requirements of open-source projects?

I’m sure that this won’t be the last we hear of this!

InfoQ article


Releases

Quarkus 2.0.1

This first maintenance release of Red Hat’s modern microservice framework comes one week after 2.0.0 (see last week’s issue). It’s a “safe upgrade for anyone already using 2.0.0.Final”.

Announcement, Release notes


Spring Cloud Hoxton.SR12

The Spring version scheme change can’t come soon enough! Why? Because I don’t want to write slightly bizarre-sounding sentences like “This will be the last regularly scheduled release of the Hoxton Release Train”.

Anyhow, this release is for Spring Boot 2.3.x and 2.2.x. 23 issues got closed this time around.

Announcement


And Now For Something Completely Different

Candidate for “Most Terrible Chart of The Year”

Charts make it easier to spot important information in a sea of data and can highlight trends. Well, most do. Not this CNN one. Go ahead and spot what’s wrong with it.

Did you look at it yet? I’m waiting.

Ok, so what did you find?

  1. Although the big title is “Violent crime is a very big problem”, it doesn’t report on crime rates. The chart shows survey responses: “% of US adults who believe that violent crime is a ‘very big problem’” would have been the correct title.
  2. The chart goes from right to left.
  3. Different durations have the same length on the X-axis: 5 months (October 2018 - March 2019), 16 months (March 2019 - June 2020), and 10 months (June 2020 - April 2021).
  4. The Y-axis doesn’t start at 0 but at 35%, making the differences seem more significant than they are.
  5. The margin of error of survey responses is +/-3%, as the fine print below the survey reveals. So the “52% in October 2018 vs. 48% in April 2021” could also be “49% in October 2018 vs. 51% in April 2021”. In other words: Most differences are not statistically significant and don’t prove anything.
  6. The one statistically significant change was an 8% drop from 49% in March 2019 to 41% in June 2020. Maybe there is an explanation for this?

Tweet with terrible chart


About

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 marathon runner. Karsten got a Master's degree in Computer Science at the Dresden University of Technology (Germany) in 1996.

Karsten has worked in Europe and the US. He co-founded a software start-up in the US in 2004. Karsten led product development for 13 years and left after the company was sold successfully. He co-founded the UK SaaS start-up "Your Home in Good Hands" as CTO in 2020. Since 2019, Karsten also works as a contractor in the UK.

Karsten has this newsletter, a developer website, and a contractor site. He's on LinkedInTwitter, and GitHub. Karsten is also an author at InfoQ.

Top comments (0)