Programming is a tool making profession, new age blacksmithing if you will. Sure, you can make tools to extract meaning from the world, but most of programming is more about getting everyday stuff done more easily, efficiently and accurately. Programmers more than anything else are problem solvers. People who figure out how to use a box of tools to build an edifice and ensure it is fit for purpose. It's about problem solving, but then most creative and destructive processes involve problem solving.
To the extent that war and mining involve problem solving, programming is like those. But war as an analogy to programming doesn't seem a very good fit to me. You might as well use a factory as an analogy, or politics, or any of a huge number of other metaphors which share the common objective of managing people with a common goal. Programming in and of itself has almost nothing to do with people management. In the war analogy programming is much closer to fighting, learning and applying a domain specific set of skills, than war which is much more about managing people and resources.
Premature optimization is the root of all job security