6 ms·
I've been using Sinatra for more than a year now. It's the perfect mini framework in Ruby. It helps you get web dev done, without ever getting in your way. I
by cschneid 17y ago
I've been using Sinatra for more than a year now. It's the perfect mini framework in Ruby. It helps you get web dev done, without ever getting in your way.
I've written a blog with lots of documentation at http://www.gittr.com http://www.gittr.com.
In addition, coworkers of mine at Citrusbyte have taken Sinatra and built a minimal, yet more full featured web-stack called Monk (http://www.monkrb.com http://www.monkrb.com). Basically it takes the Sinatra library and wraps it up with convenient conventions, libraries for testing, settings files.
I've used Sinatra for small projects like Irclogger (http://www.irclogger.com http://www.irclogger.com) (http://www.github.com/cschneid/irclogger http://www.github.com/cschneid/irclogger). You can take a look at the code and see how simple it is underneath. I've also used Sinatra for larger projects involving many files, user login and authentication, database access, and more.
What you'll find when you're writing Sinatra is that almost nothing is provided in the way of helpers, but also that you won't miss them. You write your own helpers where you want, and use normal rubygems to provide other functionality. It's not really a web framework's role to render JSON when there's a perfectly normal JSON gem that does it well. On the other hand, various people have recreated the small helpful stuff in reusable forms, including fairly simple things like partial rendering, up to reverse URL lookup (like Rails provides person_edit_path(), etc).
I'm not sure what the other commenter is talking about with bloated memory footprint for Sinatra, it's a fairly minimal piece of Ruby code, and any memory bloat will be the fault of your code, and not the framework itself. A hello world app in Sinatra takes about 10 megs of ram to get up and running (under Thin in my case). Rails takes about 40 last time I checked. Everything from there is related to your app (be careful with ActiveRecord, it'll chew through ram).
To sum up: Sinatra is a do it yourself framework toolkit. It doesn't provide much beyond making it easy to build your own helpers and your own application specific code. If you need help or advice, swing by #sinatra on freenode.org. People are always around to help.
- 1gor 17y agobe careful with ActiveRecord What alternative ORM would you recommend that is mature enough?
- cschneid 17y agoIt really depends on your needs. My comment was in regards to the memory footprint. There was an Engineyard blog post about that recently. Basically if you do some non-obvious things, you can just explode out the size of ram, and because of how ruby works, it'll never get given back to the OS. Edit: http://www.engineyard.com/blog/2009/thats-not-a-memory-leak-its-bloat/ http://www.engineyard.com/blog/2009/thats-not-a-memory-leak-...
- mikeryan 17y agoPoor use of an ORM (or pretty much any robust full-featured library) has its risks. I'm not sure how you provide features that AR includes without putting your memory at risk of overuse. Model.find(:all) is going to be problematic across the board, there will always be a risk when you start playing with things like including children (there's a great benefit as well). You need to know what you're doing with any ORM.
- trevorturk 17y agoI've heard good things about sequel, but have never used it personally: http://sequel.rubyforge.org/ http://sequel.rubyforge.org/
- chasingsparks 17y agoI use Sequel when I am doing projects in Sinatra. It's elegant.
- jhancock 17y agoThe sequel approach is unique. I worked with it a year or so ago and was happy.
- cscotta 17y agoDatamapper (http://www.datamapper.org http://www.datamapper.org) is a great alternative as well. It's not as full-featured as ActiveRecord, but then it's also not nearly as heavy!
- jhancock 17y agoWhat is your opinion on Sinatra's support community? I keep peeking at Sinatra for my new app. I have a Merb app in production and working on a new one. My new app has characteristics quite different than my old one but I still get to borrow my education from Merb. Unfortunately, Merb's google group is a ghost town these days. I worry this is going to get worse and have no interest in counting on Rails 3 being useful to me in the next year.
- matthewcford 17y agoSinatra is a great micro framework for when you don't need the whole Rails stack, I used it for building http://tweetarium.com http://tweetarium.com along with tokyo cabinet.