18 Mar 2010
Programming: Higher level languages vs. CPU Instructions
The instructions that the computer understands are very primitive: mostly arithmetic operations such as add, subtract, divide, and multiply, some operations that aren’t arithmetic operations, and others. Because the instructions understood by processors generally operate only on numbers, it’s a time-consuming and complex process to take operations we normally think of doing, and boil them down to the primitives that computers understand.
Therefore, there are entire research areas & software markets dedicated to the task of taking languages that are more palatable to people and generating efficient sets of instructions that computers can understand. These languages that are “more palatable” to people resemble spoken/written languages in the same way that Al Gore invented the internet: hardly. FYI, the products in this market are compilers, linkers, debuggers, and other names; Microsoft’s Visual Studio is a popular one for the Windows platform.
As a back-of-the-envelope example of how describing processes can take much more space for a computer language, consider the game Towers of Hanoi. Wikipedia explains the game in about 7 sentences. An implementation in C, a popular programming language, is about 43 lines. The number of primitive instructions that your fancy Intel CPU needs to run this program is 137 (this can vary significantly but it will always be some larger multiple of the preceding 2 numbers).
The implication of the fact that computers understand such primitive languages is that every little detail need be spelled out, much like, say, instructing a toddler to do laundry :-)