If you were to ask me, I’d say that Merb has caught the fancy of Rubyists around the world and it’s not just hype. Recently RL conducted a poll on new course offerings where 1000 Rubyists (from over 140 countries) voted. Over 30% requested for an Introductory course on Merb. RL’s Satish Talim caught up with Matt Aimonetti (a serious Ruby addict and Merb core team member) to learn more about Merb.
RL>> Welcome, Matt and thanks for taking out time to share your thoughts. For the benefit of the readers, could you tell us something about your self?
Matt>> Hi Satish, thank you for giving me the opportunity.
I wish I could tell you that I have been programming in lisp since I was 4. Unfortunately I can’t. However, I learnt English thanks to my dad who was an accountant and put his work computer in my bedroom. I believe the first English word I saw was: “ready”.
I’m 100% Mediterranean, born and raised in France with Italian, Spanish and North African roots. I have travelled a lot and lived in different countries. I’m now located in San Diego, CA where I live with my wife.
But I guess your readers are more interested in the “Ruby-esque” aspect of my life. I’m part of the Merb core team and have been a contributor to many Ruby open source projects, from Rails to DataMapper without forgetting a legion or gems and plugins more or less interesting/useful. I fell in love with Ruby when I evaluated Rails for a previous employer. Since then, I have setup my own consulting company offering development and training. I’m also leading a new project that I’m particularly fond of: The Merb Open Source Book. It’s pretty exciting to work with great people from all around the world. We all have the same passion; we have people who just started using Merb, some experts and some with editorial experience.
RL>> Recently, there has been a lot of talk about Merb. What’s Merb and why is it becoming so popular in the Ruby world?
Merb – Ruby web framework for the enterprise
Matt>> Merb is a Ruby framework to build web applications and web services. Merb started being developed in 2006.
Merb is getting popular inside and outside reasons because of some of these factors:
- Merb reached the 1.0 cap
- Merb has a guaranteed public API
- Merb is truly modular and agnostic
- Merb is fast and cares about performances
- Merb tries to be closer to the Ruby language
- Merb is new and different
- Merb has a different philosophy
- Merb learnt from Rails
Of course different people are attracted to Merb for different reasons. I have started a new interview series called Meet the Merbists. I hope to interview a lot of different people and let them explain why they like Merb.
RL>> If I wanted to learn and start using Merb, how do I do that? Can you talk about what all is being done for Merb in terms of documentation, books, tutorials and training?
Matt>> In all honesty, even though the Ruby community do a lot of things right, we really aren’t good at documentation. If you look at other languages like Python and other frameworks like Code Igniter or Django, you will see a different level of documentation. The good news is that we are aware of that problem and are working on it.
To answer your question, I would say that if you want to learn Merb, you need to start with Ruby. I heard a lot of good things about “Beginning Ruby” even though I have not read it. My personal favorite Ruby books are: “The Ruby Programming Language” and
“The Ruby Way“. You can also find a lot of great resources online.
Once you feel ready to start with Merb, you can look at a few things:
- The Merb Open Source Book: It’s available, though still a work in progress and being translated in 14 languages. It still needs a lot of work but it’s a good place to start.
- The Merb Wiki: We rewrote the wiki for Merb 1.0 and people keep on adding content daily (sample apps with code are available there).
- One of the Merb beta books: The Merb Way or Merb in Action (2 more books are coming out soon).
- Check the Merb documentation at http://merbivore.com/documentation.html and http://docsbeta.merbivore.com/.
- Blogs covering Merb: http://merbist.com/, http://yehudakatz.com/, http://www.merbunity.com/, http://www.merboverheard.com/ and many more.
- IRC: #merb on freenode.net
- Twitter: follow @merbist, @merbivore, @wycats and others. Feel free to ask questions.
- Peepcode: PDF and soon to be released screencast (rough cut available).
- Read the source code and check the public specs.
- Read the Merb internals guide by Michael Klishin.
- Watch the Merb Camp videos.
And on top of that you have the training sessions. RubyLearning.org has a great introduction to Merb class which is really affordable. My company, m|a agile offers a 3-day training given by Yehuda and myself. At the moment we only have classes scheduled in the USA, but if there are enough requests we might try to go overseas.
RL>> What are the advantages of Merb over similar web frameworks? Any drawbacks?
Matt>> It’s always a hard question to answer. I’m not going to try to convince people to switch to Merb if they are happy with the framework they use. Instead I will give you my personal and therefore a biased opinion.
People have different needs and different ways of approaching problems. Merb is strongly inspired by Rails but has a different approach on how the framework should work and how it relates to people. I believe this is the key difference between Merb and Rails.
During an interview for InfoQ.com, David Heinemeier Hansson the creator of Ruby on Rails said:
I’m not in this world to create Rails for you. I’m in this world to create Rails for me and if you happen to like that version of Rails that I’m creating for me, than you are going to have a great time. […] I don’t really care whether you use Rails or not. I think it’s great that we have critical mass, and I care about that; but I don’t care about you as a single individual customer.
It’s not a scoop. Rails is very opinionated and that’s why it’s so successful. Merb’s philosophy is different: let people choose and build around a solid and small core. Merb is built around 1 single gem called merb-core. merb-core is built around Rack to allow more flexibility, it has a powerful router and knows how to deal with requests/sessions. It’s up to the developer to build his own stack based on his needs. We offer some default settings to get you started:
- a very flat stack: 1 file app “A la Sinatra” (great for web services)
- a flat stack: keeps the logic in a single file, but has separate files for configuration and views (great for very simple apps)
- a core stack: MVC structure but without any dependencies or ORM setup. It’s up to you to define what you want to use (great for custom apps using couchdb, sequel, JRuby etc…)
- a full stack: MVC structure with DataMapper, merb auth, helpers, assets, mailer, cache, action-args, param-protection (Rich Web Applications)
You can always add or remove dependencies to your app making sure you only use what you need and keep your performance to the maximum. The reason is that Merb came to the world because some people were frustrated by some limitations in Rails. It was designed for performance and to fulfill the needs of various types of developers. Merb can be really opinionated but also knows it has to deal with really opinionated developers who might disagree. It’s therefore designed to let you design your own opinionated stack.
To sum-up: Merb is great when you need a custom solution and/or when you care about performance. It shines when dealing with legacy/custom/enterprise type applications or small and efficient systems like web services.
However, because it’s so flexible it requires you to know and understand the various moving parts. That’s why you might not get up and running as fast as with Rails.
RL>> We have so many Ruby based web frameworks. On what type of projects would you use Merb?
Matt>> That’s a very good question. As a consultant that’s something I’m being asked a lot.
Recently I’ve been involved with some projects where CouchDB seemed to be really the way to go because of the complexity of the architecture and the fact that Couch was offering a very elegant solution. I did not need a full-fledge ORM like ActiveRecord, DataMapper or Sequel and I didn’t feel like fighting with the framework to get it just the way I needed it. Merb was a perfect choice to adjust to the custom needs of this project.
Another project uses Merb slices (standalone apps which can be mounted in another app) for different reusable parts of the application. The slices can be customized and reused on various applications. The client saw that this had a real benefit.
Another project was getting 7-10 million requests per day. The first version of the application was written in Rails but we had to customize/optimize it so much that it was hard to support/maintain. We ended up rewriting the application with Merb (using ActiveRecord). We still had to optimize it to deal with the load but it was easier to just pick and choose what we needed. Being able to easily read the source code was also a great benefit.
Finally the merb-book is an excellent example of how to use merb without all the fluff. The book deals with different languages, including Arabic (right to left) and renders markdown content using maruku (a markdown to html/latex/pdf gem). It’s simple, efficient and was written in less than 2 hours. Ultimately, the book will be exported to static HTML (using a plugin written by topfunky) and PDF (using a jruby/flying saucer plugin).
RL>> How do you plan to support Merb over JRuby?
Matt>> As a team, the merb team works pretty closely with the JRuby team. We micro-benchmarked JRuby and Merb on a 8 core machine and got 14,000 requests per second. That’s pretty impressive! Of course, I would not expect to get these kinds of results in a production app, but that proves the potential of such a combo.
JRuby’s threading system has some great advantages and that’s something Merb always valued. Of course things are not perfect yet but we do our best to fix bugs when they are reported to us. We are also planning on further optimizing Merb specifically for JRuby. We believe this is a great choice for the enterprise and we want to fully support people choosing JRuby and Merb. Expect a lot of improvements and even better support and performance.
RL>> Are there any IDE’s for Merb?
Matt>> Any IDE’s for Ruby will work with Merb. However, the core team has been working with Sun’s Netbeans team to add custom Merb support to their next version. Even though none of the Merb core team member use an IDE, we recognize that a lot of people, especially coming from a different background are used to IDEs and we should do our best to make their transition easier. I personally really like profiling and re-factoring tools so I wouldn’t mind a light yet powerful IDE.
RL>> Talking about Merb without talking about DataMapper, Mongrel or Erb is difficult. How much “decoupling” exists between Merb and DataMapper and the DataObject adapters and if in the near future whether there will be an adapter for JDBC?
Matt>> Very good question. DataMapper is an Object Relational Mapper (ORM). The goal of an ORM is to convert scalar values from a data store (a database for instance) to objects in your programming language. People with a Rails background are familiar with another ORM: ActiveRecord. DataMapper has a unified API/inteface to access adapters. MySQL, Postgres and SQLite3 adapters use DataObjects drivers. These drivers were rewritten from scratch in C to match the DataMapper API. By using this unified API, DataMapper doesn’t need to hold all the logic and therefore stays simpler and easier to maintain. The problem is that people need to write adapters. The good news is that it’s really easy since you have an API already defined for you.
You can look at examples like my google video adapter or Yehuda’s Salesforce adapter which were written in very few lines of code. As the Database adapters rely on C drivers, they don’t run on JRuby yet. That’s why the DataMapper team is working on a JDBC adapter.
Now that I have explained a bit more about DataMapper, let me address the question of decoupling. DataMapper (DM) is a separate project and even though the Merb team is often involved with DM, it is not managed by us. Merb doesn’t rely on DataMapper and only the “opinionated stack” uses DataMapper by default. As a matter of fact, Merb supports a lot of adapters: DataMapper, Sequel, ActiveRecord, RelaxDB and can support new ones as they will be released. Once again, people have different needs and we believe they should make a choice which ORM they prefer to use.
Take YellowPages.com for instance, Lori and Jacob use and love Sequel. Lori did a presentation at MerbCamp and is actively supporting Sequel’s integration in Merb. They are both also working on the Sequel section of the merb-book. Because of my involvement with CouchDB, I use CouchRest quite a lot. CouchRest is just not really an ORM per say and it works great with Merb. So really, if you don’t want to, you don’t have to use DataMapper.
RL>> Is there a Merb (community) support for Windows, Linux and MacOS? Or is the framework development currently focused on just a specific operating system?
Matt>> In all honestly, I wish I could tell you that there is full support for all the platforms. Unfortunately the reality is slightly different. While we do want to support Windows, none of us use Windows daily. And if you ever tried, you know that using Ruby on Windows is painful. It’s slow and not really optimized. However, thanks to people like Luis Lavena things are easier. We are working with Luis to make sure that we don’t leave the Windows users behind. I really hope that soon, we will have an overall better Ruby support on windows. Apple shipping its OSX with Ruby obviously makes things easier, the core team uses MacOSX and Linux to develop and we all deploy to linux servers.
RL>> Will Merb work as well as Rails under passenger, or will there be plans for moving forward with mod_rails? In essence, how do you expect the hosting support in the very near future to unfold for Merb? Rails took quite a while to be supported as much as it is right now, and even so it doesn’t reach the same base as PHP or ASP or even Python support for hosting services.
Matt>> This is another question we get quite often. Phusion Passenger is a great project which changed the way you deploy Ruby apps. Passenger is an apache module which simplified the life of many people and opened the door to shared hosting (it makes it easier to manage accounts according to locaweb.com.br). But it’s more than that, the Phusion guys also worked on Ruby Enterprise Edition (REE), a patched version of Ruby designed to optimize memory usage. Merb is already setup to take advantage of the REE optimizations if you decide to use REE instead of the standard MRI. Passenger is also designed to serve all Rack based applications and therefore support Merb but also Sinatra, Ramaze, Mack etc…
However, it is true that Passenger is specifically optimized for Rails and does stuff it won’t do with Merb and the other Rack based frameworks. I know of a few people deploying their merb apps on passenger and being really cool about it. However, we really hope to be able to work with the Phusion guys and specially optimize Merb for passenger. It’s very important to keep things simple and I can assure you we are going to do our best to make sure Merb and Passenger work together in an optimized way.
RL>> Any comments about Mack, Ramaze and Sinatra – or any of the “new” MVC players in Ruby for web applications?
Matt>> I’m actually really excited to see so many new frameworks. Some are not so new but people are probably a bit more open nowadays. I need to spend more time studying what they do, how they do it and why. As a team, we have spent some time looking at other frameworks, including outside the Ruby world. We learnt a lot from Django for instance. Our concept of slices is really close to their concept of “applications”. But what is exciting about all these frameworks is that we are all using Rack. And now Rails has joined the party.
The great advantage of Rack is that we can share adapters and we can share middlewares. The other day I was chatting with Bitsweat from the Rails core team about some really cool middleware they’ve been working on. I’m really happy to see that we will all be able to work on some common piece of code which we all be able to share. I’m also interested in frameworks with a different perspective like Waves. I don’t fully understand it yet but I’m sure it will enrich our community.
RL>> Is Merb being used by companies? Can you name a few?
Matt>> We have a list of people using Merb on the wiki. The best thing to do is to check there. Some names I have in mind would be of course Apple via Sproutcore which is used for MobileMe. Yellow Pages which now uses Merb for their service tier. I heard Wikipedia is using Merb on a small project lead by Hampton Catlin (the Haml guy). Microsoft/powerset is using Merb. I believe hulu.com used to use Merb a long time ago, but I’m not sure whether they are still using it. Some other companies prefer not to mention these kind of things, but if you look for job offers you will find companies like Adobe looking for Merbists.
RL>> What’s the future of Merb?
Matt>> The best person to ask would be Yehuda Katz, Merb lead developer. Right now we are in “community support mode”. Now that we have released a stable API and have a solid code base, people have started using Merb and we are listening to their feedback. We are building the framework for the developers and we need to know what they need. We’ve been focusing on trying to fix all the little annoyances. We are monitoring IRC and twitter to see what people complain about and we work on it. The immediate future top priorities are: Documentation and Gem dependencies. That’s why I started the merb-book and Yehuda worked on a documentation app and a new optimized bundler (he also worked on RubyGems and hopefully his changes will be available in the next release).
Once this is solved we will be able to focus on Merb 1.1. Merb 1.1 will focus on a few things, mainly:
- improving the concept of slices by making any application a namespaced mountable application
- increase the interaction with Rack to allow more flexibility and performance
- push the concept of resources even further reducing duplication in your code
- significantly improve the performance of large route sets
In the long term we are also focusing on two categories of people, a bit left behind at the moment:
- the enterprise users
- Rapid Prototypes designers needing the simplicity of PHP and sexiness of Ruby
On the way to 2.0 we are also planning on working on cool Merb slices like an admin slice, a slice administrator etc..
RL>> Matt, thank you for your time. Anything else you would like to add?
Matt>> I would like to thank the rest of the core team and all the contributors, including all the translators working on the merb book. A big thanks to Matz and the Ruby core team for an awesome language, thanks to DHH and the Rails core team for pushing Ruby and creating Rails. And of course thanks to RubyLearning for supporting the project and offering an exclusive opportunity to learn more about Merb.
The opinions expressed are those of Matt Aimonetti and do not necessarily reflect those of www.RubyLearning.com.