I find myself constantly running into this expression "don't reinvent the wheel" or "never reinvent the wheel" when I ask some questions on SO. They tell you to use some frameworks or existing packages. I know where this attitude is coming from since it's unwise to waste time on something others have already solved. Or it that so?

As a student, I find by using some code others wrote to solve my problem I can't learn as much as I'd like to, and I gain less insight. And sometimes I think that phrase is mainly for working programmers facing deadlines and not for students like me.

Is it that bad to "reinvent the wheel"? Maybe I'm thinking it wrong? Maybe there is a way I can avoid reinventing the wheel and at the same time learn a lot?

  • 51
    You won't get much benefit from joining a gym if you get other folks to lift the weights for you (unless you are learning to be a manger). Commented Apr 11, 2012 at 3:41
  • 83
    It's ok to reinvent the wheel when you're going to be building wheels. When you're building houses, it's a good idea to assume the wheel-builders know what they're doing better than you do.
    – zzzzBov
    Commented Apr 11, 2012 at 5:11
  • 22
    You at least need to TRY making a wheel! Otherwise you do not know why you should use a prefabricated one.
    – user1249
    Commented Apr 11, 2012 at 6:41
  • 59
    It is never appropriate to state an absolute. :)
    – user
    Commented Apr 11, 2012 at 7:30
  • 2
    It can be ok to reinvent wheels when you are creating extremely optimized code. Standard libraries are very useful, but it is often possible to create something that is less general but faster.
    – Leo
    Commented Apr 11, 2012 at 9:41

20 Answers 20


I think you make a good point. Most of the programmers on this site are likely working professionals whose goal is pretty much to create quality software as quickly as possible. Reinventing the wheel fails this goal on two counts.

  1. Re-writing code that exists is wasted effort that could be used on the unique parts of your system and makes the project take longer than is necessary.
  2. The first version of any code is more likely to have bugs/unforseen issues. Most libraries and re-usable components have been battle tested and patched multiple times. If you re-invent a hashing algorithm or try to create your own RDBMS (unless that is what the project is) more often than not you are going to end up with inferior results.

That said, in an academic environment the goal is to learn, not deliver software on a budget. Re-inventing a wheel to understand how the spokes or axle work is a great way to accomplish that goal. That's why many programming curricula include a class on building compilers when very few working programmers ever have cause to need to do that.

  • 37
    I agree with the idea to understand how things work, though I also do wish programming schools took some time in their curriculum to learn how to use third party libraries and why you should. I constantly find programmers and developers of professional capacity who cannot do this and end up reinventing the wheel.
    – Spoike
    Commented Apr 11, 2012 at 6:11
  • 3
    great point about compilers
    – Chani
    Commented Apr 11, 2012 at 9:17
  • 1
    I think learning not to reinvent the wheel is more important. There are many things you can do that don't involve creating something that was already created. Commented Apr 11, 2012 at 15:50
  • @Krelp While one is a student, the concepts are the most important part. Many professors use code samples to allow a bridge theory and application. Those are the types of programs that are going to reinvent the library but it is to make sure that the students understand the material.
    – Jetti
    Commented Apr 11, 2012 at 16:09
  • 2
    As a student you need to reinvent the wheel to see why it goes as fast as it does, but as a professional you need to use commercial wheels so you can go as fast as possible. Unfortunately, as it turns out, SO is primarily a site for professionals, not for students (didn't they ban [homework] for a while?)
    – Tacroy
    Commented Apr 11, 2012 at 17:40

The answer depends a lot on the context. If you would like to gain more in-depth understanding of data structures by trying your hand at implementing a hash table, "reinventing the wheel" is the best thing you can do. If you are learning how to write compilers and need a symbol table, implementing your own hash map instead of reusing one from the standard library is a complete waste of your time.


As a student, I would expect you to begin your programming education by first copying a wheel or two to start with, then learning to modify wheels to see how they work, and to understand any limitations. Later you might even create a brand new wheel of your own to see if you can improve on the design, or to show your course supervisor your understanding of the concepts involved.

As a working professional however, I would expect you to have learned which wheel to use to solve any given problem, and when it might be appropriate to modify an existing wheel if it only partially solves your problem. If you can't find a wheel anywhere, then perhaps you have identified market niche, or you haven't explored far enough, and you would need to be experienced enough to know when it would be appropriate to create a brand new wheel of your own.

The issue of when it is appropriate to re-invent a solution is complex, and it requires time and experience to learn when it might be better to create a brand new version of something that has already been done before. When you have only been developing for a short time, it is better to simply use an existing solution, and to ask your mentors to suggest options. When you have tight deadlines and a lot of uncertainty in a project, using something existing can be a huge time saver, and is always your first choice. You can always refactor to use other solutions later if it is appropriate to do so, even if this means eventually returning to reinvent your wheel.


Being a teacher or programming, I constantly battle with the opposite side of the problem: when do I ask students to reinvent the wheel?

Take these simple situations: we're studying sorting algorithm, and I set tasks to write a program that sorts some data; or working on date functionality, and I ask for a calendar.

For both of these, there are countless ready-made libraries and functionality available; but I want the students to avoid them, and develop their own version of a sorting algorithm or of a calendar.

Now take this other one: I set a task to write a simple application for, say, scheduling appointments. This is likely to need sorting, and a calendar, and more. This time "don't reinvent the wheel" applies: I don't want students to struggle with solved problems, but instead assemble existing functionality to obtain a result.

My difficulty is, how much to ask you to recreate the existing, which does get you to learn, and has the advantage of well-trodden problems with know difficulties that I can use to make you practice the craft, and how much I should place you in a real-world setting, where wheels are not reinvented?

To answer your question more directly, two suggestions:

  • if a teacher tells you to "not reinvent the wheel", they probably say so because they have designed their problem that way. Maybe they want you to try a library, struggle with someone else's implementation of an algorithm, rather than write your own - there's learning in that too, and recreating is interesting but misses the point.
  • if you have too many exercises assembling library calls, rather than developing algorithms, you could raise with your teachers the question of balance between these activities - highlight you've never been asked to write your own algorithms for, e.g. sort and merge. Communication will never go amiss.

Practice I doubt the first 1000 lines of code anyone writes are very unique.

Expand your toolset Using a framework has more benefit when you understand what it is doing (Alost to the point you could do it yourself.) so you know how to apply it.

Understand the "Wheels" Using a poorly constructed and worn-out wheel or one that doesn't fit, is no excuse for blindly sticking to this rule-of-thumb. You may be short on time, funding, expertise, so you just patch it up and finish the trip.

There are few absolutes.

  • 1
    + Especially for the last point. Commented Apr 11, 2012 at 12:10
  • The first 1000 lines of code anyone writes tend to be very unique in terms of creative mistakes. Commented Apr 11, 2012 at 20:32
  • @leftaroundabout - I guess I should limit that statement to lines of code that can compile.
    – JeffO
    Commented Apr 12, 2012 at 1:45

Students don't have money budgets to complete assignments, but there are due dates to consider.

As someone who was a student until recently, I think the amount of wheel reinventing that's appropriate depends on what class you're doing the assignment for. You don't want to write your own socket library for a web development and design class (if you can do that and turn the assignment in on time, what are you doing taking a class that easy?), but you'd be missing a great deal if it was an assignment for a networks class. Of course, professors usually take these things into account when they're creating assignments, so you will mostly do work that is related to the class, but sometimes, knowing what you shouldn't write yourself is important too.

That said, once you leave school, it's hard to find the time to build things that already exist. Take every opportunity you get when you can, while you're still in school.

If you get the "Use library X/framework Y" brush-off on SO, preface your question with "I'm writing X by myself to learn more about it"

  • preface your question with "I'm writing X by myself to learn more about it". This. +1.
    – boisvert
    Commented Dec 31, 2018 at 17:25

If you don't have a set deadline for your project, IMO, it is better to reinvent the wheel. If you don't have a job, or are just looking to learn to program, not to make money programming, what is the point of using shortcuts that will not make you a better programmer, ones that will merely get your project done faster? Although this is true, it is definitely a good skill to know how to use libraries, frameworks, and other people's code.

  • This is the idea behind the concept of Code Katas, rewriting code over and over again to improve and learn from it. I'd say even at work rewriting your code repeatedly is good, and being able to implement many patters if you have to is even better.
    – Bill K
    Commented Apr 12, 2012 at 7:43

In real life, the wheel is reinvented over and over again. If we look for the reasons, we might find some insight as when we need to reinvent the wheel in programming.

Since Sumerian times, many things have changed:

  • The material used to build wheels: from stone, wood, metal, carbon, ...
  • the size of objects needing wheels - in the size of nanometers for medical instruments and wheels for earning brown coal, 100m in size
  • the production environment - hand made, or industry production
  • the precision of wheels which are needed
  • The right situation around your wheel. There might be a perfect wheel for your job, but it might be patented.
  • The shining and polish for your wheel. A Cadillac might deserve another wheel than a VW Golf.
  • The optimal wheel for a baby stroller depends on many parameters: Size and weight of stroller (plus baby/~ies), climate circumstances, resource prices for oil or natural rubber, machines to build wheels and craftsmen, available for production. Shortly spoken: World economics.

How does that translate to the software world? Well,

  • there might be a webserver, but unfortunately it is written in PHP. You would prefer to have it in a language you're fluent in
  • a sorting algorithm might be oversized for 10 elements, but does not scale up to 1T of elements
  • you might need a solution which is itself generated by second program
  • precision is most often a digital question in software land, if an algorithm sorts a list it is sorted - not mostly sorted. But beside performance, code size, memory usage or other restrictions can happen
  • Patents don't need further explanation, I guess.
  • The look and feel is a constant reason for reinventing something - think dropDownList (ComboBox).
  • The global economic situation can influence your software-wheel: will it be a cloud wheel, an Open Source wheel, a Browser-wheel or an App wheel?
  • And of course the most famous reason to build your own wheel: You like to learn it.

I'm a newly educated student. In the school we was 'learning' asp.net and C#, those 2 years the education took, we never tried to make our own email system, login system, or CMS.. Everything was just dragging, and dropping control into the design view.

We started 102 students, 23 did complete. 4 people has a work. The reason?: Those 4 people(including me) did know how to program before we actually started on the education.

The rest of the people is lost. Because we never 'reinvented the wheel'. We never got to know how the code actually work. It's fairly simple to build a full login system, with user management - But the students from my education, doesn't know how to do so. Because they don't know how a login system actually works.

I feel sad, that at some point, actually wasted 2 years, learning nothing. - I wish, that teachers around the world, say: Yeah, we know there is frameworks, where the code exists, You can use them in the real life.. But on this education you will learn how to do programming..

Many programming educations are very short, so the educations need to cover a lot of things within that time. I think it would be better that the list of things was cut to half, and spending more time on programming. People can 'invent a new kind of wheel' if they know how to build a normal 'wheel'. People are not stupid if they have a little knowledge, but you can't ask a man that doesn't know anything about cars, to build a car.. But asking a man that knows how to build a bike, would have much easier with actually building the car.


It really depends on what you're doing. If you're trying to understand wheels, it's a good idea to reinvent them yourself. If however you're trying to understand cars, reinventing wheel the wheel or internal combustion engines is generally wasteful and distracting.

So for example, when you're interested in understanding how a fulltext search index might work, it's a good idea to try to roll your own. If you're trying to build an application for document management, it's better to reuse an existing library, because most of your work is getting the application architecture and the user experience right all at the same time.


Yes, it's appropriate to tell students not to reinvent the wheel. But there needs to be a clear understanding of what it means for a student: write what is germane to the assignment. It does not mean if the assignment is to write a bubblesort, you copy it off of Wikipedia, nor does it mean to use array.sort or equivalents if your framework or language provides it. But after you have covered the various sorting algorithms, have written your own bubblesort and quicksort, don't bother rewriting it for each new assignment, use either the built in sorting or what you wrote, don't do the same old thing over again.

Reinventing the wheel is about not wasting time, which is just as applicable to students as it is to professionals -- the difference lies in what there goals are. Students should be learning, so something that doesn't further their understanding, is a waste of time -- after you have written one bubblesort you know what it does, you know why you don't want to use it on a large set, and rewriting it again and again is a waste of time. You aren't going to learn anything new on the 25th rewrite.

For students, it doesn't mean don't write what others have written, it means don't redo what you have already mastered -- that time that could be better spent on what you haven't mastered.

  • Except if the 25th rewrite is a practise for some programming language you're newly learning. Commented Apr 11, 2012 at 20:35

Lot of thoughts and effort has gone into creating a wheel. The advice is "not to reinvent the wheel" but you can go ahead and reverse engineer the wheel and understand why certain things are done in the way it is done. After this, you may try implementing the wheel in your own way which might result in either of the three logical ends.

  1. You either understand why things are the way they are.
  2. You might optimize it and make it better
  3. You might screw it up and learn how not to do that thing.

To me student should not reinvent the wheel, but try to reverse engineer it & understand the implications.


I would say that it depends on whether you are reinventing to see how the wheel works or reinventing the wheel in the process of accomplishing some other task. Certainly there are wheels that every student needs to implement at least once on their own. You have to know how some elementary data structures and algorithms work in order to understand how they will affect the performance of your code or choose which ones to use in various circumstances.

Stacks, heaps, linked lists, trees, etc. are definitely worth the investment in time to implement once; then ever after use the ones provided by the framework. Everyone who uses a jQuery plugin ought to write at least one, but you don't have to write every different type of one that you will ever use. I'd say that it's helpful, but not necessary, to write a small process scheduler or mini-OS so you can understand what goes on under the hood on a computer. You DO need to understand how processes, threads, etc. work, though.

Once you have a good working knowledge, it can also be important (and fun) to go back and implement new structures/algorithms to get a feel for them. Unless it's your job or you're really good at it, I would stick with using the existing ones in your code.


The answer depends on whether you wish to learn or create.

If learning is the aim, "reinventing the wheel" can give you greater insight and better understanding than using the existing wheels (library functions).

But if creating a complicated product is the aim, then "reinventing the wheel" can be a time consuming practice and will help little the creation of the product.

Nevertheless, if the soul objective is learning provided with enough time and stamina, "reinventing the wheel" is the best option, as it helps to customise every single feature.


Well, there are two aspects to this.

Firstly, if you are trying to learn, it can be useful to do some things from scratch, or use lower-level interfaces than necessary. However, it is still necessary to identify what you are learning: if you want to learn about the HTTP protocol, you don't need to do the socket programming yourself. Only reinvent the things you are learning about, and only do so to really explore and understand them.

But - one of the most important skills of a professional programmer is to select, learn about, and use pre-existing software. This is something that you also need to learn. A huge proportion of the questions on SO seem to come from people who are incapable of reading documentation.

Finally, programming rests on a substantial theoretical base. You will need to use both practical exercises, coupled with reading, to learn the theory.

  • I agree. That's why there are so many new pre-existing software frameworks and libraries being created all the time :)
    – gbjbaanb
    Commented Apr 13, 2012 at 13:42

I have faced the same situation. It's because of the difference in perception in industry and academics.

If you don't "reinvent the wheel" then you absolutely cannot study anything in school or understand how something works.

Whereas in an industry the objective is to bring out a product in least time and effort.

Personally, I like to go down the rabbit hole and I detest the industry philosophy but thats how businesses are done and you can't complain.


The Hacker Jargon Lexikon has a very good comment on reinventing the wheel:

To design or implement a tool equivalent to an existing one or part of one, with the implication that doing so is silly or a waste of time. This is often a valid criticism. On the other hand, automobiles don't use wooden rollers, and some kinds of wheel have to be reinvented many times before you get them right. On the third hand, people reinventing the wheel do tend to come up with the moral equivalent of a trapezoid with an offset axle.

So it might be good to reinvent the wheel, but make sure that you look at other's solutions before or after doing it.


Answer A: Reinvent the wheel. It deepens your understanding of data structures and algorithms and makes it a LOT more likely that you'll write good stuff. I'm sure that when Guido van Rossum was starting on Python, people told him not to reinvent the wheel. There were lots of languages already. Why write google when there was already Yahoo! How about clang? Learn it all. Be a giant. Don't let the small people limit you. Answer B: If an instructor tells you what to do, give him what he wants, or just a bit more even if it seems silly. If you want to ALSO go crazy making an astonishing solution and give him a link to it go ahead. First, though, fulfill the requirements set forth as given so (s)he's happy.


If you are a student, and hence don't have a set deadline for your project, it is better to "reinvent the wheel". If you are programming now merely to learn how to program, and not to make money, why take shortcuts that won't help you learn? Why not do it the hard way? But, when you do become a working programmer, people will be skeptical if you don't know how to use frameworks or libraries...

  • 10
    I don't know which school you attended, but where I went, deadlines for assignment were commonplace.
    – user
    Commented Apr 11, 2012 at 7:37

Do what the assignment/question/exam asks you to do.

Years ago I was a TA for a C programming class. An exam question was 'Write a program to copy a file'. Several students asked the same type of question - can they spawn a process and run the OS cp command?

What we asked them back was 'Will your program copy the file?'

The exam question asked them to write code to copy a file. If the answer did not have C code that copied the file (e.g. open input, open output, a loop to read/write bytes, close input, close output) then it did not copy the file.

If the teacher says use a framework or library (e.g. a graphics class might tell you to use a 3D library ) then use what they tell you to use. Do not invent your own or use a different one. Anything different will make it harder for the teacher to grade your work.

In a job interview a knowledge of popular frameworks will help you answer questions. Create your own projects to learn. Good luck with your studies.

  • Yes, but if they spawned cp their programme would in fact copy the file.
    – Marcin
    Commented Apr 13, 2012 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.