Many Ruby developers love Rails for its power and capabilities as a model-view-controller (MVC) framework. But some of them don’t like Rails’ size, complexity, and learning curve.
Meanwhile, many other Rubyists love Sinatra for its simplicity and ease of learning, plus its ability “to create a fully functional web app in just one file,” says Darren Jones in his new book, Jump Start Sinatra. “There are no complicated setup procedures or configuration to worry about. You can just open up a text editor and get started with minimal effort, leaving you to focus on the needs of your application.”
Jones does not temper his enthusiasm for Sinatra, adding that “there isn’t a single line of bloat anywhere in its source code, which weighs in at fewer than 2,000 lines!”
“Sinatra makes it easy–trivial almost–to build sites, services, and web apps using Ruby,” the author states. “A Sinatra application is basically made up of one or more Ruby files. You don’t need to be an expert Rubyist to use Sinatra, but the more Ruby you know, the better you’ll be at building Sinatra apps.”
Jones adds: “Unlike Ruby on Rails, Sinatra is definitely not a framework. It’s without conventions and imposes no file structure on you whatsoever. Sinatra apps are basically just Ruby programs; what Sinatra does is connect them to the Web. Rather than hide behind lots of magic, it exposes the way the Web works by making the key concepts of HTTP verbs and URLs an explicit part of it.”
Jump Start Sinatra is a well-written, appropriately illustrated guide to getting started with this popular free software. Ruby newcomers may wish for a few more how-to steps or code examples. But the counter argument is, if you’re brand-new to Ruby, save Sinatra for later; focus on getting learning Ruby first.
Darren Jones does not buy into a common assessment that’s often heard when developers are asked their views of Rails vs. Sinatra. “Opinions abound that Sinatra can only be used for small applications or simple APIs, but this simply isn’t true,” he argues. “”While it is a perfect fit for these tasks, Sinatra also scales impressively, demonstrated by the fact that it’s been used to power some big production sites.”
Some of those “big production sites,” according to Wikipedia, include such notables as Apple, LinkedIn, the BBC, the British government, Heroku, and GitHub.
– Si Dunn