Subsections

2.2 Text editors

The first thing we need to do is to write some code. This obviously involves tapping away on the computer keyboard, but we are also dependent on software to record and manage our keystrokes in an effective manner.

An important feature of the computer code that we will write is that it is just plain text. There are many software packages that allow us to enter text, but some are more appropriate than others for entering computer code.

2.2.1 Text editors are not word processors

For many people, the most obvious software program for entering text is a word processor, such as Microsoft Word or Open Office Writer. These programs are not a good choice for editing computer code. A word processor is a good program for making text look pretty with lots of fancy formatting and wonderful fonts. However, these are not things that we want to do with computer code.

The programs that we use to run our code expect to encounter only plain text, so we must use software that creates only text documents, which means we must use a text editor.


2.2.2 Important features of a text editor

For many people, the most obvious program for entering just text is Microsoft Notepad. This program has the nice feature that it saves just text, but its usefulness ends there.

When we write computer code, a good choice of text editor can make us much more accurate and efficient. For example, the following facilities are useful in a text editor:

atomatic indenting:
as we will see in Section 2.9, it is important to arrange code in a neat fashion. A text editor that helps to indent code (place empty space at the start of a line) makes this easier and faster.
parenthesis matching:
many computer languages use special symbols, e.g., { and }, to mark the beginning and end of blocks of code. Some text editors provide feedback on such matching pairs, which makes it easier to write code correctly.
syntax highlighting:
all computer languages have special keywords that have a special meaning for the language (e.g., anything of the form <name> in HTML). Many text editors automatically colour such keywords, which makes it easier to read code and easier to spot simple mistakes.
line numbering:
some text editors automatically number each line of computer code (and in some cases each column or character as well) and this makes navigation within the code much easier. This is particularly important when trying to find errors in the code (see Section 2.4).

2.2.3 Text editor software

In the absence of everything else, Notepad is better than using a word processor. However, many useful (and free) text editors exist that do a much better job. Some examples are Crimson Editor and Textpad on Windows, and Kate on Linux. The ultimate text editor is a cross-platform software package called Emacs, which is extremely flexible and powerful, but it does have a steeper learning curve.

2.2.4 IDEs

Professional code writers will often use an integrated development environment (IDE). These provide even greater support for writing code, but they tend to focus on a single computer language. An exception is the Eclipse package, which can be customized for many different languages, but again, the learning curve is steeper with this sort of software.

Paul Murrell

Creative Commons License
This document is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.