Friday, April 19, 2013

"Not Invented Here" Considered Helpful

We are constantly told not to "re-invent the wheel," as if doing so would be an utter waste of time. Yet doing so is extremely worthwhile, if only for the sake of experience alone. Maybe a better way to put it would be "dissect the wheel, learn about all of its intricacies, then rebuild it from scratch." Maybe someone has already done it. Maybe they've done it very well. But none of that matters. Who says your design won't be better? Who says it won't better apply to your needs? And what of the grand sense of accomplishment that you've done something by yourself?

In programming, Not Invented Here is spoken of as strictly a bad thing. "There's a library for that," they say. They're right—there probably is a library, but there's something critical missing in these discussions. Using a library does not necessarily give you understanding as to how it works.

In my undergraduate compilers course, we used a few libraries to help us parse our language. But before using a new library, the professor would ensure that we had a clear understanding of how it worked. Before using regular expressions, for example, he made sure we had a good background in finite automata and state machines. "Given enough time," he would ask, "could you have implemented this yourself?"

More and more, I'm convinced that we should have an intimate understanding of the libraries that we use. Where necessary, we should sculpt them, tear them apart—even rewrite them.

Now, when you're on the clock, your opportunities for exploration may be limited. But at a bare minimum, take the time to do so in your personal projects. After all, why else are you doing personal projects, if not to learn and have fun?

1 comment:

  1. I agree :

    "Using a library does not necessarily give you understanding as to how it works."

    Actually, maybe you don't work like that, but I'm completely convinced that using a library often keeps you from understanding at all.

    Case in point :

    In Php, I can use the imagick (image magick) extension. However, I don't really understand imagick, or how extensions are implemented at all.

    Or, again in Php, I can use the cURL library to post to a form (usefull to get a response from Paypal if they still allow it). But that doesn't mean it I know what goes on inside that library, does it?

    Me too, I just can't understand why anyone would like to say "Not invented here".

    However, I have to admit, I tend to make my own js libraries (scraps of code or functions that I use all the time, not a whole framework!).