Not logged in (Log in or Sign up)

unwwwritten

The chairman of the bored

I bore easily.

When doing something like watching TV, I tend to either channel surf, or hack, or program, or even read a book.

So, when a (relatively) new technology that I have little or no exposure to seems to solve a problem that I have... I am drawn to it.

In this case, I'm talking about sinatra.

Rails seemed to be serious overkill for one of my small side-projects, so I'm playing again.

My first impression of sinatra is that it is pretty sweet for a small application.

How easy is this?

   1  require 'sinatra'
   2  
   3  get '/' do
   4    'Hello world!'
   5  end

It feels a bit clunky without the helpers that make forms easier to work with in Rails, but that may just be my inexperience.

In the process of playing with sinatra, I'm also playing with haml - instead of using erb. I think I'll be using haml for more projects.

   1  !!! XML
   2  !!! Strict
   3  %html
   4    %head
   5      %title Hello
   6    %body
   7      %h1 Hello
   8      %p Hello world!

Lastly, as a side effect of using sinatra, I'm working with rack. My first impression? It seems to solve the problem of how to run your web applications - regardless of the framework. It's consistent and simple.

   1  $0 = File.expand_path(File.dirname(__FILE__)+'/main.rb')
   2  require $0
   3  
   4  set_options :run => false
   5  
   6  run Sinatra.application

One small note about the config.ru show above... I set $0 explicitly so that sinatra can find its public and views folders. Hopefully a future version of sinatra will address this (the problem is that $0 is /usr/bin/ruby in some hosting environments, so sinatra looks in /usr/bin/public for static entities and /usr/bin/views for the templates... not quite right, eh?).

More later.

Cheers.

blog comments powered by Disqus