What Is Computer Source Code?

Source Code in Visual Studio

Source

Source Code

A program is a set of instructions given to a computer to tell the computer what to do. Without these instructions, the computer is completely useless. Because computers can only understand instructions in the form of binary code (ones and zeros), there exists the need to translate human instructions into machine code (binary numbers). To do this, programmers write these instructions in a human readable form called source code. The image on the right is a sample of what source code would look like in the C++ programming language using Microsoft Visual Studio 2010 Professional. Click on it to enlarge the picture.

Once the source code is written and saved, it can then be converted (or compiled) into machine code. In the first stage of translation, the pre-processor seeks out special commands at the beginning of the file called pre-processor directives. These commands begin with the "#" symbol, and refer to what are called header files. The pre-processor translates these header files into source code, which can then be used to check the rest of the program for syntax errors.

Object Code

Syntax errors are caused by the programmer incorrectly using the various elements of the source code. Once all of the source code is processed and translated into machine code, also called object code, it is saved into what they call an object file.

Three Types of Code

Executable Code

Finally, the last stage of translating the programmer's instructions into something that the machine can execute is performed by a program called the linker. The linker brings the object code and the C++ Programming language's runtime library code together, and saves the resulting executable code as an executable file. This is the full program file that can execute (or be run) on your computer. On the left, you’ll see a graphic simulating the three codes.

More by this Author


Comments

No comments yet.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working