Best of both worlds
Published 2006-03-07 @ 03:47
Here is my very simple rule for optimizing:
Never ever code for speed until you need to code for speed!
Consider it an addendum to Knuth’s “root of all evil” law. There are two corollaries to this law:
Only rewrite the slow part in C, not the whole damn thing.
Some of this came up recently because of a dialog last week on ruby-talk between Sascha Ebach and JEG2 about making FasterCSV even faster. James wants to keep the module as pure ruby (totally laudable goal) but Sascha thought it’d be neat to take advantage of RubyInline if it were available. I’m all for keeping it pure ruby, but I wanted to see how you’d do the dual implementation version in a way that still read clean. Here is my first scratch at it: