What is Programming?
- Problem to solve.
- Algorithm: Set of instructions to solve the
problem.
- Language: The language used to write the
algorithm.
In the logician's voice:
an algorithm is
a finite procedure,
written in a fixed symbolic vocabulary,
governed by precise instructions,
moving in discrete steps, 1, 2, 3,...,
whose execution requires no insight, cleverness, intuition, intelligence, or
perspicuity,
and that sooner or later comes to an end.
From The Advent of the Algorithm, by
David Berlinski
Edit-Compile-Run Cycle
Practical Steps for Creating and Running a Program
involve the following steps
- Edit:
Type the Java code into a text file. Any word processor will do as long as
you make sure you save to a "text" file. Make sure the file has extension
.java. For example, myProg.java.
- Compile:
Use the Java compiler (javac) to convert from the text file to bytecode. The
compiler will create a new file with the same name as the text file but with
the extension .class. For example, myProg.class. The bytecode can (in theory)
be transferred to any other computer and executed.
- Debug: If there
are any errors in your .java program, error messages will be generated and
the .class file will not be created.
- Run: To actually
run (execute) the program, you run the Java interpreter. There may be execution
errors such as divide by zero.
Visual Cafe (VC)
Visual Cafe is called an Integrated Enviroment
because it combines all of the following for you:
- A text editor that has special features convenient
for Java. For example, color coding of the code and some error checking.
- Most Java programs consist of multiple text
files. VC requires that you create a project which organizes all of your
files.
- VC has a debugger which help you find errors
in your program.
- VC has online Java API documentation so you can
easily look up information about the classes in the Java libraries.
- When you execute your program in VC, it
combines the Java compile and the Java interpreter into one step.
- Downside: "Integrated Environments" for programming
are inherently very complex and take sometime to learn. They also can frequently
crash so it is important to always keep back-ups of your work in a separate
folder. Also, you should save your work frequently.
To create a program in Visual Cafe, you must:
- Create a "project". The project will contain a listing of all the
Java files (class definitions) that
are used your program.
- You must specify whether or not your program is an Applet or an Application.
next lecture