Well it's actually quite simple - the amount of bugs depends on the amount of code - less code, less bugs.<p>To truly eliminate bugs, you either need to be able to see the future or have learned from your mistakes and from others' mistakes. (The latter being more common)<p>Depending on what you're doing, chances are if there isn't a clear separation of concerns and you're not following good/best practices (ia. solid, grasp, design patterns, ddd/tdd/bdd/*design) and - proper planning - there will be bugs.<p>Another thing developers generally struggle with is calling something by its name, ex. var a = 13 vs. var age = 13. That generally confuses even the developer himself after he went to take a leak.<p>I also agree on all Samikcs points - in addition to that there is really a lot of different ways to 'test code' ea, integration testing, unit testing, behavioral testing, requirements testing, deployment testing etc. - even software testers have to attend courses/study.<p>If you've read up to here, you will have realised there is no one answer. Programming isn't a task to be taken light-heartedly. Plan. Develop. Test. Verify. Repeat.