Programming 101 – addendum

Before I go with the lecture for week 2, I need to go back and explain something about compiling. When you compile your textfile with the .java extension, you usually do this from a Command Line Interface (CLI) or from an Integrated Development Environment (IDE).

The CLI is a basic part of most operating systems (the old MAC OS 9 being the exception) where you can enter commands directly to the computer. This was the old one and true way to interface with computers in the olden days, and you can read a homage to CLI here.

The way to use the CLI to compile a program would go something like this:

Just like writing the actual code, using the CLI isn’t really very friendly.
You have to know the syntax of the command line as well. In the highlighted Step 2, You use the program “javac” to compile your textfile “”.
In the highlighted step 3, you use the Java Virtual Machine “Java” to run the newly-compiled “FirstApp” (apparently, there’s no need to add the extension “.class”).
As you can see, running the program results in the computer printing the message “Hello CS 170” on the screen.

In Computer Science tradition, it is a virtue for the computer to give as little “noise” as possible. Therefore, as long as the program executes correctly, it offers no more information than is demanded by the program being run. In this way, the only way we know that the program compiled correctly is by the fact that we regain the command prompt and that no error message occurred.

The compiler isn’t really very helpful when it actually comes to error messages, anyway. And when you build larger programs consisting of many small bits and pieces, it’s easy to lose track of them all on the command line. Even so, a lot of purists, including my friend Stefan, use just a text editor (such as the wondrously complicated Vim and Emacs) and a compiler directly from the command line.

Thus the IDE:

The IDE contains everything you need to write, compile and test your code. It uses a graphical user interface to seperate the different elements. There’s a text editor (on the left) and a project overview (on the right) that makes it easy to keep track of the different bits of code, and whether they’ve been compiled or not. You can compile a chunk of code simply by pressing the “compile” button, and run it by pressing the “run” button. Deceptively easy.

There are many different IDE’s made for Java. Apparently, Eclipse is the most popular one as it aims to be a universal IDE (ie. it also works with all sorts of other programming languages) but so far, I’ve enjoyed using BlueJ which attempts to keep the bells-and-whistles-count low, and the ease of use high.

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>