Incremental Java
Text Editing

Text Editing

After designing the program (we'll skip this step for now), the next step is to type the program in some file. The minimal software needed is using an editor. An editor is basically a word processor, except we don't care that much about fonts. We don't need spell-checkers, or other features need to make a nice looking paper. A good text editor may help us find errors such as mismatched parentheses or missing semicolons. Some editors are very sophisticated, and are aware of some errors in your program as you type them.

Programmers often use a generic editor such as emacs (or on Windows, it's Notepad). These editors can be used to edit any text file, not just Java programs.

You would think we'd have advanced beyond typing in text for programs, but we haven't. While there are some visual programming languages that allow you to design a program by dragging widgets such as buttons onto a page, the most common way to write a program is typing in text.

Using a text editor usually requires specifying a file to be opened. For example, if you used emacs, you'd type:

% emacs Foo.java
This is done at a prompt in a UNIX shell. This would start the emacs editor. emacs has a Java mode, so it can help make your Java code look nice, and provide some basic features to avoid some of the simpler errors.

Many programming language books like to avoid talking about the editor. After all, there are maybe dozens of different editors. It's possible to have editors that vary from version to version (though it's rare). Even if you explain how an editor works, you then have to explain how to get the editor on your machine, and maybe you don't have a PC. Maybe you have a Mac, or maybe a Sun, or maybe you don't have sys admin privileges to install software, or maybe you've never installed software.

As you can see, just editing a program can be a complete hassle, and books seem to avoid talking about it because they don't want to lock you down to one editor.

We'll briefly discuss how to use the emacs editor, and take the route that so many others have, by not dealing with the editor that much.