People can and do learn to write code in numerous ways. However, every really *good* programmer I've ever known (and I've known some spectacular ones), has learned to program at the feet of a guru (or in my case, a string of gurus) that taught them to respect the machine.
Anyone can learn to optimize algorithms. It takes wisdom to know when and why to do so. Anyone can learn to write a sort function. It takes experience to know which one to choose, and why... and not only that, why it matters. Anyone who programs will eventually learn how to debug their mistakes. It takes insight to learn the Tao of the Debugger.
It's possible for someone to learn these things on their own (obviously the first hackers did somehow, eventually), but if you learn them early, from someone that you deeply respect, a) the lessons *stick*, and b) you don't have to spend your time and effort learning them on the job later, so you have time to focus on all the other things you need to learn to do whatever you end up doing.