Datasheet

530
An Overview of Programming
one or more options — the command is the first word in the line and the
rest are the options (specific behaviors for the computer).
Environment variables are essentially text strings with names. For
example, the PATH environment variable refers to a string that contains
the names of directories. Operating systems use environment variables
to provide useful information to processes. To see a list of environ-
ment variables in a Windows system, type set in the Command Prompt
window. In Linux, you can type printenv to see the environment
variables.
Basics of computer programming
A computer program is a sequence of instructions for performing a spe-
cific task, such as adding two numbers or searching for some text in a file.
Consequently, computer programming involves creating that list of instruc-
tions, telling the computer how to complete a specific task. The exact
instructions depend on the programming language that you use. For most
programming languages, you have to go through the following steps to
create a computer program:
1. Use a text editor to type the sequence of commands from the program-
ming language.
This sequence of commands accomplishes your task. This human-
readable version of the program is called the source file or source code.
You can create the source file with any application (such as a word
processor) that can save a document in plain-text form.
Always save your source code as plain text. (The filename depends on
the type of programming language.) Word processors can sometimes
put extra instructions in their documents that tell the computer to dis-
play the text in a particular font or other format. Saving the file as plain
text deletes any and all such extra instructions. Trust me, your program
is much better off without such stuff.
2. Use a compiler program to convert that text file — the source code —
from human-readable form into machine-readable object code.
Typically, this step also combines several object code files into a single
machine-readable computer program, something that the computer can
run.
3. Use a special program called a debugger to track down any errors and
find which lines in the source file might have caused the errors.
4. Go back to Step 1 and use the text editor to correct the errors, and
repeat the rest of the steps.
42_770191-bk08ch01.indd 53042_770191-bk08ch01.indd 530 8/6/10 9:51 AM8/6/10 9:51 AM