The Early Days of Programming
During the early 1980s, Chris worked for a computer software firm. The firm
wrote code for word processing machines. (At the time, if you wanted to
compose documents without a typewriter, you bought a “computer” that did
nothing but word processing.) Chris complained about being asked to
write the same old code over and over again. “First, I write a
search-and-replace program. Then I write a spell checker. Then I write
another search-and-replace program. Then, a different kind of spell
checker. And then, a better search-and-replace.”
How did Chris manage to stay interested in his work? And how did
Chris’s employer manage to stay in business? Every few months, Chris had
to reinvent the wheel. Toss out the old search-and-replace program, and
write a new program from scratch. That’s inefficient. What’s worse,
it’s boring.
For years, computer professionals were seeking the Holy Grail — a way
to write software so that it’s easy to reuse. Don’t write and rewrite
your search-and replace code. Just break the task into tiny pieces. One
piece searches for a single character, another piece looks for blank
spaces, a third piece substitutes one letter for another. When you have
all the pieces, just assemble these pieces to form a search-and-replace
program. Later on, when you think of a new feature for your word
processing software, you reassemble the pieces in a slightly different
way. It’s sensible, it’s cost efficient, and it’s much more fun.
The late 1980s saw several advances in software development, and by
the early 1990s, many large programming projects were being written from
prefab components. Java came along in 1995, so it was natural for the
language’s founders to create a library of reusable code. The library
included about 250 programs, including code for dealing with disk files,
code for creating windows, and code for passing information over the
Internet. Since 1995, this library has grown to include more than 3,000
programs. This library is called the API — the Application Programming
Interface.
Every Java program, even the simplest one, calls on code in the Java
API. This Java API is both useful and formidable. It’s useful because
of all the things you can do with the API’s programs. It’s formidable
because the API is so extensive. No one memorizes all the features made
available by the Java API. Programmers remember the features that they
use often, and look up the features that they need in a pinch. They look
up these features in an online document called the API Specification
(known affectionately to most Java programmers as the API documentation,
or the Javadocs).
The API documentation describes the thousands of features in the Java
API. As a Java programmer, you consult this API documentation on a
daily basis. You can bookmark the documentation at the Sun Microsystems
Web site and revisit the site whenever you need to look up something.
But in the long run (and in the not-so-long run), you can save time by
downloading your own copy of the API docs.