We are in 2020, Java is one of the most widely used languages for developing applications. And above all, there is Quarkus.
We offer you to share our point of view and let you discover this framework.
Ready for a trip?
A bit of history
Why is Lunatech interested in Quarkus? Because we find the spirit of Play Framework 1, another framework created by Guillaume Bort (Criteo Labs) 10 years ago. And 10 years ago, believe us, being productive with Java to develop a Web app was complicated (JSF, XML, J2EE…). We were facing a very nice effort from a part of the community to make everything systematically complicated. And one day, Play Framework shows another vision. Nicolas Leroux (CEO of Lunatech) was one of the contributors on Play Framework 1, and he co-wrote a book on Play2 Java a few years later. As for me (Nicolas Martignole) I was passionate about Play 1. At that time I was touring the JUGs. More than 30 presentations in the end. It is on this occasion that I met Nicolas Leroux.
Then Quarkus. In a few words: it is a Java software framework focus on productivity, for Java or native applications (with GraalVM). Once your development is finished, you can package a native application. No more need for JVM. This allows you to have an application that starts instantly.
What can it be used for? Quarkus was thought from the beginning for hosting in the Cloud. You gain in memory size, which reduces costs. And your application starts up in the blink of an eye: you can for example look at so-called “serverless” architectures.
For also discussing with Stéphane Epardaud (Red Hat) and Emmanuel Bernard (Red Hat): it is clear that the user/developer experience is very important. It’s important to be productive, to go fast and also to allow to create several services, not just one. That’s why you might rediscover some old good ideas of Play such as the display of errors in the browser or the hot reloading.
What strikes from the first minutes with Quarkus is the speed of compilation. This makes it possible to change a few lines, and instantly reload the page in the browser. It’s simple: I’ve re-enabled my Live Reload” extension on Chrome, so I don’t have to refresh the browser page.
Compared to Play2 based on SBT and Scala, Quarkus is much faster. Of course we’ll lose the verification at compilation time with the types, but on the other hand we’ll gain in feedback loop. Play2 remains better on the side “I check all the types at compilation” because it is based on Scala. But at the price of a compilation time 10 times slower (and I’m a nice, happy owner of an i9 core with an apple on it)
On the templating side, no Twirl like Play2 but a new simple project called Qute. It’s very easy to learn, it allows you to quickly build a small web application. It is possible to make templates and redo the “taglet” pattern (first seen on Grails if I remember correctly, in 2009).
Qute being a young project, I’m currently missing the equivalent of Play2’s Forms. But hey, let’s not be in too much of a hurry, all this didn’t exist a few months ago.
Show me some real-life projects
If you want to “read” some Quarkus code, we have created 2 projects for Lunatech, in order to evaluate the framework, on writing web applications :
Hotel Quarkus demo is a project with a simple REST API and a Vue.JS front-end.
Time Keeper is a new internal project, in the spirit of the small CRUD applications we often see.
These projects are shared to show you our tests and we will often publish updates.
How to evaluate the framework?
We have listed several typical use cases based on our experience. The goal is to see exactly how we could respond to our customers’ requests on future projects.
Here are a few points that we will evaluate in the coming weeks:
the template engine, the possibility to include tags to build a website
loading per page from a database and displaying with the pagination of the elements
HTTP error handling (404, 400)
generating and sending emails via API / via SMTP
simple authentication and rights management by controller method
Open ID Connect for integration e.g. with Keycloack
JSON and serialization
We will have an approach based on our experience in web application development, accumulated over more than 10 years. For example, Lunatech has built a data publishing web service with a GraphQL API for a large amusement park in the Paris region (yes, the biggest one…).
Why is Quarkus fast?
And maybe first of all… why is this getting interesting? For 2 reasons: you will want to spend your day on this framework. Then you will be pleasantly surprised by how easy it is to test your application with a real database, as the startup time is really (really) fast.
Remember what we were explaining a few lines above : the application starts very quickly. This then allows you to write integration tests, and run them on a real instance of your application. Unit tests on your application. The whole thing works with Docker, which will be in charge of building your database. Add some Flyway for example (and/or Hibernate ORM) and you won’t have to manage (too much) your schema for the development mode.
Quarkus is super-sonic. Its startup time is almost instantaneous. And it’s even better with the native version, where you’ll run a binary, which will connect to your database, create the schema, and mount data. All this in 85ms as shown by Emmanuel during his presentation in 2019 at Devoxx Belgium.
Quarkus starts quickly, because part of the usual work is shifted from execution to compilation. Frameworks in general have to read configuration, solve Java Proxies, browse the classpath (mostly because of annotations), solve dependencies, do injection, use reflection to introspect classes… All this costs time at the start of the application. In the idea of targeting the Cloud, Quarkus will therefore weave the links and tackle the task of grouping and plugging in a large part of your application.
Quarkus is a framework to start other frameworks at build time
This work is done only once: during compilation. Whether your little service is then started once or 1000 times: the gain is final. Less startup time but also less memory needed to start. Bye bye the XML parser to look at the persistence.xml file for example…
This requires a lot of work on the Quarkus side, which must analyze what frameworks do in general, to accelerate them. We can say that Quarkus is a particle accelerator (wooo this one is mine).
Our first conclusion is the following : by moving towards more simplicity, and by removing unnecessary code: we get an immediate gain in productivity.
Tons of Java framework were waiting for a new vision, this is what Quarkus will offer you.
Congratulations to Emmanuel and the other talents working on this project.
To be continued…