Recently, I’ve been working on a project that is mostly front-end work, but also communicates with some back-end web services. I needed something to quickly respond to some basic GET requests at various endpoints and return either HTML fragments or JSON. I’m not much of a big Ruby or Rails programer (although I do admire both), but I decided to try out a Ruby gem called Sinatra for my basic web server needs.
Aside from being a famous American Crooner, Sinatra is a “DSL for quickly creating web applications in Ruby with minimal effort.” (as described in the intro)
After using it for a bit, I’d have to agree. This is especially impressive to me because as I mentioned, I’m not much of a Ruby programmer. Sinatra let me do what I had to do on the back end (which wasn’t much) quickly so I could focus on the UI code. I ran into a few things that I had some trouble with (like extracting a custom header), but after a bit of Googling, I found out how to do what I needed to do.
What I especially liked about using Ruby with Sinatra was the fast cycle times. I could make a change and restart Sinatra in less time than it took me to switch back to my web browser. Having a very short feedback loop really speeds up development. I haven’t uses Sinatra extensivley or researched it too deeply, so I can’t comment on it’s appropriateness for larger projects, but it was great for my simple needs.
So if you find yourself needing a fast, lightweight web server for a simple app or prototype, give Sinatra an audition. You might even find it fun.
* Please be aware that all comments are moderated.