Jump to content

User:Ruud Koot/Nupedia/source code (brief version)

From Wikipedia, the free encyclopedia

The term source code usually refers to the form of computer programs written by humans. Commonly, source code is written in high-level (human-oriented) programming languages such as Java, C, C++ and LISP, as opposed to machine-oriented languages, for instance, most forms of assembly language and machine code.

More formally, source code is often the input to a compiler, in contrast with object code, which is often the output from a compiler. Generally, source programs cannot be executed; hence the need for some form of translation to object code by a compiler, assembler or similar tool. Because of this translation process, source programs are usually written in a language that can be translated with relative ease by a machine. The notion of source code arose during the early 1950s with the advent of assemblers and the first FORTRAN compiler, which John Backus and his team at IBM developed from 1954 to 1957, building upon the principles of compilation established by Grace Hopper.

Note that, formally, source code need not be human oriented. A compiler reading machine-oriented virtual machine code or an assembler reading machine-oriented assembly instructions are two examples of machine-oriented source code.

To illustrate the relationship between source code and object code, consider the following hypothetical source code:

while (a<10) {
a=a+1;
}

The object code generated by a particular compiler from this input might be machine-oriented assembly code such as the following:

10 BRANCH_IF_NOT_LESS_THAN REGISTER1 10 19
15 INCREMENT REGISTER1
17 BRANCH 10
19 END

By using this assembly code as the input to an assembler, however, the program now becomes a form of source code. Object code generated by the assembler is likely to be executable code for a specific computer and might look similar to the following:

E3 01 10 0019
B6 01
E2 10
FF

Note that most compiler suites (meaning a compiler, an assembler, a linker and the associated tools) are capable of generating an executable version of a program (immediately above) from its source code.

For Further Reading

[edit]

Des Watson. High-Level Languages and Their Compilers. Reading, Massachusetts: Addison-Wesley, 1989.
Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman. Compilers: Principles, Techniques and Tools. Reading, Massachusetts: Addison-Wesley Publishing Company, 1986.
Dick Grune, Henri E. Bal, Ceriel J.H. Jacobs, and Koen G. Langendoen. Modern Compiler Design. Chichester, England: John Wiley and Sons, Ltd., 2000.