An Overview of the Programming Process
Read the introduction to computers before continuing with this section. The introduction to computers
includes a summary of how a program runs on a computer. This section continues from there, giving an
overview of how programs are created by a computer programmer (a person who creates computer programs is called a computer programmer).
The steps to create a program are:
- Design the program (on paper, in your head, via a design program, etc.)
- Write the instructions for the program in a high-level programming language such as Java.
- Use a text editor to save the Java instructions in a file on the computer.
- Translate your instructions into the computer's language (the computer's language is called 'machine code')
- Run the program.
- Verify that the program is running correctly
If the program has errors, you will need to use the text editor to fix the faulty instructions (step three), then repeat steps four through six. Errors that occur in a running program are called bugs. The language that the computer understands, called machine language or machine code, is very hard to for humans to read and write.
The languages that humans use (e.g., English, French, Arabic, Chinese) are far too powerful and
complex for a computer to understand.
The current method to resolve this gap is for the human (the programmer) to write the instructions in
a special language that is somewhere inbetween the simplistic computer language and the powerful
human languages. This specialized language looks a bit like human languages, and yet it is simple
enough that it can be translated
to machine language via a language translator program called a compiler. Therefore, the process is to write the program in the kind-of-human-like language and then use a compiler to translate the
instructions to machine code. These kind-of-human-like langauges are called programming languages,
and there are many to choose from. Java is the programming language discussed here.
Therefore, you will have to learn the Java language, and you will need to get a Java compiler. You can
get the Java compiler from Sun Microsystems, Inc.
A Simplified First Example
Here is the programming process, step-by-step, to create and run a sample Java program. The name of the sample program is Demo.
First, write the Demo program in the Java language, then use an text editor to enter the program onto the computer's disk. Save the Java instructions in a file named Demo.java:

Use the Java compiler (the compiler is not shown in the picture below) to translate the Java instructions to machine language. Keep the
machine language instructions in a file named Demo.class. At this point you have two
copies of the same program, written in two different languages. You can understand the Java version, the
CPU can understand the machine language version.

Start to run the program by making a copy of the Demo.class and loadiong it into memory.

Once the machine language instructions are in memory, then the CPU can start following (performing)
the instructions:

Filling in some Gaps A lot was left out of the above explanation. I'll clear up a couple of those missing details here. In the example above, I only showed the code written by the programmer. Every program has a lot of standard code that is necessary for the program to run correctly. Instead of having every programmer write this same standard code for every program that gets developed, this code is supplied to all programmers in a library. When the code that you, the programmer, have written is loaded into memory, it is linked up with large chunks of library code. The library code is not shown in my pictures (or mentioned much outside of this paragraph).
Another detail is that Java is not actually translated straight to machine code, as described above. Most programming languages are translated straight to machine code. These are languages like Ada, FORTRAN, C, C++, C#. However, Java does something a little bit different. It translates your Java instructions to something that is almost machine code -- something that Java calls
byte code.
Java does not translate straight to machine code because there are
several different manufacturers of CPUs, and each manufacturer's CPUs have different machine
languages. Therefore, when a compiler translates to a machine language, it is compiling to
one specific kind of CPU. The translated version will work on that manufacturer's CPU, and none of the others:

If the programmer wants to sell his or her program to every kind of computer, he or she needs to translate
it to every kind of computer. This means that the programmer must do a seperate translation for every platform onto which they want to sell their program. This requires a different compiler program for each platform, and requires selling the appropriatly translated program to each customer.
Java overcomes this problem by translating once to a generic machine language --byte code -- which is very similar to all of the machine languages, but not exactly any one of them. The
Java scheme is to try to have a program called the Java Virtual Machine (JVM) installed on (hopefully) all computers. The JVM knows how
to do the last little translation from the generic machine language ('byte code') to the specific machine's machine language. This allows the programmer to deliver a single byte code image to several different platforms:

Therefore, the full process of developing and running a Java program is to write the Java code (Demo.java),
translate that code to byte code (Demo.class), load the Demo.class byte code to memory (and also load some library code),
then run the program's instructions on the CPU via the Java Virtual Machine (JVM).
Summary -- The Complete Process
1. Come up with an idea for the program. Possibly write the idea down on paper, or maybe even use a design program (many programmers plan their programs in a visual design language called UML).
2. Express your ideas in as Java instructions.
3. Use a text editor to put enter the Java instructions onto the computer's disk drive:
3. Translate the Java instructions into byte code.
4. Make a copy of the byte code and load into memory, along with some necessary extra library code supplied by the Java system.
5. Run the program. The byte code is run through the JVM, which does a last
second translation from the byte code (which is almost machine language) into the
actual machine language for this CPU.

The programming process can be greatly aided with the use of
a integrated development environment (IDE) program.
|