A Lagom Review of O’Reilly’s ‘Sinatra Up and Running’
Sinatra Up and Running is a new book published by O'Reilly and written by Alan Harris and Konstantin Hasse that covers the popular Sinatra web application DSL in a brisk 103 pages, acting as a tutorial to newcomers and a handy reference for old hands.
TLDR: It's a short, sweet, relatively cheap and very well written book about Sinatra. Recommended. Buy here.
An interesting quirk of Scandinavian society is the concept of Jante Law. It knocks down standing out and being individual, in favor of communal harmony. It's typically used in a negative context to lament restrictions and lack of risk taking within Nordic society (DHH touched on this briefly in a recent Mixergy interview) but the flip side of the Jante coin is lagom: the idea and ideal of having just the right amount of something.
Sinatra Up and Running is, second to K&R, the most lagom technical book I've read. At a mere 102 pages you may wonder whether it's worth buying - it is. Unlike most technical books - yes, including mine - it skips the waffle and provides a perfect level of detail going through from what Sinatra is, to how it works, and on to an example project that covers just 13 pages. Don't be fooled, though, this isn't one of those tiny format O'Reilly handbooks; it's a regular, full size book - just a thin one!
The book is split into three key sections:
- Sinatra's "fundamentals." We cover similar ground to the Sinatra README but I prefer the less generic examples in the book. How to build routes, use views, use sessions, caching, HTTP headers, and even Sinatra 1.3's new streaming functionality.
- Behind the curtain. The bulk of the book takes a peak under the kimono into areas where online documentation occasionally trips over or fails to mention. How is Sinatra implemented and what is its basic execution model? How do you create extensions for it? How does it integrate with Rack middleware? And how can you use Sinatra in a modular style?
- Blog engine project. A snappy run through a simple Git and Sinatra powered 'blogging' system.
As a core piece of printed documentation for a project, the book does a great job at sharing the basics, inspiring you to dig further and, of course, its short length puts Sinatra into context with the gargantuan Rails framework, where even a 400 page book would struggle to cover the essentials.
So, should you buy it?
Sinatra Up and Running is a good book and well written. I enjoyed it and picked up or was reminded of quite a few interesting bits and pieces. I'll probably refer to it from time to time. If your Sinatra experiences are rather on and off or you've not played with it for a while, it's a great, well-paced introduction.
If, however, you're already a Sinatra guru and/or working with Sinatra on a day by day basis and have all of the main patterns memorized, there's not a great deal you're going to get out of it. Buy it to be a completionist or to support the authors, but if you want a book demonstrating in depth how to integrate Sinatra with everything or how to big giant Web applications, this isn't for you.
Inexperienced Rubyists may also find the book's direct no-nonsense style intimidating. If you know what a code block is, you're good to go. This may seem like a bizarre observation to most Rubyists, but I've encountered many beginners who've wanted to "build a Web site" and immediately leapt into an advanced Rails book, only to be confused. If you're still new to Ruby, read The Well Grounded Rubyist or Beginning Ruby first.
And I'm going to stop here, because that would be lagom :-)
Where to buy
There are several options for buying the book. Check out O'Reilly (print, PDF, Mobi, and ePub), Amazon.com (print and Kindle), and Amazon.co.uk (print and Kindle) or your own favorite local bookstore.
December 14, 2011 at 9:58 pm
I wonder if Scandinavian people imported that Jante Law from Japan (Deru kugi wa utareru).
December 15, 2011 at 3:09 am
Couldn't have said it better myself! I really enjoyed this book.
December 15, 2011 at 8:42 am
What does Jante law have to do with a ruby book on Sinatra? Is it addressed in the book?
December 15, 2011 at 3:52 pm
I read this book and it's really great! But, in chapter 3, it's written that Sinatra::Application.new return an instance of Rack::MethodOverride, but it's returning an instance of Sinatra::ShowExceptions
I'm using MRI 1.9.2p290 and Sinatra 1.3.1
Anyone know what's causing this difference?
December 15, 2011 at 8:26 pm
Thank you for the heads up :) I immediately bought the book from O'Reilly, even though I’m probably not in the target audience.
December 16, 2011 at 10:48 am
This book is a simple peace of art :)
December 18, 2011 at 10:09 pm
@karatedog: Funny you should mention that: at a Japanese speakers meetup at Sydney last Friday, someone told the anecdote in China of a crowd of people watching an old lady drowning for five minutes, and an American tourist coming round the corner and immediately (after taking off his shirt) diving in to save her.
The narrator explained that none of the Chinese helped because doing something to help a person outside of their family would have been seen as suspicious, as if they were responsible for the lady drowning.
(It may have been an Uruguayan rather than someone from the USA who helped, though)
This article mentions an example where someone who helped was assumed to have caused the accident.
tl;dr: it may not just be a Scandinavian thing.