Lightweight Frameworks

Posted by on in Blogs
I came across this interview with Yehuda Katz about Merb, an interesting web framework for Ruby.  Although I have less actual experience with Merb than with Rails, I've always liked the general design philosophy of Merb. Whereas Rails appears to be designed as a complete MVC framework (and a nice one, too; I'm not writing this post to critique Rails), Merb allows you to build your own framework by combining existing tools. It doesn't try and reinvent a new ORM or package manager, for example. Like jQuery, less commonly needed items are available as plug-ins, rather than being part of the core framework. As Katz puts it:
We also try to keep our code relatively small and modular, so a few just install Merb core, which is the core of framework - there are only 6.000 lines of code in there. Just starting up Merb and having it run it's going automatically takes up less RAM, the critical path will be smaller, we don't do alias_method_chain, which means that the number of method calls for a regular request is going to be smaller out of Merb.

Now, that's nice, but it's even nicer if your preferred ORM doesn't happen to be ActiveRecord.

I like the ASP.NET MVC framework for the same reason.  It doesn't supply an ORM because you might not need one, and if you do, there are plenty of existing tools from which to choose.  It doesn't invent a new templating language.  Though ASP.NET routing was created to support it, routing is no longer part of the ASP.NET MVC framework; it's now an entirely separate project which other tools can and do use.

By contrast, I have pretty much sworn off / am not even tempted to try certain other frameworks which attempt to do everything required to build an entire application, with strong coupling between the various parts.  Indeed, even though I use the Entity Framework in my ASP.NET MVC applications, these two parts of the application have no knowledge of each other. I'm also incredibly wary of commercial web "components" which don't play well in ASP.NET MVC, due to dependencies on View State (or worse).  These aren't web "components;" they are extensions of the WebForms framework, and I'm building web sites, not WebForms sites.

Big frameworks with strong coupling are prisons. Once you go into them, you're stuck, and it can be incredibly difficult to get out.


Check out more tips and tricks in this development video: