Well, this is very subjective. I think every programmer have wondered this at some time.
Also, it depends a lot. There's a golden rule - the more people use one code, the better it gets - it's tested a lot, it's optimized a lot, the bugs are minimal, etc.
So, in my opinion, there're few criteria:
- if you need something for a common use (such as ordinary containers - just like
std::list, or smart pointers (boost) ) and you don't need that much performance - use the existing one, which is "out there". This will save you much time coding, testing, finding bugs. And, as I said - the more developers use it, the more bugs are fast found and fixed, the better the lib becomes.
- if you need something very specific:
- if you're not looking for high performance (for example for real-time systems, which should process, lets say, 10 000 messages per second) and if there's something, that can help you - I'd suggest the same, use the existing one
- the things are different if you really need high performance and THE MOST IMPORTANT THING - YOU'RE SURE, THAT YOU'LL ACHIEVE IT - then develop it by yourself. I can give you a real example from my experience - there are a lot of IPC libs, but most of them have a lot of features, that we (me and my co-workers from the company) don't need. So, this slows down the things, as we develop software for real-time systems, that process many messages per second and each operation, each millisecond is important to us. Then we developed our own IPC lib - it took a long time, a lot of tests, a lot of bugs, etc, but it was the best solution for us.
Other example - some containers, such as
std::vector have really great functionality and a lot of useful things. But if you're sure, that you'r not gonna need them and you really need HIGH performance, and, again, you're sure, that you can achieve this - you could implement your own container.
You know, it's really subjective. Programmer's time is much more expensive and valuable that CPU's time or something. So, if you can use something existing and it satisfies (as performance, interface ) you - use it.
About this: "Doing it your self helps you understand how it does it but you cant possibly understand everything about programming, there's to much and it keeps changing." - you're completely right. To learn something, you do need to practise it. When you write something by your own, you'll learn a lot - much more that reading about it (from book, internet, article, whatever). The best teacher is practice.
But practising could be done at home, this will make you better developer. Most companies will pay you to write quality code, and do it faster, with less bugs. Noone will let you implement
map, for example - you know, it's rather difficult and hard to implement (you need to know some advanced data structures there - like AVL tree or something similar). (and I mean
map for some casual use, not something very, very special, because if it's something specific - it's different then).
I'm not sure if I confused you more or helped, but there's no correct answer for this :)