Our capacity to torture ourselves with our thoughts is without equal. Our minds feed us with thoughts that scare us and worry us. They're thoughts that contribute to stress, anxiety, depression, and other mental disorders that hundreds of millions of people suffer from. Consider these thoughts:
When we read sentences like these, it seems obvious these are bad thoughts we should pay no heed to. But they're much harder to catch when we're thinking them than when we're reading them. They can flit by and leave a little imprint without anyone noticing.
The essence of the problem is that we trust and respect our minds too much. We believe all thoughts are valid and should be given some consideration, even if we know deep down that what we're thinking is wrong or false.
But the reality is that thoughts are just thoughts. They are not facts. They often don't accurately represent reality. They're just part of our minds erring on the side of caution and warning us against possible threats, but they don't inherently mean anything. From the waterfall of thoughts that crash through our minds every day, we shouldn't place too much emphasis on the worrying ones.
It's a good practice to course-correct wrong thoughts with positive thoughts. For example, “I'm not a poor programmer today and I'll be a much better programmer in the future.” But even then, no one can constantly monitor their thoughts. Our minds will think and some of those thoughts will worry us.
Don't try to forcibly stop all negative thinking, because that's impossible and might worsen the problem. Just don't give undue attention to the worrying thoughts, because they almost always far exaggerate the actual problem, if there is one at all. If each of us could move into a position where we could control our minds instead of the other way round, we would see how fragile these negative thoughts are when you pay them little attention.