News for hackers. Stuff that matters.
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by adriand on Tuesday March 23, 2010 @06:12PM (#1214216)
If you haven't tried Sinatra, you really ought to. It's a joy to work with. If you're accustomed to using Rails, using Sinatra brings back the enjoyable feeling of being closer to the code, closer to the HTTP protocol itself, and free of the many conventions and the complex file structure that comes with Rails.

I especially recommend it for when you want to hack up something small, useful and lightning quick. Rails is great, but sometimes it starts to feel like a very large hammer, when many web app ideas start out as small nails. Sinatra is a nailgun.

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by jackowayed on Tuesday March 23, 2010 @06:27PM (#1214251)
I really wish Sinatra were more practical for big projects. It's so much more pleasant to work with, but between the speed advantage that Rails gives for doing a lot of the normal big-app tasks and all the plugins, it seems like Rails is too good for most big apps to make Sinatra a reasonable choice.

I guess if you were doing something very weird, where Rails would really get in the way, it might make sense. And I've seen it end up being a piece of big apps, just not the main web interface.

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by grandalf on Tuesday March 23, 2010 @06:49PM (#1214300)
I like it for big apps precisely because of all the stuff that doesn't end up in the app.

I have found that I can write 10-20 lines of code and replace just about any plugin, and that makes the app far less complex, particularly when you think of how messy and undisciplined many rails plugins are.

I realized that rails offers the biggest benefit if your site uses TONS of forms. It's really not that big a deal to write a few forms by hand, and it makes using client side validation easier and cleaner.

I also love datamapper.

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by donw on Tuesday March 23, 2010 @11:08PM (#1214826)
My Rails app is very likely to be moved on to Sinatra, specifically for this reason. Sinatra's codebase is really only about 1600 lines of Ruby, so it's very easy to understand, and very easy to extend, and it's threadsafe.

There just aren't that many moving parts, so there's very little that can go wrong, and there's no hidden magic, which is what has been making my life hell in the Rails 3 beta.

Also, Sinatra is fast. I just did a quick benchmark (ab -n 1000 -c 5 -k) on my laptop, and the scores were impressive. In the same rackup server, a bare Rack app did 4932 req/sec, Sinatra did 3169 req/sec, and the Rails 3 beta managed... 214 req/sec.

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by cschneid on Tuesday March 23, 2010 @07:02PM (#1214328)
May I suggest Monk, which is built on top of Sinatra, and provides a nice basis to organize your code.
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by jackowayed on Tuesday March 23, 2010 @07:11PM (#1214353)
That's pretty cool. I could see using the dm skeleton for something pretty big.

Here's the link for the lazy: http://monkrb.com/

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by thibaut_barrere on Tuesday March 23, 2010 @06:31PM (#1214259)
I'm using it exactly for something weird where Rails get in the way - it's truely useful.
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by lg on Tuesday March 23, 2010 @07:23PM (#1214376)
I tried Sinatra after I read RailsSpace and thought, man, I will probably never need most of this, though I'm glad it's around in case I do. I think of Sinatra as a layer on Rack that can do views and things, and that plus plain ruby gets me far enough on the server side. I usually like to use files for storage when I can get away with it anyway (yeah warning not scaleable warning). The online Sinatra book is great too, it had answers to all of my early questions.
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by bonaldi on Tuesday March 23, 2010 @08:24PM (#1214499)
Sinatra has that "secret weapon" feeling about it. While everyone else is bogged down trying to steer their massive lumbering frameworks around, you're whizzing past in a sporty two-seater that goes exactly where you want.

To me, it feels exactly like web programming should -- and it does so in a way that makes a lot of sense; it builds on the whole Ruby thing of "how do I do this? I wonder if _this_ will work? Ho! It did!"

If you haven't looked at it yet, it is _well_ worth your time.

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by n8agrin on Tuesday March 23, 2010 @07:03PM (#1214330)
A few people have already commented that Sinatra is great for quick small projects. One person has mentioned that they prefer it for larger projects. My knee-jerk reaction to Sinatra for the last year has been that it would be fun for building small apps as well, which got me thinking:

Why wouldn't it be good for large projects?

After reading the current docs, I really don't have a good answer to this question. Anyone have any opinions or thoughts? I know Rails gives you a ton out of the box (for example, 304 etag caching) but how hard could it be to implement that stuff as necessary? More and more I find myself focusing on HTTP as the actionable interface to my model and less as simply an HTML delivery protocol.

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by petercooper on Tuesday March 23, 2010 @07:10PM (#1214350)
Why wouldn't it be good for large projects?

It is for some, but it doesn't provide enough structure and opinion for some people. With Sinatra, you either need to come up with and fully grok your own structure (always a good thing, IMHO) or a myriad of plugins and middlewares.

Sinatra vs Rails is like a house with one big empty space vs a house with predefined rooms ready to decorate. With Sinatra, you need to be much more of an "architect" than you need to be with Rails. I'd much rather define my own walls and internal structures and Sinatra lets me do that more easily than Rails does.

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by adriand on Tuesday March 23, 2010 @08:08PM (#1214472)
> With Sinatra, you either need to come up with and fully grok your own structure (always a good thing, IMHO) or a myriad of plugins and middlewares.

This is a good assessment. If it's a big project with a lot of CRUD on a large variety of models in a complex database, by the time you'd added all the stuff to Sinatra that would be useful, you'd have recreated Rails.

You could still very much use Sinatra for a large project, but it would be best for a large project that is not a standard CRUD- and form-heavy web app. For example, if you wanted to build, say, an online video encoding service.

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by jamesbritt on Wednesday March 24, 2010 @07:19PM (#1217174)
"Sinatra vs Rails is like a house with one big empty space vs a house with predefined rooms ready to decorate. With Sinatra, you need to be much more of an "architect" than you need to be with Rails. "

That's why Ramaze has hit the sweet spot for me. Hyper-fast and feature complete.

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by bmizerany on Tuesday March 23, 2010 @07:58PM (#1214448)
Sinatra has had etag support for years; longer than Rails (http://bit.ly/9rBLut now http://bit.ly/d3ir1T). Sinatra is well suited for large apps. I suggest using it for them. :)
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by n8agrin on Tuesday March 23, 2010 @08:32PM (#1214510)
Awesome and thank you for the relevant links!
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by wheels on Tuesday March 23, 2010 @09:01PM (#1214576)
Why do Rubyists insist on overusing the phrase "DSL" so much? Sinatra isn't a domain specific language, it's just a quirky usage of Ruby syntax to make it more natural to set up routes for a web app. Haml is a DSL; Sinatra is not.
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by AndrewO on Tuesday March 23, 2010 @09:21PM (#1214628)
Haml is an external DSL. Sinatra is an internal DSL. Rubyists insist on using the term so much because Ruby's linguistic flexibility makes it easy to define them, so they're constantly doing it.

Martin Fowler is often credited with coming up with the distinction between the two. The concept is similar to a "fluent interface" from a different point of view.

http://martinfowler.com/articles/languageWorkbench.html#Inte...

http://martinfowler.com/dslwip/InternalOverview.html

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by wheels on Tuesday March 23, 2010 @09:37PM (#1214662)
Ok, so the answer is, "because Rubyists have redefined that phrase"? ;-)

The sweetening of the syntax in Sinatra seems to be rather straightforward. I assume it's something like:

  # internal route stuff

  @routes = {}

  def get(method, &block)
    @routes[method] = block
  end

  # user provided code

  get 'foo' do
    puts 'foo'
  end

  # something hooked up to execute at the end of the file

  while input = gets.chomp
    @routes[input].call if @routes.include? input
  end
I find it really hard to call that a language – it's just a clever use of normal Ruby syntax.
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by AndrewO on Tuesday March 23, 2010 @09:59PM (#1214702)

  Ok, so the answer is, "because Rubyists have redefined that phrase"? ;-)
Well, by name dropping I was hoping to avoid the appearance of that. :-) Fowler certainly writes about Ruby a lot, but I'd hope he's perceived as general enough to not just be a "Rubyist" (I don't know what he primarily uses). But he also points out that Lisp is a perfectly good host environment for internal DSLs (he calls it the "doyen of internal DSL thinking").

And I also brought up the "fluent interface" thing to suggest that you could call it that if it made you happier. For my tastes, I'm fine with the idea that a "language" reuses a more general purpose language's interpreter and libraries. YMMV.

  I assume it's something like:...
http://github.com/bmizerany/sinatra/blob/work/lib/sinatra/ba...

Sure looks similar, but as you can see from all the code above the method there's a lot more going on. But hey, at least they didn't need to write a parser. ;-)

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by ubernostrum on Tuesday March 23, 2010 @10:27PM (#1214750)
There's a humorous SGML FAQ from many years ago (http://www.flightlab.com/~joe/sgml/faq-not.txt) which includes a table explaining how web designers use SGML terminology. In essence, everything -- "element", "attribute", entity", etc. -- just maps to "tag".

Some of the more enthusiastic new people to Ruby seem to do the same thing, only with everything -- "function", "class", "module", "library", etc. -- mapping to "DSL".

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by cpg on Wednesday March 24, 2010 @12:39AM (#1214981)
Congrats!

We have been using Sinatra for our installer at Amahi (http://www.amahi.org) and it has performed well with a couple of caveats.

1) Things can get messy quickly if one is not careful to impose and keep on having structure. It's hard to read what's going on very easily.

2) They released 0.9.5 which produced crashes in ruby (!) and this bit us hard. This is really a bit of a ding on how gems are packaged and distributed. We tried to package is as an RPM (Amahi is Fedora-based) and it was harder than other (bigger) gems due to some things we could not figure out quick enough. I really like it, however, the community did not really help much in getting to the bottom of this, probably because it's still a bit small, I guess. No question that it will grow. :)

3) (ok more than a couple, though this one may not be a Sinatra issue). We rely on periodic http calls to get our installer progress shown on the browser (via jQuery). Some times one http call breaks (to localhost no network involved!) and we have not been able to figure out why. We believe we have mostly eliminated jQuery, leaving Sinatra as the main suspect. Maybe we have another bug in there we're hitting? It's not too repeatable, sadly.

Congrats on the 1.0 release!!

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by ctrager on Tuesday March 23, 2010 @06:23PM (#1214243)
I use Sinatra running at Heroku for my Hacker News Android app, for the screen scraping part, the part that scrapes pages just like this one. Both are easy and fun.
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by tibbon on Tuesday March 23, 2010 @08:44PM (#1214545)
I've been using Sinatra for a while and loving it. So much easier to understand your code than Rails imho.

However I have one question- is there much to making it scale? Not in a Twitter-like way, but I know there are a ton of books and documentation on making Rails work for larger sites. Does Sinatra hold up ok?

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by jackowayed on Tuesday March 23, 2010 @10:43PM (#1214784)
I think it would be pretty simple and basically the same principle as for Rails. You could just have several machines with Passenger (or whatever) running your app on each and stick a load balancer in front of them. (Disclaimer: I've never actually scaled things, but it sounds like that's more-or-less how it's done.)

Really, the hard part almost always ends up being scaling your database. And since Sinatra isn't super-glued to ActiveRecord (though Rails3 fixes that), it would be easier to use whatever NoSQL-type thing you wanted if you got to the point of needing to operate on a huge scale.

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by dhotson on Tuesday March 23, 2010 @10:52PM (#1214803)
I believe you can scale it in much the same way you scale other Ruby frameworks... fire up a bunch of Thin webserver's and reverse proxy with varnish or nginx.
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by mark_l_watson on Tuesday March 23, 2010 @06:07PM (#1214197)
Great news! I usually use Rails for medium and medium-large projects but I like to use Sinatra for small web apps and web services. Sinatra seems like a better fit also if you want to use JRuby on AppEngine (at least for now).
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by grandalf on Tuesday March 23, 2010 @06:53PM (#1214307)
don't forget python on app engine. the google webapp framework is very much like a verbose version of sinatra.
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by cannabis_sam on Wednesday March 24, 2010 @10:12AM (#1215706)
Or you could run Bottle: http://bottle.paws.de/

It's the closest thing to sinatra I've found written in python. (It might need some maturing though)

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by simonw on Tuesday March 23, 2010 @07:24PM (#1214380)
I'm really not a fan of the webapp framework. Like you said, it's quite verbose - but more importantly, it runs out of steam very quickly - the moment you need to do anything useful with cookies, for example.
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by csytan on Tuesday March 23, 2010 @08:18PM (#1214488)
I'd try tornado then. It has class based handlers, runs great on appengine, a very nice templating language, XSRF protection, secure cookies, and more.

http://www.tornadoweb.org/

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by grandalf on Tuesday March 23, 2010 @07:27PM (#1214390)
hmm, like what? I've used cookies extensively with it.
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by simonw on Wednesday March 24, 2010 @09:13AM (#1215576)
How did you do it? Did you have to construct your Set-Cookie header by hand, or is there an API for that now?
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by grandalf on Thursday March 25, 2010 @12:19PM (#1218716)
check out the appengine_utilities code on google code... it has some useful stuff in it.
Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by nileshtrivedi on Wednesday March 24, 2010 @02:45AM (#1215140)
Congrats to the Sinatra team!

I have used sinatra in a bunch of projects ( http://brandpeek.com is one example) and it's a delightful little framework.

Re:Sinatra 1.0 Released: Major Milestone for Ruby’s Best Web... by frankus on Tuesday March 23, 2010 @08:59PM (#1214567)
I'm using it as the back-end for an iPhone app on top of Amazon SimpleDB. It's perfect for building little REST APIs.