in reply to Where do you want to go today? (a little deeper than CGI.pm)

Not all reinventions are equal. There are times I tell people to reinvent perfectly good wheels for the experience. There are others I refuse to use what is apparently a working wheel. And, of course, there are times I look at a wheel reinvention and wonder what kind of crack the reinventor was smoking.

This is not as unreasonable as it looks, and here are a few rules of thumb.

First of all if the wheel is (like CGI) something that involves security, I am against anyone reinventing it without having very good reason. (Auditing the code and finding it is insecure and not fixable is a good reason.) In general with this kind of problem, even if reinvention is necessary, I don't want to see it reinvented by the wrong person. If you have to ask how to reinvent CGI, you shouldn't be doing it. Similarly if you don't know enough to know why you shouldn't be inventing your own encryption algorithms then relying on them, you certainly don't know enough to attempt the task.

Secondly, what is the wheel going to be used for? There are many wheels that are instructive to build. By all means build them in your spare time. But if you need to produce something for production, generally it is better to go with the existing wheel.

Thirdly there is the harder question of what I think about the current wheel. That comes down to many questions. For instance I may have heard things about the author (eg Matt Wright) that indicate that I don't really want to bother evaluating their wheels. Or I may know something about the module (eg the extremely poor performance of Math::BigInt due to constant string-array conversions) that makes me not want to use it. Or I may look at the API and decide that it is not one I want to code against for a variety of reasons. This involves a subtle combination of knowledge, intuition, and experience. (Also some prejudices...)

And last but not least, there are wheels that are just fine to reinvent. For instance I was asked why in Continued Fractions I did my own rounding rather than use Math::Round. Well the answer was that the use of sprintf for rounding is a wheel I was familiar with, I had never heard of Math::Round, and even after reading it I didn't see any rounding function there that matched my need. I reinvented that wheel, and would do the same again without hesitation...

  • Comment on Re (tilly) 1: Where do you want to go today? (a little deeper than CGI.pm)