Apparently, Java developers and I would assume the rest of the world, are tired of reading about AI. So, what else do Java developers want to talk about? I went around and asked some folks in the community what they would like to read about: This article will discuss 11 non-AI Java trends including GraalVM, DOP, Quarkus, Kotlin, Spring Security, Spring Modulith, Observability improvements, and more.

Digmo + Java log

Here are topics that Java people want to talk about:

  • GraalVm – (ram usage) and deployment
  • A deep dive into DOP would be nice.
  • Quarkus 
  • Spring Internals
  • Kotlin + spring boot 
  • Spring Security 3 with OAuth2
  • Data JDBC
  • Compiled Template Alternatives to Thymeleaf
  • Spring Modulith
  • Runtime efficiency with Spring 
  • Observability improvements

1. GraalVM

11 Non-AI Java Trends: From GraalVM to Spring Modulith - AD 4nXc2Mx90jBgnVemNuFYWOW0SCApMw2IaeHxLeibSCFeS 5N6QEi1HJkejFGeWhQ9QZwLX3hETWSmVQuMGRbs451OSPZq27Rky0gHr66ui5cc7G7iHScnygV0AlJH tgxjYByT5qLi7fimc1RId0O8pauv3SW?key=kAdcc1LR23I tqbpAlH2rw

GraalVM is essentially an improved version of the JDK that includes ahead-of-time compilation to Native Image. It comes with the following features:

  • Native executables consume less memory and CPU resources than a JVM, enhancing efficiency and cutting expenses.
  • Native executables consist of only the necessary classes, methods, and fields in your application, decreasing the potential areas for attack.
  • Precompiled native executables boot up immediately without needing any warmup to operate at optimal levels.
  • Native binaries are compact and provide various linking choices, simplifying their deployment in lightweight container images.
  • Well-known platforms like Spring Boot, Quarkus, Micronaut, and Helidon offer excellent compatibility with GraalVM.
  • SDKs from top cloud platforms, such as Microsoft Azure, AWS, GCP, and Oracle Cloud Infrastructure, support and integrate GraalVM.

Quarkus initially positioned itself as the go-to framework for cloud-native applications, emphasising efficiency and performance. This strategy worked well during the early Spring Boot 2.0 era. However, with the rapid advancements made by the Spring team, particularly in the cloud-native space, many developers are now questioning the need for Quarkus.

Why should we use Quarkus if we already have a large Spring stack? What are its advantages?

Quarkus advocates have not directly addressed This question. While Quarkus leverages many official specifications (like Jakarta EE), it’s worth noting that Spring is also moving in that direction.

For Quarkus to gain a stronger foothold in the market, it needs to match and exceed Spring’s current standards. This involves offering clear, distinct advantages over Spring, especially for those who have already invested heavily in the Spring ecosystem.

2. Data-Oriented Programming (DOP)

Fundamentally, Java is an Object-oriented programming language (OOP). However, Object-Oriented Programming cannot efficiently solve all problems on its own. Over time, Java has borrowed useful concepts from other programming paradigms. Java 8 added support for Functional Programming, and now Java is gradually adding support for Data-Oriented Programming (DOP).

Data-oriented programming (DOP) is an approach to programming that treats data as first-class citizens. The programs are designed so that functions only change data by taking in one type of data, performing calculations, and outputting a different type of data. The data remains unchanged during computation because it is immutable, and the resulting data is also represented in an immutable form.

In contrast to Object-Oriented Programming, it takes a distinct approach in which real-world entities are represented as “Objects” with a changeable “state” that can be altered through an instance method.

For example:

// OOP way
// Basket state is mutated as a new fruit is added
basket.addFruit(fruit);

// DOP way
// new basket is created with fruit
var newBasket = addFruit(basket, fruit); 

Data-Oriented Programming in Java

In the article Principles of Data-Oriented Programming, Yehonathan Sharvit provided a clear description of DOP; he listed four principles of DOP:

  • Isolate code (behavior) from data.
  • Represent data with generic data structures (like maps, lists, sets, etc.; don’t use classes).
  • Regard data as immutable
  • Separate data schema from data representation.

Is it possible to follow these principles in Java?

We can adhere to principles 1 and 3 by using immutable data types without instance methods and by writing functions separately; however, we cannot comply with principle 2.

Theoretically, we can bypass classes and display information using generic data structures such as maps or lists; however, this would sacrifice type safety.

We prioritise type safety in Java and choose classes over a generic data structure. As we already adhere to the structure, principle 4 is unnecessary.

In Java, we mainly adhere to two DOP principles.

  • Isolate code (behaviour) from data.
  • Regard data as immutable.

You could argue that this is not solely DOP based on 4 principles, and you would be correct; it is not completely pure. In Java, the focus is not on being pure. The main goal is to optimise efficiency as a flexible programming language.

3. Quarkus

11 Non-AI Java Trends: From GraalVM to Spring Modulith - AD 4nXeWi9hRwzRQQX2AK1utOTl59wRLdc8VabBAwMILYbYWcKLYOL52l5EUI7D QPIgVbQsXX0YQUNlGP8adWIh0NSOOcCEPpykFsejC7zEFAm9SoL5reOHwQgBETVaC1rCnO wQJB F4SA7YobDGbPHZvX0RQO?key=kAdcc1LR23I tqbpAlH2rw

boot time, improved resource usage, and efficiency.

It is designed for use in cloud, serverless, and containerised settings. Despite this slight shift in emphasis, Quarkus still seamlessly integrates with the top Java-based frameworks.

Here are some important features of Quarkus:

  • Performance: Application performance is enhanced by processing tasks during build time rather than runtime.

This means faster startup, longer build time, and reduced memory footprint. Reflection calls can be substituted with standard invocations, decreasing memory usage.

  • Kubernetes-native: Deploying to Kubernetes is a straightforward process that requires minimal setup. Quarkus also offers Kubernetes metrics and debugging tools.
  • Reactive and Imperative: While it is reactive at its core, Quarkus also allows for both imperative and reactive code within an application. And they are controlled by the same reactive engine.
  • Simple development: Quarkus provides a range of tools for generating code, testing, debugging, and minimising boilerplate code. Its hot-reload feature is also enabled while running the application in development mode.

Changes made to Java resource and configuration files will be automatically compiled and redeployed when a request is resent.

4. Spring Internals

Spring Internals relates to the inner workings of Spring and the fundamental structure of the Spring framework.

Many Java developers are interested in Spring Internals as this helps them understand the “magic” that Spring carries out under the hood. This underlying architecture includes:

4.1 Dependency Injection (DI): This refers to the way Spring handles the creation of objects and wiring them together using its Inversion of Control (IoC) container.

package com.geeksforgeeks.org;

package ai.digma;

import ai.digma.observe;

public class Check {

    // The object of the interface IObserve
    IObserve observe;

    // Constructor to set the DI
    Check(IObserve observe)
    {
        this.observe = observe;
    }
}

4.2 Aspect-Oriented Programming (AOP): This is how Spring incorporates cross-cutting concerns such as logging, transaction management, and security.

To practice Aspect-Oriented programming, you must include this starter in your pom.xml file.

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>
</dependencies>

4.3 Spring Beans: This refers to the lifecycle and scope of beans, including how they are instantiated, configured, and managed.

package ai.digma;
 
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
@Configuration
public class AppConfig {
 
    @Bean
    public Observe myBean() {
        return new Observe();
    }  
}

4.4 Application Context: The central interface to the Spring IoC container, managing the lifecycle of beans and providing access to configuration information.

public static void main(String[] args) {

  ApplicationContext context = SpringApplication.run(App.class, args);

  Tutor tutor = context.getBean(Tutor.class);

  System.out.println(tutor);
}

4.5 Event Handling: How Spring handles application events and the event listener mechanism.

@Service
public class AuthenticationService {
    @Autowired
    private ApplicationEventPublisher eventPublisher;

    public void AuthenticateUser(String username) {
        // ... Authentication logic ...

        eventPublisher.publishEvent(new LoginEvent(this, username));
    }
}


4.6 Transaction Management: The internal workings of Spring’s transaction management, both programmatic and declarative.

@Service
@Transactional
public class EmailService {

    public void sendEmail(String email, String message) {
        // send email code
    }
}

4.7 Spring MVC: The architecture of the Spring Model-View-Controller framework, including how requests are processed and views are rendered.

@EnableWebMvc
@Configuration
public class WebConfig {

    /// ...
}

4.8 Data Access: This refers to how Spring abstracts data access using frameworks (like JDBC, JPA, Hibernate) and manages database transactions.

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/library
    username: root
    password: your_password
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true

5. Kotlin with Spring Boot

Some developers went from Java to Kotlin and never looked back. What Java developers love about Lombok in Spring Boot is that Kotlin developers have that with Kotlin.

11 Non-AI Java Trends: From GraalVM to Spring Modulith - AD 4nXcHshVIYgA5FaG0D4S7W9H4kveMUycNlciS6wI 1c0xk87naG2bwmbzf hg7eanQtFr3X4 93X32tj5vPRfYOjUMBzpCsQSom2l2Nj6 gpscYaRMxLKF3tKZdGKKv3cQ0fQOSw3BMG38pO8MyJg2fGunIW6?key=kAdcc1LR23I tqbpAlH2rw


Yes, record classes from Java 21 might be nice. Actually, as Java is getting a bit pressured, I think they are getting faster and faster at integrating new features and improving the developer experience to compete with Kotlin.

Kotlin offers several benefits over Java, such as brevity, absence of null pointer exceptions, functionalities related to functional programming, and enhanced tools. Incorporating Kotlin into your company’s development workflow may be beneficial, particularly for new microservices or slowly introducing it into current projects.

One thing you need to take note of is that spring annotations can not be used with suspension functions.

6. Spring Security 3 with oAuth2

REST APIs are the foundation of modern web apps, enabling data transfer and interaction between different parts. The importance of securing API endpoints is extremely high, whether for a banking app dealing with financial transactions, a healthcare platform managing patient data, or an e-commerce system handling user information. Unauthorised entry, data leaks, and other security risks endanger user privacy and present considerable legal and financial dangers to organisations.

Protecting REST APIs is not only recommended but essential in a time of increasingly complex cyber threats. Unprotected APIs can be used to obtain unauthorised entry, alter data, or disturb services, resulting in serious repercussions for businesses and users.

Spring Security 3 is now the preferred security framework for Java applications to implement authentication and authorisation in the complex web security landscape. Its adaptable and expandable structure makes it ideal for safeguarding REST APIs, offering developers a robust set of tools to enforce access controls and safeguard resources.

OAuth2, however, addresses authorisation challenges by introducing a standard protocol for delegated access. This protocol enables apps to access users’ resources with limited privileges while keeping sensitive credentials secure. Due to its adaptable nature, OAuth2 is well-suited for third-party apps or services requiring managed access to secured resources.

Java developers can strengthen their defence against various security threats by integrating Spring Security 3 with OAuth2. Spring Security 3 offers many functionalities, covering user authentication and complex authorisation situations. At the same time, OAuth2 streamlines the management of access tokens and permissions for a secure and user-friendly experience.

7. Spring Data JDBC

Connecting with databases, reading, and inserting data in Java can be difficult. Developers have to create JDBC URLs, manage database connections, and fix practical application issues like connection pools. 

Spring makes database-related tasks easy with its abstractions. A perfect example of an abstraction in Spring is the JDBC template.

int result = jdbcTemplate.queryForObject(
    "SELECT COUNT(*) FROM EMPLOYEE", Integer.class);


public int addEmplyee(int id) {
    return jdbcTemplate.update(
      "INSERT INTO EMPLOYEE VALUES (?, ?, ?, ?)", id, "John", "Doe", "UK");
}

The JDBC template is a reliable abstraction that streamlines database interaction. Yet, it can become verbose when creating basic CRUD services centred around resources. A thorough understanding of communication techniques with a database, like row mappers and mapping columns to fields, is necessary and can be challenging.

To solve the verbosity and complexity involved in creating basic CRUD services, Spring Data JDBC, a component of the extensive Spring Data collection, simplifies the process of creating JDBC-based repositories. This module focuses on improved assistance for data access layers based on JDBC, making it easier to build Spring-powered applications that utilise data access technologies.

@Repository
public interface EmployeeRepository extends CrudRepository<Employee, Long> {

    List<Employee> findByName(String name);

    @Modifying
    @Query("UPDATE employee SET name = :name WHERE id = :id")
    boolean updateByName(@Param("id") Long id, @Param("name") String name);
}

8. Compiled template alternatives to Thymeleaf

Thymeleaf is a Java template engine for server-side web and standalone applications. The main focus is designing easy HTML templates for users to navigate and update. 

Thymeleaf templates are valid HTML files that can be displayed in a browser even without processing by the template engine, making them more readable and easier to work with.

It supports natural templating, meaning the templates look like regular HTML with additional attributes for dynamic content.

<table>
  <thead>
    <tr>
      <th th:text="#{msgs.headers.product_name}">Product Name</th>
      <th th:text="#{msgs.headers.product_price}">Product Price</th>
    </tr>
  </thead>
  <tbody>
    <tr th:each="prod: ${Products}">
      <td th:text="${product.name}">Oranges</td>
      <td th:text="${#nos.formatDecimal(product.price, 1, 2)}">2.99</td>
    </tr>
  </tbody>
</table>

Thymeleaf integrates well with various Java web frameworks, such as Spring MVC, making it a popular choice in the Spring ecosystem.

Many Java developers prefer Thymeleaf because JSP makes it too easy to code injection flaws and other bugs; the HTML and Java source codes look horrible if mixed.

Despite the allure of using Thymeleaf, Java developers still want other compiled template alternatives to Thymeleaf.

These compiled template alternatives are:

  • Jade/Pug
  • Velocity
  • Freemaker
  • JSP (Java Server Pages)
  • Handlebar.java

9. Spring Modulith

Before we talk about Spring Modulith, we need to understand its inspiration. It was inspired by an architectural design called the Modular Monolith.

A modular Monolith is an architectural design that organises codes by grouping them into modules. It is a great option for numerous organisations. Having a level of independence is beneficial as it allows for a smooth transition to Microservices Architecture if needed.

Spring Modulith assists developers in creating organised Spring Boot applications and helps them discover and manage domain-driven application modules. It aids in verifying modular setups, testing modules independently for integration, monitoring the module-level behaviour of the application and generating documentation snippets based on the setup.

Below is what a Spring Modulith looks like for an application demo web application called shop.

□ Shop
└─ □ src/main/java
   ├─ □ shop           <1>
   │  └─ Application.java
   ├─ □ shop.inventory <2>
   │  └─ ...
   └─ □ shop.order     <2>
      └─ ...

Spring Modulith started gaining attention when news broke that Amazon Prime Video ditched its use of microservices-cum-serverless and went back to traditional, monolithic architecture. This news made system architects and software developers question the effectiveness of microservices.

However, a temptation exists with modular monoliths: when developers are under deadline pressure, they are likely to take shortcuts by adding functionality where it doesn’t naturally belong just to release something faster.

Unless the team is committed to preserving clean architecture, it’s likely that everything will end up in a single module sooner rather than later. Unlike microservices, a clear physical boundary exists between applications. You can’t easily mix separate concerns together.

10. Runtime Efficiency with Spring 

Runtime efficiency with Spring speaks to the improvement that came to Spring’s runtime with the advent of two features being adopted in Java 21

  • Virtual threads
  • CRaC

Project Loom, popular as virtual threads, revolutionized server applications in Java 21. It greatly decreased the excess of traditional thread-per-request models, providing almost perfect hardware usage. 

Spring MVC utilizes virtual threads to build a lightweight web stack, enhancing performance on Servlet containers such as Tomcat or Jetty without requiring changes to the code. The smooth blending leads to improved scalability and effectiveness, which is especially advantageous for programs developed with Spring Web MVC.

import java.util.*; 

//Driver class 
public class VirtualThreadDemo { 
	// main function 
	public static void main(String[] args) { 
		try { 
			
			// thread Initialization
			Thread.Builder builder = Thread.ofVirtual().name("Digma Thread"); 

			Runnable task = () -> { 
				System.out.println("Running thread"); 
			}; 

			Thread t = builder.start(task); 

			System.out.println("Thread t name: " + t.getName()); 

			// Add a delay to allow the virtual thread to run 
			// Sleep for 1 second 
			Thread.sleep(1000); 

			// Wait for the thread to complete 
			t.join(); 
		} catch (InterruptedException e) { 
			e.printStackTrace(); 
		} 
	} 
} 

In response to community feedback, Spring Framework 6.1 introduces RestClient, a modern HTTP client optimised for Virtual Threads. This new feature offers another option to RestTemplate and the reactive WebClient, improving the user experience in the Spring ecosystem, including Spring Cloud Gateway.

Project CRaC

This project introduced a new method for scaling down to zero. It allows for checkpointing and restoring JVM applications, leading to a notable decrease in startup times. 

In Spring Framework 6.1, CRaC support is incorporated to efficiently manage resources such as sockets and pools in alignment with Spring’s lifecycle. This technology presents a different option than GraalVM, with its advantages and disadvantages, such as requiring application pre-loading and cautious management of confidential information.

11. Observability improvements 

Much attention has been drawn to observability improvements, especially in Spring Boot 3.2 and Spring Boot 3.3. This is so because Java developers are beginning to realise that they need to understand the internal state and behaviour of the web applications they’re building.

Monolithic applications offer a single point of monitoring, but monitoring microservices becomes tricky because these distributed services create so many blind spots. 

Observability solves this problem by providing insights into the behaviour of microservices and their interactions. This is crucial in a distributed system where services are not tightly coupled and function independently.

One tool that takes advantage of the observability improvements in Spring Boot version 3.2 and version 3.3 is Digma

11 Non-AI Java Trends: From GraalVM to Spring Modulith - AD 4nXetLiYyintnIw kYd0bvSEl T57espfcgKHwLf Lx6MsP2LiAQoYaat0RpMg7HiWqkgr92uN2 C4NOJTrxI6AA480ZmX4c5fsAzLHt4W9yNQL7bJuNfK1h0OAezZcBQrZ0 iyUPCdxY PWFHWD00zqvA1FK?key=kAdcc1LR23I tqbpAlH2rw

Digma insights

Digma gives Java developers a holistic approach to gaining insights into their application’s performance, detecting anomalies, and quickly tackling bugs. Digma offers the following benefits:

  • Improved Optimization: Identify performance bottlenecks and optimise resource utilisation across your web application
  • Fast Incident Diagnosis: It helps you quickly pinpoint the root cause of production issues, streamline troubleshooting and reduce downtime.
  • Improved Application Visibility: It lets you see your application’s overall health status, facilitating proactive maintenance and preventing outages.
  • Application Health: Digma offers a detailed analysis of your application’s overall health, possible issues, and user satisfaction. It allows you to recognise problems before they affect operations and take action beforehand.

How to make good use of Digma

  • Establish your observability objectives: Determine which components of your microservices require the most attention for monitoring. You can skip this step if your application is a monolith or a modular monolith.
  • Make use of Digma in the development phase to detect issues early by installing and activating it on your IDE.
  • Select the tools that integrate seamlessly with your Java development setup and cloud infrastructure.
  • Utilise automation to establish thresholds and alerts for proactive system health management.
  • Continuous Learning: Regularly review the data collected by Digma to refine and adapt observability practices.

Conclusion

The Java trends we’ve discussed give an insight into what Java developers are interested in and the likely questions you’ll get asked in an interview for a Java developer role. You also appreciate how far Java has come and all the improvements that have been made over the years.

Download Digma: Here


Spread the news:

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *