Why We Should Reinvent The Wheel (Occasionally)

Monday, 12 April 2010 09:32

It's one of the basic tenets of programming: “Don't reinvent the wheel”.

At first glance, this makes a lot of sense. Why waste valuable time changing something that already works? Instead, just build upon what others have already invented; extend it and create your own new layers which alter its functionality.

Well, we did reinvent the wheel—several times over. We made wheels from stone; then wood; then we carved the wood into spokes; then made the spokes from metal... and so on. Why? Because each new version improved on the last; made it lighter, stronger, faster, better. The original wheel would be no match for our modern alloy and composite wheels, which were redesigned from the ground up—the basic shape is the same, but the wheel itself is now a completely different animal.

Programming languages themselves are constantly changing, and new languages appear all the time. Generally this is nothing to do with the limitations of the old languages, but rather a desire to do things more elegantly and easily. Programmers and developers are naturally curious; we're not satisfied with something that just works, we want to know how it works. Then, once we know how it works, we start thinking up ways to improve on it.

I've learnt a great deal by—somewhat arrogantly—assuming I could improve on what's already out there, then steaming straight in and trying to build it. Even when the resulting code turns out not to be an improvement, it's always been a worthwhile investment of my time in terms of the new skills I've learned.

When I wanted to learn Python, I wrote myself a simple blog engine. I could have downloaded any one of a number of open source Python blog engines and modified it to suit my needs, but I wouldn't have learned half as much, half as fast as I did building my own from the ground up. The result is certainly not the most feature-packed blog software out there, but it does the job and I know it inside out—and I learned Python along the way.

I'm not saying that we shouldn't promote code reuse; indeed, there are many complex libraries and applications which are so mature and so refined that it would be pointless, not to mention extremely time consuming, to try and recreate them. However, “reinventing the wheel” can often be a good thing, particularly when it comes to learning new languages and techniques. Here's why:

My point is that it's not always a bad thing to revisit problems that already have an established solution. Sometimes it can be beneficial to understand the foundations of a construction, before you start building on top of it.

Add your comment