In the following, Christian Schwörer and Carlos Barragan present important JVM microframeworks. Given the large number of microframeworks available, this list makes no claim to completeness, but presents important facts about some of the most prominent microframeworks.
http4k is a lightweight but fully-featured HTTP toolkit written in pure Kotlin that enables the serving and consuming of HTTP services in a functional and consistent way. http4k applications are just Kotlin functions which can be mounted into a running backend.
Kotlin
http4k calls itself a "Server as a Function HTTP toolkit". From this it is already obvious that its goal is to enable the creation of small, fast applications.
Like many other frameworks, it uses a Kotlin DSL for application configuration. This is primarily used to define HttpHandlers and filters. HttpHandlers are used to read requests and map them into corresponding responses. Filters can be used to add pre- and post-processing actions, for example for authentication, logging and caching.
http4k supports various servers such as Jetty (with WebSocket support), Undertow, Netty and Ktor CIO. It brings numerous extension modules, for example for Micrometer metrics, Resilience4J and preconfigured OAuth providers. Various templating engines - including Dust, Freemarker and Thymeleaf - can also be configured.
Hello World Example
fun main() {
routes(
"/hello" bind GET to {
Response(OK).body("Hello World!")
}
).asServer(Jetty(8080)).start()
}
Starter class Application.kt
The framework is characterized by its consistent use of Kotlin Functions. This allows for a very concise, short code style. Thus, in an http4k reference example, a Dropbox clone was realized with only 70 lines of Kotlin code.
Due to the strong focus on this language feature, appropriate prior Kotlin knowledge is helpful when getting started.
SUPERSONIC SUBATOMIC JAVA
A Kubernetes Native Java stack tailored for OpenJDK HotSpot and GraalVM, crafted from the best of breed Java libraries and standards.
Red Hat, Inc.
Java, Kotlin, Scala
Quarkus uses Ahead of Time (AoT) compilation to realize the framework logic. Thus, the resolution does not take place at the start or run time, but already with the compilation. AoT compilation allows the framework to do without reflection and runtime proxies, which has a positive effect on startup time and memory footprint.
The framework has several extensions such as RESTEasy, Hibernate, SmallRye JWT and Kafka. It also offers cloud-native modules for service discovery, the implementation of resilience patterns such as circuit breakers and distributed configuration management.
Quarkus is mostly compatible with the Eclipse MicroProfile programming model. In addition, it also supports the Spring model, so that Spring applications can be ported to Quarkus with manageable adaptations.
The framework places a lot of emphasis on the developer experience and offers a development mode. In this mode, code changes are applied immediately without having to recompile and restart the application.
Hello World Example
@Path("/hello")
class RestController {
@GET
@Produces(MediaType.TEXT_PLAIN)
fun hello() = "Hello World!"
}
Controller class RestController.kt
The framework is easy to understand and use, especially for Java EE or MicroProfile developers. Spring Boot developers will also find it easy to get started.
The integration of the GraalVM is a central aspect of Quarkus. Therefore, adapted libraries from well-known frameworks such as Hibernate are provided. These libraries have been modified in such a way that Reflection and Proxies are only minimally used and are as GraalVM-friendly as possible.
Although Quarkus does not currently offer as many modules and extensions as Micronaut or Spring, it is catching up with each release. It is expected that the framework will soon reach feature parity if the current development speed is maintained.
Therefore, Quarkus is a very promising candidate for the future of cloud-native Java applications.
Eclipse Vert.x is a tool-kit for building reactive applications on the JVM.
RedHat, Inc and Eclipse Foundation
Java, Kotlin, Groovy, Scala, Ruby, JavaScript
As the tagline suggests, Vert.x is more of a toolkit than a complete framework. Consequently, Vert.x does not offer some features that are familiar from other frameworks, such as dependency injection or convention over configuration. On the other hand, the runtime is very lean: Vert.x hardly uses Reflection, Dynamic Proxies or other techniques that could negatively affect runtime, especially in terms of application startup time and memory consumption.
Vert.x was launched back in 2011, making it one of the oldest and most mature microframeworks. It was also one of the first libraries with which reactive JVM applications could be developed.
Vert.x is a polyglot toolkit. It supports not only JVM languages such as Java, Kotlin and Scala, but also JavaScript and Ruby.
Even though it is only a toolkit, Vert.x still comes with numerous features: messaging for RabbitMQ and Kafka, data access for SQL and NoSQL databases, and authentication with JWT and OAuth 2.0. In addition, Vert.x is ideally suited for use in a microservices landscape, as there are components for service discovery, circuit breaker, and external configuration.
Vert.x supports the actor model approach: Verticles represent an actor. A Verticle is a small application executed by Vert.x. You can run multiple Verticle instances within one Vert.x instance. Communication between Verticles is done via the so-called Vert.x event bus.
Hello World Example
internal class Server : AbstractVerticle() {
fun start() {
vertx.createHttpServer()
.requestHandler { req ->
it.response()
putHeader("content-type", "text/plain")
.end("Hello World!)
}.listen(8080)
}
}
Starter class Application.kt
Vert.x is one of ...