Wednesday, July 25, 2012

Sinatra pitfalls


I recently got interested in Sinatra as a way to create simple web applications quickly. Sinatra allows for one file web applications and it's like ruby's answer to PHP.

But I ran into a few pitfalls that aren't well documented in the Sinatra website or in the O'Reilly book (Sinatra: Up and Running).

Pitfalls:
* an explicit return quits the Sinatra app.
* the render command must be the last thing on the block or it might not work.
* the thin gem is not yet supported on Windows.

Additionally while the Sinatra website really pushes haml as a viable format, I found it kind of useless. While HTML can be easily copy and pasted (and debugged) haml just seems to add complications to it unless your familiar with it. That is haml has a very steep learning curve before you reap any benefits while HTML is totally linear. The more you learn the more you can use.

While this is similar to the criticism coffeescript gets, JavaScript's learning curve is not linear like HTML's. And coffeescript's is easier to learn that JavaScript. Which is why I keep saying that the number one feature of coffeescript is for teaching people JavaScript. Unfortunately all the coffeescript books assume fairly advanced JavaScript knowledge.

So:
Additional Pitfall:
* using haml, at all. Stick to HTML and erb.