Why Kit?
January 8, 2022
Kit is a web framework built upon robust existing technologies used in the Clojure ecosystem. The libraries that are its foundation have evolved from production code running on scalable, fast systems meant to handle tens of thousands of requests a minute. At the same time, it is a very lightweight framework, accessible to newcomers.
In short, I spent six months with Dmitri and Dan to build a web framework that would prepare a production-ready foundation in minutes.
Philosophy
There are three fundamental goals of the project:
1) Fast and robust libraries for a scalable web server
2) Excellent developer experience
3) Make it easy for newcomers to the library, and to Clojure, to get started
What does this mean in practice?
Fast
Speed is important for servers which handle many concurrent requests, which is why the Undertow web server is the default configuration. This server can handle both synchronous and asynchronous requests.
While the default configuration the Kit template spits out is plenty fast, the Kit Framework was built in such a way that the configuration can be customized for as much speed as you need. This means you can cut down on middleware, replace the web server, and do whatever is required to get more performance. Kit’s here to provide you with fast defaults out of the box to start from and then gets out of your way when you need to go blazingly fast.
Robust
The libraries are built using existing dependencies that have become defacto standards in the Clojure community. We are not trying to reinvent the wheel, but package a lot of the existing tools we used across our projects into simple, customizable components. Thanks to Integrant these libraries give the components you would need in many systems - your database, cache, routes, REPL, and so on. Using Integrant lets us built a modular foundation with Kit libraries.
At the time of launch, Kit comes with official libraries supporting:
- Hato HTTP client
- Prometheus metrics
- Quartz scheduler
- Redis cache
- Selmer templating engine
- JDBC, including default PostgreSQL bindings for JSONB
- Undertow HTTP server
- Socket REPL
Developer experience
We know that it’s impossible to handle every single use case a developer will have out of the box. This is why flexibility is inherent in Kit. What a good developer experience means for us is that the Framework gives you all the tools to get started, strips away the boilerplate, and let’s you do what you do best. If there’s anything that you don’t need then simple, just don’t include it. Want to use a different server? Easy, remove the io.github.kit-clj/kit-undertow
edge and write your own.
For context, the entirety of the guestbook example project is less than 300 lines of Clojure code. In it you end up with a server that lets you write and read from a database, accept user input, and render the results.
Accessibility
In short, the code generation and module system of Kit make it incredibly easy to get started and hacking away at a project. Dmitri talks about this in great detail in his introduction to Kit here.
Getting Started
Interested? To get started, you can visit the Kit documentation site and work through the Guestbook project or read through the documentation. You can also join us in the #kit-clj channel in the Clojurians Slack to talk there. We’d eagerly welcome feedback and contributions to Kit!