Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Sinatra 1.0 Released: Major Milestone for Ruby’s Best Webapp DSL

By Peter Cooper / March 23, 2010

In November 2007, we casually mentioned a new Ruby webapp library called Sinatra. It took a year to capture the imagination of the Ruby community as a whole and we eventually covered it in more depth but today we're proud to (exclusively) announce that Sinatra has today reached its landmark 1.0 release!

Impromptu release party in the official #sinatra channel on irc.freenode.net, anyone? :-)

Sinatra is well known in the Ruby community for providing developers with a simple way to put together Web apps big and small. The canonical ultra-simple example:

require 'rubygems'
require 'sinatra'

get '/hi' do
  "Hello World!"
end

Sinatra's lead developers — Ryan Tomayko, Simon Rozet, and Blake Mizerany — have done a great job, along with about 50 other contributors, to produce a slick and powerful Web application DSL for Rubyists. Their ideas have even inspired similar frameworks in other languages (such as Sammy in JavaScript). Satish Talim put together a great piece, 20+ Rubyists are using Sinatra - Do you?, last year that got a good feel for how Sinatra's being used for Web apps both big and small by a collection of Rubyists.

What's New?

As an avid user of Sinatra 0.9, I asked Blake Mizerany what the biggest changes were going to 1.0:

I think the biggest changes are what we cleaned up. Tilt is a great new under-the-hood addition. Sinatra has matured; we're done messing around. It's super solid. The extension API has matured to something really killer. Extensions are ridiculously simple to create now - you can easily install helper methods, DSL methods, and install new routes on apps, and the user need only require 'sinatra/your-extension' - that's it.

Unsurprisingly, the official changelog also provides useful information to existing Sinatra developers.

A more significant longer-term change for Sinatra over the past year has been in how it integrates with Rack. In Sinatra Rack And Middleware, Ben Schwarz looks at how Sinatra interacts with Rack and how you can use Rack's middleware and multi-application features with Sinatra. A key aspect of this is the ability to produce "modular" Sinatra applications by subclassing Sinatra::Base to separate discrete applications or application portions:

require 'rubygems'
require 'sinatra/base'

class MyApp < Sinatra::Base
  get '/' do
    "Hello world!"
  end
end

And then, in a Rackup file:

require 'my_app'
run MyApp

Installing and Trying Sinatra

If you're not yet using Sinatra and want to give it a quick try, you can install it with RubyGems:

gem install sinatra

Put the following basic example into a file, say example.rb:

require 'rubygems'
require 'sinatra'

get '/hi' do
  "Hello World!"
end

Then run the Ruby file in the usual way, and a request to http://localhost:4567/hi should get you a "Hello World!" response.

Learn More Online and on IRC

The examples shown above are as basic as Sinatra gets, but it goes a lot deeper than that (such as embedding Sinatra apps inside Rails apps) and the Sinatra Web site has some great code examples of where you can go next. There's also solid documentation available and if you want to take a look at lots of existing Sinatra projects to get a feel for the patterns and techniques involved, there's a great list of Sinatra apps and extensions too.

Lastly, if you're interested in asking questions about Sinatra or just hanging out with Sinatra's developers and users, head along to the #sinatra channel on irc.freenode.net. There's usually between 50-100 people hanging out there.

Comments

  1. nap says:

    Congrats to the entire team! Sinatra is truly a piece of work (I mean that in a good way).

  2. Aslak Hellesøy says:

    Sinatra is art. Thanks for the hard work!

  3. Thibaut Barrère says:

    Thanks for the hard-work on Sinatra - it's currently my favorite web framework!

  4. Ade says:

    Congratulations to the Sinatra developers! I absolutely love Sinatra. It's a joy to work with. If you haven't tried it, you really ought to.

  5. Marc Chung says:

    Sinatra is an amazing piece of software. Thank you for all your hard work.

  6. Jay says:

    Congrats to Sinatra team on their major milestone. Its simple and very addictive.

  7. André says:

    I usually don't comment on blogs, but Sinatra truly rocks. Congrats to its developers.

  8. Kuroi Kenshi says:

    Sinitra kicks major ass! Can't live w/out it.

  9. Juanjo says:

    For the "inspired in Sinatra" list, from the Perl world:

    - http://perldancer.org/
    - http://mojolicious.org/ (well, Mojolicius::Lite though)

    I've used those two, and are great. We must thank Sinatra for the inspiration!

  10. Nico says:

    Congratulations, Sinatra is a great framework!

  11. Maurice says:

    Sinatra is a rare blend of ridiculously useful and practical code poetry. Kudos for the team and contributors!

  12. Jonty Davis says:

    Just a note to say the documentation still says version 1.0 not yet out!

  13. Jonty Davis says:

    Oh and another so I don't seem churlish! Thanks a bunch for great work - I am awed by the simplicity

  14. Sohan says:

    Your post is linked at the drink rails link blog

  15. roger says:

    wow those perl frameworks "inspired by Sinatra" actually look good. Way to go Sinatra!

  16. Satish Talim says:

    To celebrate this milestone, we at RubyLearning announced a free, online "Introduction to Sinatra" course from 15t May, sponsored by 1stEasy.com. The course filled-up in 6 hours. Hopefully we shall do a repeat batch soon, provided we get a sponsor.

Other Posts to Enjoy

Twitter Mentions