What is Quarkus? Is it an alternative to SpringBoot?
I was looking for an alternative to SpringBoot once, and a fellow programmer suggested I try Quarkus.
SpringBoot is still my favorite to develop Java-based services, but there is no harm in exploring alternatives. From my analysis so far, Quarkus is aimed at cloud-native, microservices, and serverless development.
Quarkus is an open-source project developed and sponsored by Red Hat. Red Hat engineers initiated the project and has since gained contributions from a diverse community of developers worldwide.Ā
Quarkus is part of Red Hatās efforts to modernize Java for cloud-native and containerized environments. Red Hat sees Quarkus as a key technology to enable developers to build lightweight, fast, and efficient Java applications that are well-suited for microservices and serverless architectures.
As an open-source project, a community-driven process governs Quarkus, and contributions from various organizations and individuals play a crucial role in its evolution and improvement.Ā
Quarkus is a cloud-native and Kubernetes-native framework.
The framework was introduced to address the challenges faced by traditional Java applications in cloud-native environments. While Java is known for its robustness and scalability, it has often been criticized for its high memory consumption and slow startup times.Ā
Quarkus seeks to overcome these limitations and provide a more efficient platform for building cloud-native applications.
Key features and characteristics of Quarkus include:
Supersonic Subatomic Java: Quarkus claims to provide supersonic speed and a subatomic memory footprint. It achieves this by using a technique called āGraalVM Native Imageā to compile Java applications into native executables, which result in faster startup times and reduced memory usage.
Microprofile and Jakarta EE Compatible: Quarkus is compatible with popular Java standards, including MicroProfile and Jakarta EE. This means developers can leverage existing libraries while building applications on Quarkus.
Cloud-Native and Kubernetes-First: Quarkus is designed from the ground up to work well in cloud-native environments and is optimized for deployment on Kubernetes. It offers native integrations with Kubernetes features like ConfigMaps and Secrets.
Code
A sample API written in Quarkus project is given below.Ā
package com.example;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;
@Path("/books")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class BookResource {
private List<Book> books = new ArrayList<>();
@GET
public Response getAllBooks() {
return Response.ok(books).build();
}
}
Notice that we are only adding Java libraries here to create APIs.
Personally, I found it more challenging to get the setup ready in my local machine to run the Quarkus app compared to how I usually go to spring initlzr, add dependencies, and get my app up and running in literally no time. But that could also be because I have spent years playing around with Spring-based projects, and the community support out there for Spring projects is much higher than the comparatively-new Quarkus project.
Anyways, do try this project and form your own opinion.
Happy coding!