Featured image for "Why should I choose Quarkus over Spring?"

Want to learn more about developing applications with Quarkus? Download our free ebook Quarkus for Spring Developers, which helps Java developers familiar with Spring make a quick and easy transition.

As interest grows in microservices and containers, Java developers have struggled to make applications smaller and faster to meet today’s demands and requirements. In the modern computing environment, applications must respond to requests quickly and efficiently, be suitable for running in volatile environments such as virtual machines or containers, and support rapid development. Because of this, Java, and popular Java runtimes, are sometimes considered inferior to runtimes in other languages such as Node.js and Go.

The Java language and platform have been very successful over the years, preserving Java as the predominant language in current use. Analysts have estimated the global application server market size at $15.84 billion in 2020, with expectations of growing at a rate of 13.2% from 2021 to 2028. Additionally, tens of millions of Java developers worldwide work for organizations that run their businesses using Java. Faced with today’s challenges, these organizations need to adapt and adopt new ways of building and deploying applications. Forgoing Java for other application stacks isn’t a choice for many organizations. It would involve re-training their development staff and re-implementing processes to release and monitor applications in production.

Java is still relevant

With additions to Java and Java frameworks over the past few years, Java can proudly retain its role as the primary language for enterprise applications. Quarkus, an open source project introduced by Red Hat, is one such framework that has taken the Java community by storm. Quarkus combines developer productivity and joy with the speed and performance of Go.

Quarkus integrates with other modern Java frameworks and libraries that many developers are already familiar with and most likely using. Among the specifications and technologies underlying and integrated with Quarkus are Eclipse MicroProfile, Eclipse Vert.x, Contexts and Dependency Injection (CDI), Jakarta RESTful Web Services (JAX-RS), the Java Persistence API (JPA), the Java Transaction API (JTA), Apache Camel, and Hibernate, just to name a few.

Quarkus and Spring address many of the same types of applications, but because it was born in today’s day and age, Quarkus has the advantage of starting with a clean slate. Quarkus can focus on innovation in modern areas of development pertaining to scalable, cloud-hosted applications because it doesn’t have to retrofit new patterns and principles into an existing codebase that has evolved over time.

But I already know Spring ...

Quarkus for Spring Developers introduces Quarkus to Java developers with a special eye to helping those familiar with Spring’s concepts, constructs, and conventions learn Quarkus quickly. Spring developers should immediately recognize and be able to apply patterns they are already familiar with, and in many instances, using the same underlying technologies. Using Kotlin in your Spring applications? Great—you can continue using Kotlin with Quarkus.

Chapters are devoted to getting started, RESTful applications, persistence, event-driven services, and cloud environments such as containers and Kubernetes. Each chapter offers like-for-like examples and emphasizes testing patterns and practices with such applications, while also differentiating Quarkus from Spring.

Additionally, Quarkus provides a set of extensions for various Spring APIs. These extensions help simplify the process of learning Quarkus or migrating existing Spring applications to Quarkus, capitalizing on a developer’s Spring knowledge to accelerate the learning curve to adopt Quarkus. In some cases, an existing Spring application may even be able to run in Quarkus without any code changes.

How can Quarkus help me?

Quarkus has many features and capabilities that can help both developers and operations teams.

Enhancing developer productivity

Since its inception in early 2019, Quarkus has focused on more than just delivering features. Developer productivity and joy have been critical goals. With every new feature, Quarkus carefully considers the developer experience and how to improve it.

The development process is faster and more pleasant with Quarkus's live coding feature. Quarkus can automatically detect changes made to Java and other resource and configuration files, then transparently re-compile and re-deploy the changes. Usually, within a second, you can view your application’s output or compiler error messages. This feature can also be used with Quarkus applications running in a remote environment. The remote capability is useful where rapid development or prototyping is needed but provisioning services in a local environment isn’t feasible or possible.

Quarkus takes this concept a step further with its continuous testing feature to facilitate test-driven development. As changes are made to the application source code, Quarkus can automatically rerun affected tests in the background, giving developers instant feedback about the code they are writing or modifying.

Need a database for your application? Kafka broker? Redis server? AMQP broker? OpenID Connect authentication server? API/Schema registry? Quarkus Dev Services for databases (see the video demo), Dev Services for Kafka (see the video demo), Dev Services for Redis, Dev Services for AMQP, Dev Services for OpenID Connect (see the video demo), and Dev Services for Apicurio Registry have you covered. Dev Services makes development faster by providing needed infrastructure automatically, eliminating all the required provisioning and configuration hassle. New Dev Services are added with each new release.

Following the philosophy of simplicity and enhancing developer productivity, building an application into a native image is extremely simple. All the heavy-lifting and integration to consume GraalVM is done for you by the Quarkus build tools. Developers or CI/CD systems simply need to run a build, just like any other Java build, to produce a native executable. Tests can even be run against the built artifact.

Kubernetes native

From the beginning, Quarkus was designed around Kubernetes-native philosophies, optimizing for low memory usage and fast startup times. As much processing as possible is done at build time. Classes used only at application startup are invoked at build time and not loaded into the runtime JVM, reducing the size, and ultimately the memory footprint, of the application running on the JVM.

This design accounted for native compilation from the onset, enabling Quarkus to be "natively native." Similar native capabilities in Spring are still considered experimental or beta, and in some instances, not even available. Coupled with a runtime platform like Kubernetes, more Quarkus applications can be deployed within a given set of resources than other Java or Spring applications.

To be or not to be reactive?

With Spring, a developer needs to decide up front, before writing a line of code, which architecture to follow for an application. This choice determines the entire set of libraries that a developer uses in a Spring application. Quarkus does not have such limitations because it was born in the reactive era. Quarkus, at its core, is based on a fully reactive and non-blocking architecture powered by Eclipse Vert.x.

Quarkus integrates deeply with Vert.x, allowing developers to utilize both blocking (imperative) and non-blocking (reactive) libraries and APIs. In most cases, developers can use both blocking and reactive APIs within the same classes. Quarkus ensures that the blocking APIs will block appropriately while the reactive APIs remain non-blocking.

Ready to give it a try?

The Developer Sandbox for Red Hat OpenShift, which offers a free and ready-made environment for trying out containerized applications, is set up to support Quarkus. Whether you run on-premises, on Red Hat OpenShift, or in another cloud setting, the many open source capabilities of Quarkus are available.

Quarkus for Spring Developers will help get you started and guide you through your journey.

Last updated: September 13, 2021

Comments