I ALWAYS reinvent wheels, pretty much on a weekly basis. Why would anyone do anything that stupid? The first wheel was made out of stone. The person creating the first wooden reinvented it. The person creating the first rubber one reinvented it. The person creating the first rubber one filled with air reinvented it. So if you need a wheel today, will you buy one made of rubber and filled with air or will you buy one made out of solid stone? I’ll guess you go for the first one… but if nobody had ever reinvented it, your car would still use stone wheels.
When I go out to buy an actual wheel, I don’t reinvent it. Why? I have absolutely no idea of wheels. I don’t know how to make a good wheel. I don’t even know how to make a poor wheel. And I’m absolutely the wrong person to come up with a brilliant idea how to make better wheels.
I’m a programmer. I have no idea of wheels, but I have ideas of code. Taking code from someone else means:
- I must assume he created the fastest code possible
- I must assume he created the most resource friendly code possible
- I must assume he created bug free code
- I must assume he created the best possible interface
and then I just use his code and it saves me hours of work. Have you ever considered that none of the above might be true? His code may be way slower than possible, using way more resources than necessary, it may have (still undiscovered) bugs, and the interface might really suck. What makes you believe, just because he has written some code, that this is actually perfect code? Because he’s a genius? The programmer of an API may have half the programming knowledge you have, one quarter of your experience, and his grade point average in math might have been two grades worse than yours throughout his whole education career. Do you know that is not the case? However you are willing to just blindly trust his code? Why?
Don’t get fooled by the fact that thousands of other projects use his code. Just because thousand other team leaders are too lazy to reinvent that wheel and just take the library already there says nothing about the quality of this library! The only you code of that you can control the quality is your own code (unless you do code audits on other people’s code).
I have already reinvented the wheel just to find out that when benchmarking my code, it beats the original code in speed, it uses less memory, it is multithread-safe (while the original one was not), and the API exactly meets my needs. I already reinvented the wheel just to find out my code sucks in speed, it eats memory like popcorn, it has no advantages over the other code and my API doesn’t look much different to the original library. Wow, big waste of time, right? Not necessarily. First of all I proved that the exiting library is of high quality (or let’s say the quality is better than the best thing I can produce)… alone this insight was worth the work. And the second interesting thing is that even knowing my wheel is worse, it may be still good enough for my project and the advantage is that I have total control over my wheel, while the development of the other one takes part behind my back.