One of my trade skills is server side Java, implying writing services in Java. Recently they’ve mostly been servlet based microservices. I’ve used the Spark Framework a lot, but as clean as that framework is, there’s no denying that servlets are the man behind the curtain, and you can’t avoid paying him attention any time you do anything of substance. Servlets work well enough, but they are showing their age, and so I always keep an eye open for other light weight service architectures.
When I saw Ratpack I decided to give it a go. It bills itself as “Simple, lean & powerful HTTP apps”. It’s built on newer and a carefully curated selection of technologies: Java 8, Netty, Guice, asynchronicity, event driven … looked promising.
Giving it a Try
I took my standard approach to any existing evaluation, and migrated one on my kata projects over to it. The obvious choice was my snippets service. I created a feature branch, and damned if just a few hours later I didn’t have a version of the service that I felt was cleaner and faster, and the branch was merged to master.
What I liked about Ratpack:
- Appeared to live up to its credo, simple, lean and powerful.
- Seemed to produce a quick app.
- Clearly not a servlets facade. The APIs are largely consistent and you don’t immediately hit the “and here’s where it becomes servlets” boundaries over and over.
- Documented, both an online manual and Javadocs.
Here are the rough edges from my perspective:
- The documentation. Yup, it’s a like and a dislike. The manual is useful, but it leans towards “here’s a cool way to do this cool thing.” When I wanted to do the pedestrian “serve static content from inside a fat jar”, I had to hit Google and hunt around various boards.
- The Gradle syntactic sugar that magically pulls in dependencies. I wish they just listed the dependencies needed and left it to you to include them. I really don’t want magic in my gradle build, where some dependencies are implied, but most you need to list. I prefer less magic, a little more work, but consistency.
To Keep in Mind
I was migrating Java 8 code which had lambdas sprinkled throughout. In at least one place things started happening out of order. I had to keep in mind that Ratpack leans towards asynchronous/reactive paradigms and that some of my lambdas where now off in other threads happening in parallel and I had to make sure they had completed before using their results.
If you’re curious to see what the Ratpack based version of my snippets server looks like it’s in my github.