DEV Community

Cover image for Reinvent The Wheel (Maybe)
Chig Beef
Chig Beef

Posted on

Reinvent The Wheel (Maybe)

According to Wikipedia, the wheel was reinvented in 1888 with pneumatic tires. Taking action against a bad design to create something better, something more useful, and the guy who had the idea went on to found the company after his last name, Dunlop.

Well that's a very specific case of reinventing the wheel, but what makes a good case for doing so? Why should you? Generally these days there's a library for anything, why bother?

There are plenty of reasons why you should, but just as many why you shouldn't. Reinventing the wheel is a timely and costly endeavor, but under the right circumstances, pays off immensely.

For The Sake Of Learning

This is my favorite reason to reinvent the wheel, personally. Especially as a student early in my career, where I don't get too much chance to create profound, innovative technology. To some extent, you can't learn much without reinventing the wheel. Sure, I can understand how a raycaster works, but after making my own I truly understand it deeply, giving a few benefits.

  1. I was able to explain what I had created, even teach others how to implement it.
  2. I'm able to extend what I've created, leading to more learning, and experience.
  3. I had something to show for my hard work, which can be impressive for a job application.

Let's go through each of those points a bit more, with my real (probably biased) experiences.

I made my own raycaster in February, if you don't know what that is, it's a fast way to create crude 3D graphics, used when computers weren't fast enough to render a full 3D world at real time. Recently, my friend saw what I had made, and is trying to go on this same path. He'll come to me every once in a while with an issue he has. "Why do I get this fish-eye effect?", "Why are there gaps in the walls?". Not only is it a great feeling being able to answer these questions, but being able to explain why thoroughly. This created a transition from learning, to teaching, and teaching is one of the greatest ways to learn.

That same raycaster isn't a dead project, I keep working on, upgrading it, and learning more. Soon, I'm going to implement a BSP (binary space partitioning) tree into my program. That's another wheel to reinvent, is that a bad thing? Not at all, in fact there's a high chance I'll have the same conversation with my friend but this time with BSP trees.

And lastly, how has reinventing the wheel given me any help with jobs? I study at a university, and it would be a pretty safe guess to say 50% of students don't code at all outside of assignments and other tasks. That's a safe estimate, my honest guess would be closer to 80%. It doesn't take much to get a leg up, and practicing, reinventing the wheel, has given me a personality around my friends, he likes to learn, and more importantly, he can make programs. Because of this, I got referred by another friend for a small job maintaining a website. I don't work on websites, I know barely anything about the front end, or even PHP. Of course I got the job anyway, because people know I can program whatever I focus on. I would never be looked at that way without reinventing a few wheels.

For The Sake Of A Better Product

Ever been on a website, or an app, and there was some bug? Maybe text wasn't displayed properly, or it was too slow, whatever it was, it annoyed you, and you thought, "yeah, I could fix that". Then that thought quickly flies away as you go back to using the stupid app.

But why? Why let it go? You had an issue with it, so it's a user issue. A good business fixes user issues, so wouldn't this be perfect work experience?

I was working checkout at a grocer, scanning items through. My next item was butternut, the button for butternut doesn't work. Annoyed, I pressed the search button, I knew what I was in for. First 5 letters went in fine, but after that it took an entire second to type every letter. It then took another 1 or 2 seconds to load the results. Then I finally was able to weigh the butternut and pack it. Horribly inefficient.

I went home after my shift to work on my own search function. I made a fake app for a grocer, made a million random items, and created a button to run the search code. I made the most basic search function, added caching, and suddenly, in 90% of use cases, it was instant. It also helped to not automatically trigger searching on every key press, but that's just my opinion.

Now, since the program used at the grocer possibly isn't under their control, I don't think I have a shot at replacing that terrible code with my own, however, there is a good chance you could in your situation.

Now you've not only made the product better for yourself, but literally everyone. Once again, wouldn't that look impressive? Possibly to an employer?

For The Sake Of Performance And Streamlining

The example I just gave works here too. Sometimes the way it has been done isn't quite fast enough. Databases are all at a high level, why would you even reinvent them? For performance of course! That's exactly (for the most part) what TigerBeetle did. They reinvented the wheel, how dare they?! That's exactly what they're told not to do, but despite that, it was the correct choice. Don't let this one example speak for them all, sometimes writing it yourself will produce no reasonable gain in performance, so it's always a good idea to do plenty of research before partaking in such an endeavor.

Identify portions of your programs where performance matters, and don't waste your time optimizing the rest.
Michael Abrash

You really have to know exactly what you're optimizing, and more importantly, whether it makes a reasonable difference.

For The Sake Of Ego

I generally don't use a game engine. All I need is a language, and the ability to draw pixels to a window. Sure, that's cool to say, but I gain nothing from that. Here's another example, I can write basic programs in assembly. You see what I mean? Sounds a bit shallow right? In this case, only write your own bespoke version if you need to.

I generally don't use a game engine, they don't allow me to blank. I can write simple programs in assembly, I used it to make blank. If you can't back up your reinvention with valid reasoning, there's a good chance you're wasting your time in folly of ego. Sometimes you can see this reasoning before your endeavor, but it's not always the case. Just know that until you can give a good reason, you're just going to sound pretentious, and therefore shouldn't reinvent the wheel.

For The Sake Of Distrust

I don't trust that the standard library has a good websockets implementation, so I'm going to rewrite it by myself. Bad idea. Don't be allergic to reading code (if it's open source).

If you don't trust someone else's code, try reading it. Maybe their code is exactly what you would've written, if not better, but instead you've wasted your time because "you're the only one who knows how to code right." Now that isn't to say you should outsource all of your code, that's how we get leftpad incidents, but be more open to using someone else's code, you'll get a lot further.

For The Sake Of Performance And Streamlining (Again)

High-performance code should ideally run so fast that any further improvement in the code would be pointless.
Michael Abrash

Diminishing returns hurt, but it's a law of optimization that you can't change. Sometimes, you have to cut your losses, and suck up a little bit of extra execution time, saving you hours of pointless research (unless it's for learning's sake, then go for it!).

Imagine, going back to my checkout example, that the program already ran with a 50ms delay. I go home, spending a few days working on my own, getting the delay down to 25ms. 2x improvement, that's incredible! But going back to work the next day, I find no visible difference. I wasted all my time, when honestly, it was just fast enough already. The company doesn't think it's a big enough change to implement. Future employers don't find the innovation that impressive. I don't reap much reward from it either.

Conclusion

Don't reinvent the wheel. But maybe, every once in a while, the old wheel just isn't good enough. Without reinventing the wheel, we're stuck without imagination, reimagination. That's extremely important for computing, with such a powerful tool at our disposal.

PCs can do just about anything you can imagine.
Michael Abrash

Top comments (0)