Quick Thoughts – Comparing HTML::Mason to Ruby on Rails

Since HTML::Mason is about as close as I’ve come to coding Rails before now, and Class::DBI is about as close to ActiveRecord as you can get in the Perl world (well, DBIx::Class is close too), I wanted to draw some comparisons for people.

  • The params variable is %ARGS
    • As with each request in Mason having access to the %ARGS hash, each view and controller in Rails appears to have access to the params variable with whatever parameters are passed on.
  • Helpers are Components
    • All those little “helpers” or scriptlets or whatever they are called all are pre-defined components. Putting <%= form_tag %> in your page is very similar to using <& /components/form_tag &> (if you had a bunch of pre-done components of course :)
  • ActiveRecord is Class::DBI or DBIx::Class
    • Already stated above. The same Zen of Class::DBI and it’s goodness is replicated fairly nicely in ActiveRecord. There doesn’t seem to be an obvious replication of some of the really cool stuff from SQL::Abstract (using [ ] arrayrefs and { } hashrefs to create complex and/or and nested queries). The “noobie” ActiveRecord that I’ve been presented with so far has allowed for this by allowing you to do something like Thing.find(:all, :conditions => ["age > ? and age < ?", agefrom, ageto ] ). Not as cool, and I’m sure that if anyone was reading this blog they’d chime in that all you have to do is use the SuperMegaAwesomeSQL-fu plugin and I’d get that functionality. It might also be in the next chapter of the book I’m reading too.

These are the big obvious ones I’ve seen so far, will update when I find more comparisons that help me wrap my mind around this stuff.