Please Welcome ... Sinatra

This blog is all about using Sinatra, so I thought it might be useful to start off by explaining what Sinatra is and what it isn’t.

What Sinatra Is

From the Sinatra website:

Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort:

But what on Earth is a DSL? Well, it stands for Domain Specific Language. This basically means that it has been designed for one particular function, in this case, creating web applications in Ruby.

Ruby is simple but powerful object orientated programming language. It has an elegant syntax allowing you to do some powerful things with small amounts of code. In fact, Sinatra itself is written in Ruby.

A Sinatra application is basically made up of one or more Ruby files. Don’t worry if you don’t know how to program in Ruby. You don’t need to be an expert Rubyist to use Sinatra, but the more Ruby you know the better you will be at Sinatra. On the flip side, learning Sinatra and studying other people’s code will definitely help to improve your Ruby skills. If you don’t know any Ruby at all there is a free online book that will help get you started.

Sinatra is used to develop server side code for websites and is similar to ASP,PHP and Ruby on Rails. It probably has the most similarities with Ruby on Rails, since they both use Ruby. It can easily be connected to a database backend to create dynamic and interactive web applications that store data.

Sinatra was designed and developed by Blake Mizerany, but now has a team of people working on the code over at github. And yes, in case you were wondering, it is named after Frank Sinatra, apparently because he had “so much class he deserves a web-framework named after him.”

What Sinatra Is Not

Sinatra is not programming language. As I mentioned above, you use the Ruby Programming language to write Sinatra applications. Basically Sinatra lets you use Ruby code on the web.

Sinatra is not a framework like Ruby on Rails. A framework does a lot more for you than Sinatra does. In some ways this makes using a framework easier, but it also means that a framework will include lots of code that you don’t actually need. Frameworks can also be very opinionated because they make you do things in a certain way and use particular programs. Sinatra has not such limits. Again, this can be both good and bad.

Sinatra is not a Content Management System or blogging engine like Drupal or Wordpress. You can write any type of application you can think of using Sinatra and publish on the web. Of course, you could use Sinatra to create a Content Management System, which is exactly what I plan to do for one of my later projects.

Sinatra is not bloated. The code for Sinatra is tiny (only about 1500 lines of code), meaning that it doesn’t include any wasted features and takes up hardly any memory.

Why Is Sinatra So Cool?

Basically because of its simplicity. You can create a fully functional web app in just one file. There are no complicated set up procedures or configuration to worry about you can just get going with minimal effort. It’s also very lightweight - there is not much in the way of wasted code - basically there is enough to get you going and not much more.

Developing in Sinatra is quick and easy. Its syntax is simple to pick up yet very powerful. Sinatra doesn’t tie you to doing things in a certain way like many frameworks. You can do things your way (unintended pun), making it ultra-flexible.

So, I hope I’ve helped to explain what Sinatra is and I really hope that I’ve got you itching to start using it. The next blog post will go through how to install Sinatra and then we’ll move on to creating a basic web app with Sinatra.

blog comments powered by Disqus