I work better when I have some firm foundations. This helps me to solve everyday problems better, because I can generalize them. The thing I find in programming is so many things are black boxes. Logic is scientific, but commands are not. A command in a language is just something that does something. It is very hard to work out what its logic is, without understanding the underlying hardware. I learned brainfuck for a little bit, and enjoyed it very much, but it still has commands. These commands are packages of functionality that cannot really be understood without understanding all the lower levels of logic, unfortunately. What I would like to know is if there are any mathematical or logic principles that help with being able to generalise programming problems? 
What's the best way to inject science into everyday programming?
computer science
The thing I find in programming is so many things are black boxes.Here are some resources that will open those black boxes:Code: The Hidden Language of Computer Hardware and Software byCharlesPetzold.According to an Amazon review:...The real value of Code is in its explanation of technologies that  have been obscured for years behind fancy user interfaces and  programming environments, which, in the name of rapid application  development, insulate the programmer from the machine...The Hardware/SoftwareInterfaceThis Coursera course examines key computational abstraction levels below modern high-level languages. According to the course's description:...We will develop students sense of what really happens when  software runs  and that this question can be answered at several  levels of abstraction, including the hardware architecture level, the  assembly level, the C programming level and the Java programming  level...And finally my favorite:How do computerswork?@LieRyan provided an excellent explanation from the atom all the way up to assembly language.EDIT 1:What's the best way to inject science into everyday programming?There are so many arguments as to whether a Computer Scientist is really a scientist and whether a Software Engineer is really an engineer. Anyway, the following resources will help you inject science into everyday programming:The Art of Computer Programming by DonaldKnuthKnuth's books are considered to be the bible for algorithms. The study of data structures and algorithms are the closest to the scientific method in the Computer Science field I could think of.Algorithms, Part 1 and Part 2This course covers the essential information that every serious  programmer needs to know about algorithms and data structures, with  emphasis on applications and scientific performance analysis of Java  implementations.Is Computer ScienceScience?(PDF)