Matt Aimonetti: Why on earth would you ignore Merb?

by Satish Talim on December 18, 2008

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.

Matt Aimonetti, USA

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:

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)

Merb

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.

Disclaimer:
The opinions expressed are those of Matt Aimonetti and do not necessarily reflect those of www.RubyLearning.com.

Technorati Tags: , , , , , , ,

Posted by Satish Talim

{ 10 comments… read them below or add one }

José Carlos Monteiro December 18, 2008 at 7:16 pm

Wow! Great interview! Great answers!!! Thanks, Matt and Satish.

It’s great to hear from the “lion’s mouth” how focused they are in improving Merb, and how. I especially like to know that JRuby and Passenger topics are deeply discussed among the team, and that this same team considers them to be quite important.

I do wonder how “separate” the projects Merb and DataMapper can really stay that way for long. In a way, it’s like talking about ActiveRecord and don’t associate it with Rails. It’s in no way a comparison, more of an appreciation, when I say that Rails is fun and easy while Merb just feels right. :)

Finally, it’s great to realize that these many (good) MVC frameworks have naturally “flourished” from such a cool language as Ruby is. Amazing!

Reply

Nicolas Alpi December 18, 2008 at 8:36 pm

Very good article. It’s good to have a solid base like this to understand the main differences between these 2 hudges frameworks.

Reply

Matt Aimonetti December 18, 2008 at 11:31 pm

Jeremy McAnally was confused by my comment about merb trying to be “closer to Ruby”. I agree that I could have been more precise.
Thankfully Michael Ivey understood what I meant and expressed it in a very clear statement: “more in line with traditional ruby idioms and best practices”. @ivey even mentioned an example: merb provides/content_type approach.

Something which makes me personally feel “closer” to ruby, is how actions really look like normal Ruby methods.


def show(id)
@article = Article.get(id)
raise NotFound unless @article
display @article
end

That’s the code you get when you generate a resource with Merb’s full stack. Making the use of params clear makes me feel closer to Ruby.

I believe this is the kind of things that made Matz say:

“I think that Merb will give users more freedom in a Ruby-ish way of programming.”

Now, I also have to admit that could still do better and it’s still a web DSL. That’s why I chose to say: “Merb tries to be closer to the Ruby language”. We are trying as much as we can and there is room for improvement.

Finally, I just want to make clear that I was answering a question concerning the reasons people are interested in Merb. This is an opinion I heard often and that I share, but I admit that’s also something somewhat subjective and something you might not care about. Again, my goal is not to get rubyists using other frameworks to switch to merb because I feel it tries to be “closer to Ruby”.

It’s up to each person to look at his own needs and choose the framework that makes sense to him/her and for his/her project.

Reply

Chris December 19, 2008 at 1:57 am

I just recently evaluated merb and only ruled it out for one reason. Documentation. I just don’t have the time to read the source to figure out really basic stuff, and merb is moving fast enough that half of what’s out there right now is outdated.

Reply

Satish Talim December 19, 2008 at 5:27 am

You can find some more discussions about this blog post here.

Reply

SoftMind December 19, 2008 at 10:49 am

Hi,

Very Good interview and nice slices of information shared about Merb. Since i am a great Merb fan and admire the way Merb is shaping up, i would like to add few suggestions here…

Why Merb is thinking only about “Passenger” regarding the hosting scenario. When there can be many frameworks for Ruby, its easy to accept many options other than Passenger as well. Since Merb is modular and thinks in many different ways than Rails, why does it adjust its thoughts about none other than Passenger about shared hosting?

I think the “PHP” type simple hosting will take Merb many years ahead than Rails in a short span of time. Deployment is the ultimate goal for any framework, whether big or small. If the project is “NOT” deployed easily it is bound to fail, and no framework can save it.

I know many PHP / ASP developers,who are willing to join the Merb/Railsway.. but are scared about the deployment scenario. Unfortunately no blogs or tutorials are enough to clear their doubts, they just want Merb hosting as easy as PHP.

If Merb team can take good inspiration for Rails and Djnago and can improve it with efforts, I am sure they can improve the deployment scenario as well.

I think… Merb Team, should think about this on priority basis.

SoftMind

Reply

Jeremy December 19, 2008 at 11:29 am

I disagree with that assertion for a number of reasons, but chiefly how Merb is fairly schizophrenic in how it tends to treat objects. For example, routing:


match("/one/:two").to(blah blah blah)

That’s not what I’d consider normative Ruby by any standard (and it certainly isn’t best practice; that’s one of the reasons I don’t care for RSpec very much). But other times, you have hash arguments rather than object methods and other times still you use blocks. I’m not saying that Rails or some other framework doesn’t do that (because, for example, Rails does switch between hash arguments and the block form on occasion), but I don’t think it’s good practice in any case.

I still fail to see how that’s really “closer to Ruby” since you’re actually doing more Ruby magic than Rails is to get that effect (merb-action-args is wacky! :P). It’s not cleaner Ruby; it just looks like it. (I also feel like display abstracts too much away, but that’s a total nitpick on my part :) I do like the tiny amount of code needed)

Reply

Matt Aimonetti December 19, 2008 at 11:41 am

@softmind This is a very interesting comment. Are you saying that deploying an application with passenger is not easy?

We have been investigating other alternatives like a built-it reverse proxy and a dynamic pool of workers (swiftiply with merb’s master and worker process).

We are trying to do our best to find a powerful yet easy deployment solution. I personally think that using passenger is as easy as deploying a php or a python app, but I’m interested in hearing more from you as you don’t seem to find it easy enough.

Glassfish is another easy solution if you are using JRuby.

Again, I appreciate your comment and feel free to email the mailing list if you have any suggestions, in the mean time, I will make sure the documentation on deploying merb apps with passenger is up to date.

- Matt

Reply

Matt Aimonetti December 19, 2008 at 11:57 am

@jeremy hehe, you and I seem to agree on this one :)

merb could get better and get even further “closer to ruby”, there is definitely room for improvement.

However, even though this is not perfect, merb’s desire to come to something closer to ruby is something that people interested in merb are looking at with interest.

You mentioned RSpec, this is a different discussion all together but it would be interesting to hear different view points to help people choose what they think is more appropriate.

Maybe rubylearning.com could interview people like yourself and David Chelminsky. I know I would love to read more about the topic.

- Matt

Reply

Jeremy December 19, 2008 at 12:36 pm

@Matt My only real problem with RSpec (outside the magical implementation) is the fact that it yields self all over the place for the “English effect.” Blech! ;) That’s how you get code like poop.stub(:whatever).and_return(thing).with(blah). It’s just crazy.

Reply

Leave a Comment

{ 7 trackbacks }

Previous post:

Next post: