Wednesday, October 24, 2007

Catalyst, Ruby, and MVC in general

Ruby is all the rage these days so I decided to give a look. First I have to say it is wicked cool. You can do a lot with a few lines of code. If you need to prototype a site in a short amount of time then this is the tool for you. The downside, from what I read, is scalability. This is from a rails developer, Alex Payne, working on twitter:

By various metrics Twitter is the biggest Rails site on the net right
now. Running on Rails has forced us to deal with scaling issues -
issues that any growing site eventually contends with - far sooner
than I think we would on another framework.The common wisdom in the Rails community at this time is that scaling Rails is a matter of cost: just throw more CPUs at it. The problem
is that more instances of Rails (running as part of a Mongrel
cluster, in our case) means more requests to your database. At this
point in time there’s no facility in Rails to talk to more than one
database at a time. The solutions to this are caching the hell out
of everything and setting up multiple read-only slave databases,
neither of which are quick fixes to implement. So it’s not just
cost, it’s time, and time is that much more precious when people can[’t]
reach your site.None of these scaling approaches are as fun and easy as developing
for Rails. All the convenience methods and syntactical sugar that
makes Rails such a pleasure for coders ends up being absolutely
punishing, performance-wise. Once you hit a certain threshold of
traffic, either you need to strip out all the costly neat stuff that
Rails does for you (RJS, ActiveRecord, ActiveSupport, etc.) or move
the slow parts of your application out of Rails, or both.It’s also worth mentioning that there shouldn’t be doubt in anybody’s mind at this point that Ruby itself is slow. It’s great that people
are hard at work on faster implementations of the language, but right
now, it’s tough. If you’re looking to deploy a big web application
and you’re language-agnostic, realize that the same operation in Ruby
will take less time in Python. All of us working on Twitter are big
Ruby fans, but I think it’s worth being frank that this isn’t one of
those relativistic language issues. Ruby is slow. 1


One thing that Alex points to is Ruby, saying that Ruby it-self is slow. I have read a few other posts that lead me to believe that this is the case. So I started playing with Catalyst which is a MVC framework for Perl. I have to saying that I was pretty impressed with Catalyst as well. It has the added advantage if plugging in different view classes and even mix and matching them in the same project. Its not as elegant as Rails, then again Perl is not really known for its elegance in general. I have developed in Perl for a long time and love it as language. So this seems like a good fit.

Then I really get thinking of the MVC framework in general. MVC stands for Model, View, Controller. This is not a new paradigm it has been around in Java for years. You start with a model class that describes your data. This could be a database connection or a standard container class. You also have a view class that handles how your model will be displayed to the world. Finally there are controller classes that interact with the user by display the model through the view class and handling the user input. The controller is the glue between the user and your application. In Java typically you would roll these your-self which gives you a good deal control.

The Rails/Catalyst model seems slightly different in that they are trying to handle more of that for you. In the Rails land the View part is pretty well out of your control. You use the templating language they provide. The model is more or less locked down as well which allows you to focus your coding on the controller. The advantage is you have less to worry about so you can focus on the portion of the app that is really important. Like I said above that is really cool.

Here is what distress me. We are moving the developer further away from core pieces of development. I think that a part of the twitter problem is that they rely on ruby to write SQL for them and to display information. Yes it takes the developer less lines of code but that code didn't just disappear, it has to be handled somewhere. There is a trade off in ease of development and performance.

The Rails problem isnt new right? Do you code your project in VB or C?

1 Alex Payne Interview

8 comments:

Anonymous said...

Thanks for writing this.

Anonymous said...

buy bactrim es online without prescription buy bactrim f buy bactrim online buy bactrim buy bactrim without a prescription overnight buy bactrim without prescription
[url=http://bactrim.eventbrite.com/]buy bactrim without a prescription overnight [/url]
when to take glucophage doses glucophage me benefit of glucophage glucophage odor cause glucophage kidney pain diabetes glucophage glucophage xr
[url=http://takeglucophage.eventbrite.com/]how to take glucophage [/url]
muscle atrophy proscar side effects libido proscar peronies proscar pi generic 5mg proscar cheap affect proscar side generic proscar proscar hair regrowth
[url=http://proscar.eventbrite.com/]libido proscar [/url]
levitra woman how does levitra work levitra website levitra commercial key buy-levitra livitra cheap levitra
[url=http://virb.com/yalevi]buy levitra uk [/url]
http://virb.com/yalevi

Anonymous said...

Please, tell more in detail..

Anonymous said...

Completely I share your opinion. I like your idea. I suggest to take out for the general discussion.

Anonymous said...

Hello Thanks for sharing your thoughts. Take care.

Anonymous said...

Hi Thank you! I always wanted to write in my site something like that. Can I take part of your post to my blog?

Anonymous said...

Message29, http://www.arlo.net/massacree/ buy viagra online, wxbn9, http://www.arlo.net/fccgb/ viagra without prescription, jlqp8, http://www.arlo.net/fccgb/notes/ buy generic viagra, jtvr0, http://www.arlo.net/bytes/ buy cheap viagra online, kbiz8, http://www.arlo.net/live/ viagra

Anonymous said...

dating service for teens http://loveepicentre.com/testimonials.php dating beautiful blonde women