When I started learning Merb and DataMapper I kept a collection of notes to help me keep up with these projects. These grew to the point that they couldn't fit nicely into a single text file. With contributions from others I started to put together a small book on developing web apps with Merb and DataMapper. I have decided to release it as we go. There is also a project in GitHub if you want to check it out and contribute.
So here we go (corrections and comments welcome):
Life On The Edge With Merb, DataMapper & RSpec
What's Merb, DataMapper & RSpec?
If you're not living on the edge, you're taking up too much room. - Alice Bartlett
Merb, DataMapper and RSpec are all open source projects, which can be used for building kick-ass web applications. They are all in active development and it can be hard to keep up, but we'll try our best to keep up to date.
It's a relatively new framework (a bit like Ruby on Rails) and was created by Ezra Zygmuntowicz. Merb stands for Mongrel + ERB although now it supports the rack webserver interface so it can user any web server that has rack support (Mongrel, Thin, ebb, etc).
If you know Ruby and have used Rails you're likely to get the hang of Merb quite easily. Noticeable differences from Merb to Rails are, it's stance on being less opinionated and it's approach to modularisation.
Merb is actually made up of a number of gems:
merb-plugins. This is so you can pick and choose the functionality you need. The
merb gem installs both
merb-more so you can get started straight away. The benefit of modularity is it's kept simple with additional functionality provided by gems.
merb-core alone can be used as an upload server, to provide an API or to create a simple web app (a la camping) where the functionality of a fully fledged framework isn't necessary.
DataMapper is an Object-Relational Mapper (ORM) written in Ruby, by Sam Smoot. It's what we'll be using with Merb. It's possible to use the same ORM as Rails (ActiveRecord), but as there are plenty of examples of using ActiveRecord already I've chosen to use DataMapper.
It has some nice features which makes it faster than ActiveRecord in some cases. What really stands out for me is the way it handles database attributes. The schema, migrations and attributes are all defined in one place: your model. So you no longer have to look around in your database or other files to see what is defined.
DataMapper has some similarities with ActiveRecord. We will be highlighting the differences as we go along.
RSpec is a Behaviour Driven Development framework for Ruby.
Merb currently supports the Test::Unit and RSpec testing frameworks. As the specs for Merb and Datamapper are written in RSpec, we will be covering some aspects of RSpec but it will not be our main focus.
What About Ruby On Rails?
Merb is Harder, Better, Faster, Stronger, to quote Daft Punk - Max Williams
So what's the big deal? We have Ruby on Rails and that's enough, isn't it? There is little doubt that Ruby on Rails has rocked the web application development world. You have to give credit where credit's due, but it can be unforgiving if you don't want to do things 'the Rails way'.
Merb also has super-fast routing and is thread-safe (If performant were a word, Merb would be it). The core functionality is kept separate from the other plugins and it uses less Ruby 'magic', which makes it easy to understand and hack.
Rails (and consequently Ruby) has received a lot of criticism for not being suitable for large scale web applications, which isn't necessarily true and Merb has been built from the outset to prove that Ruby is a viable language for building fast and scaleable web applications.
At the end of the day it's about choice. There are many new Ruby frameworks springing up, undoubtedly helped by the success of Rails, but in my opinion Merb shows the most promise as a Rails competitor.
If you'd like to take a look at some other frameworks these links should get you started:
So that's it for now, stay tuned for how to install/set-up merb and datamapper next...