Carlos Gabaldon: How do I learn and master Sinatra?

Welcome to the eight installment on the RL blog, of a mini series – “How do I learn and master Sinatra?” – by top Rubyists using Sinatra. The interview series will provide insight and commentary from these notable Sinatra developers, with the goal of facilitating and providing answers to the questions Ruby beginners face on how to learn and master Sinatra.

Satish>> Carlos Gabaldon, could you tell us something about yourself – your background, where you are based?

Gabaldon Carlos Gabaldon>> I’m Carlos Gabaldon. I have been in software development for over 10 years. I am currently working as a software architect for the Apollo Group, Inc. I am based in Chandler, AZ. I have experience in multiple languages and platforms: C, C++, C#, Java, Small Talk, Lisp, Erlang, Ruby, Objective-C, Python, and PHP on Linux, FreeBSD, and Windows.

Satish>> Are there any pre-requisites for a person to start learning Sinatra?

Carlos>> A basic understanding of Ruby and HTTP are very helpful. Since Sinatra is essentially a DSL on top of Rack, which is just an abstraction layer for dealing with HTTP, understanding Ruby’s implementation of blocks, closures, and hashes will make working with Sinatra a little more straight forward.

Satish>> How should one start learning Sinatra?

Carlos>> The best way to learn is to download the latest version of Sinatra and read the documentation to get your first app running. The docs are great way to start learning. After you have gone through all the examples, I suggest building your sample application, that will allow you to explore all the various aspects of Sinatra. By building a blog or some type of social web app it will force you to learn how to do things like authentication, authorization, session management, and database interaction. Also, spelunking the source code on GitHub is a great way to learn the internals.

Sinatra – quickly create tiny web apps and services

Satish>> Which area of Sinatra should a beginner pay particular attention to?

Carlos>> For a beginner I would suggest focusing on understanding Routes, Handlers, Views, Helpers, Authentication, and Models. These are the core things required to build most basic web applications.

Satish>> Is the official documentation on Sinatra good enough for a beginner? Are there areas which need improvement or need to be re-written

Carlos>> The official docs are great for a beginner to learn Sinatra. The Sinatra book looks very promising once it is complete, it just needs more people like myself contributing to the completion.

Satish>> Sequel, DataMapper, ActiveRecord – which one would you recommend to use with Sinatra and why?

Carlos>> It depends on your background. If you are coming to Sinatra from the Rails community you will most likely be more comfortable with ActiveRecord; like wise if you are coming from Merb you will be more familiar with DataMapper, since it is used pretty heavily in that community. For basic little web applications I think any of the above ORM’s are great. I personally really like Sequel and DataMapper since they give you much more control over your table and object mappings as well as your custom SQL. ActiveRecord abstracts to much of the SQL for my tastes which makes optimization of SQL queries very difficult. If someone plans to build a high performance web site using Sinatra or any other web framework I would recommend against using any ORM – you want to have a lot of control over your SQL, you do not want the join queries being generated by an ORM.


Satish>> Is an understanding of Rack important while learning Sinatra? Why? Which area of Rack should one be really comfortable with?

Carlos>> I do not feel an understanding of Rack is important for someone learning Sinatra. Once you have a solid understanding of Sinatra, then learning Rack will help one with building middleware.

Satish>> How should one hone one’s skills in Sinatra?

Carlos>> Build a lot of different types of web apps, learn Ruby, study Sinatra’s source code, and read great sites like yours.

Satish>> What type of projects should a beginner work on to gain more expertise in Sinatra?

Carlos>> Blogs, Community Sites, really anything.

Satish>> Could you suggest some web services that a Sinatra beginner could develop himself / herself?

Carlos>> I would suggest building social integration type services on top of the Twitter or Facebook api’s. There is a lot of great open web service api’s out there to some great communities, building services that can integrate various communities is always cool.

Satish>> Anything else you would like to add?

Carlos>> Sinatra is a great Ruby DSL which makes it a lot of fun to build cool web applications. But this is possible, because Ruby is a great language for building DSL’s and Rack makes it easy to build web frameworks. I suggest that mastering Ruby and learning more about Rack are the next steps after getting comfortable with Sinatra.

Thank you Carlos. In case you have any queries and/or questions, kindly post your questions here (as comments to this blog post) and Carlos would be glad to answer.

Others in this series:

Post supported by 1st Easy Limited: UK based 1st Easy Limited offer Sinatra and Rails hosting running on a Phusion Passenger (mod_rails) and LAMP stack. If you want to try your hand at developing with Sinatra, why not let them arrange a trial hosting account for you? You’ll get to deploy your app, with full technical support from their team!

comments powered by Disqus