I’m a hacker, and I like to build things. I care about development efficiency and performance. I use Rails every day, but it’s a little too heavy for my personal projects.
When I write some code for fun, I tend not to want to use Rails much. I’ve been using RODA lately.
Roda is what?
Roda is a micro Web Framework written by Jeremy Evans, the author of Sequel, my favorite Ruby project.
RODA is great for two things – its performance, and its tree-like routing. And the two are related.
The cool thing about RODA’s tree routing structure is that it builds a tree to check the route. This means that you can nest and introduce routes without affecting performance.
You can also keep your code DRY by splitting routes into different files, and introduce permission validation code for top-level routes instead of introducing route by route.
This gives the project a clean and flexible structure.
Performance also makes RODA an advantage. Based on our tests, it makes the fastest Ruby Web Framework available today.
When I’m a user, I’m impressed with apps that are slow. I don’t want my app to be like that. Performance is important to me. I want the tools to be as fast as possible, but also as fun as possible.
Let’s look at a simple Hello World.
class App < Roda
route do |r|
r.get '/hi' do
This code does basically nothing. It just shows you that when you’re writing small personal projects, you don’t need to do the configuration initialization work before you can really get started.
My personal little project only has a small number of endpoints, so the Rails type of MVC structure is too large. I’d rather do it myself and put everything in one file.
Similarly, when the edges of your project are large, it is natural to break them up into smaller files.
Why not Sinatra
Sinatra is great and one of my favorite software projects of all time.
I use Sinatra to solve performance problems. It’s much faster than Rails. It’s just that CUBA is faster.
When writing Ruby Web Benchmark reports, I realized that Sinatra wasn’t as fast as I thought it would be, so I started using Cuba and RODA.
I have been using RODA on some small projects and it has helped me a lot and I like it very much.
In terms of performance, Roda is nearly two and a half times faster than Sinatra, which is also impressive.
Roda isn’t perfect
Using RODA is not an option for all projects. I use it for small projects where I’m the only developer. Unless it’s a small standalone tool, I wouldn’t let my ProCore team try it.
Roda’s documentation is good, but it’s a small community, anyway.
RODA is not a complete web framework, but a web request route. That means sometimes you have to work things out on your own. But many people who are used to Rails may not like this.
Finally, I like RODA very much, it is fun and can give me a break from my daily work. If you’re a Ruby developer, Roda is worth checking out.