Lesson: How do programming languages make computers work?

Explore how programming languages make computers work and how we use those languages.

Understand lower and higher levels of programming instructions. Understand compilers, compiling, linking and deployment.


At the hardware level, computers understand one language, called machine language (also called object code). This is the set of instructions supported by the computer's processor hardware and is specific to each type of processor. This object code language is numeric in nature and expressed in binary, which is a numeric coding made up of only 1s and 0s (base 2). It is very tedious to program in binary, so higher level languages were created to make it easier to create programs. In a higher level language, you use syntax that is English like and easier to understand to express what you want the computer to do. It is the job of the higher level language to translate those written instructions into binary object code for the computer to execute. In fact, when a program file is created by a higher level language it will contain only the binary instructions for the computer, not your source code.

Typically, the programmer writes instructions in the selected higher level language, Java in our case, and these instructions or source code are stored in text form in a file. This source file is then passed to a program called a compiler which translates the source language to object code in binary form and writes that to another file called the program. An example is an .exe file on Windows. There may be an additional step called linking which is the process of combining the programmers instructions with libraries of instructions created by someone else. Sometimes the program file may be sent to another computer for execution. This is called deploying.

When the program is run by the computer, the computers operating system opens the program file, reads and executes the binary instructions it finds.

The exact steps and processes taken by each language to convert source code into an executable program may vary but will always follow this general set of steps. The process of translating from source code to a computer-usable program is called compilation or compiling. It is important to note that compilation is a one-time packaging of a certain set of source code into a program file. If the source code is modified by the programmer after compilation, the previously compiled program file will represent the same set of source code that existed at the time of compilation. In order to use whatever changes are made in the source code, the program must be recompiled.