There will be no attempt made to teach any of
the programming languages available
but a few words of advice are in order.
One of the reasons why the
system is a productive programming environment
is that there is already a rich set of tools available,
and facilities like pipes, I/O redirection,
and the capabilities of the shell
often make it possible to do a job
by pasting together programs that already exist
instead of writing from scratch.
The pipe mechanism lets you fabricate quite complicated operations
out of spare parts that already exist.
cat ... \f2collect the files\f3
| tr ... \f2put each word on a new line\f3
| tr ... \f2delete punctuation, etc.\f3
| sort \f2into dictionary order\f3
| uniq \f2discard duplicates\f3
| comm \f2print words in text\f3
\f2 but not in dictionary\f3
More pieces have been added subsequently,
The editor can be made to do things that would normally
require special programs on other systems.
For example, to list the first and last lines of each of a
set of files, such as a book,
you could laboriously type
But you can do the job much more easily.
to get the list of filenames into a file.
Then edit this file to make the necessary
series of editing commands
(using the global commands of
the same output as the laborious hand typing.
you can use the fact that the shell will perform loops,
repeating a set of commands over and over again
This sets the shell variable
to each file name in turn,
You can type this command at the terminal,
or put it in a file for later execution.
An option often overlooked by newcomers
is that the shell is itself a programming language,
many building-block programs,
you can sometimes avoid writing a new program
merely by piecing together some of the building blocks
with shell command files.
We will not go into any details here;
examples and rules can be found in
If you are undertaking anything substantial,
C is the only reasonable choice of programming language:
as are most of the programs that run on it.
It is also a easy language to use
C is introduced and fully described in
The C Programming Language
B. W. Kernighan and D. M. Ritchie
Several sections of the manual
describe the system interfaces, that is,
for more complicated things.
Most input and output in C is best handled with the
which provides a set of I/O functions
that exist in compatible form on most machines
In general, it's wisest to confine the system interactions
in a program to the facilities provided by this library.
C programs that don't depend too much on special features of
can be moved to other computers that have C compilers.
The list of such machines grows daily;
in addition to the original
Data General Nova and Eclipse,
Calls to the standard I/O library will work on all of these machines.
There are a number of supporting programs that go with C.
checks C programs for potential portability problems,
and detects errors such as mismatched argument types
and uninitialized variables.
(anything whose source is on more than one file)
allows you to specify the dependencies among the source files
and the processing steps needed to make a new version;
it then checks the times that the pieces were last changed
and does the minimal amount of recompiling
to create a consistent updated version.
is useful for digging through the dead bodies
but is rather hard to learn to use effectively.
The most effective debugging tool is still
careful thought, coupled with judiciously placed
The C compiler provides a limited instrumentation service,
where programs spend their time and what parts are worth optimizing.
Compile the routines with the
to print an execution profile.
will give you the gross run-time statistics
of a program, but they are not super accurate or reproducible.
there are two possibilities.
which gives you the decent control structures
and free-form input that characterize C,
yet lets you write code that
is still portable to other environments.
tends to produce large and relatively slow-running
Furthermore, supporting software like
etc., are all virtually useless with Fortran programs.
There may also be a Fortran 77 compiler on your system.
this is a viable alternative to
and has the non-trivial advantage that it is compatible with C
can be used with Fortran 77 too.)
If your application requires you to translate
a language into a set of actions or another language,
you are in effect building a compiler,
though probably a small one.
which helps you develop a compiler quickly.
lexical analyzer generator does the same job
for the simpler languages that can be expressed as regular expressions.
It can be used by itself,
or as a front end to recognize inputs for a
require some sophistication to use,
but the initial effort of learning them
can be repaid many times over in programs
that are easy to change later on.
systems also make available other languages,
Algol 68, APL, Basic, Lisp, Pascal, and Snobol.
Whether these are useful depends largely on the local environment:
if someone cares about the language and has worked on it,
If not, the odds are strong that it
will be more trouble than it's worth.