If you want to write programs on utstat you have quite a range of choices of languages to write in. These are of several sorts, as follows:
There are also libraries of routines available to help in writing programs.
Programming in traditional languages involves creating a program with a text editor, running a “compiler” to translate it to machine language, and finally running the resulting program in the same way as a Unix command. These languages are most appropriate for writing programs that are large and complex, or which need to be very efficient.
Program source files are by convention given names ending in a suffix identifying the language, as follows:
.c C program
.c++ C++ program
.f Fortran program
For example, fred.c might hold the source for a C program, or part of a C program.
When a source file is compiled, a corresponding file ending in “.o” will be created (eg, fred.o). A final program file, perhaps derived from several source files, will also be created. For example, you would use the following commands to compile a C program that consists of two parts, stored in files part1.c and part2.c, and then run it:
cc part1.c part2.c -o myprog
The -o myprog option says what the name of the final program should be (the default is a.out), which is what you type to run the program.
C and C++ are the most popular languages for writing programs that need to be computationally efficient, or which need access to special hardware or operating system facilities. C++ is an extension of C to include “object oriented” facilities. There are many books on C and C++ in the U of T bookstore.
C programs are compiled on fisher with the cc command. C++ programs are compiled with CC (uppercase).
The gnu C and C++ compilers are also available on both fisher and photon, under the names gcc and g++.
Fortran is a traditional language for scientific computation. There are two version of Fortran on utstat: Fortran 77 and Fortran 90. They are obtained with f77 and f90 commands.
For all these languages, bugs can result in the program terminating with a message such as “Segmentation fault (core dumped)” or “Bus error (core dumped)”. A file called core will be created, which contains the state of the program when the error occurred. You can examine what happened with a debugger. Currently, it seems the only debugger we have is the gdb on fisher, which works best on programs compiled with gcc or g++. The simplest thing that gdb can do for you is to tell where in the program the error occurred. If you get a core dump when running program “fred”, the commands
gdb fred core
will result in a stack trace, showing where in the program the error occurred (source file name and line number). Core files can be quite big, so please remove them when they are no longer needed.
The make program is useful for managing large programs consisting of many parts. See “man make” for details.
Scripting languages are meant for doing fairly small tasks, especially those involving lots of character manipulation, or invoking various other programs on the right data. These languages are “interpreted” rather than compiled, which makes developing small programs somewhat more convenient than is the case for traditional languages.
See “man perl” and “man perldata”, etc. for documentation. There is a Perl web site with up-to-date information.
We seem to not have tcl at the moment. We probably ought to…
Java is similar in many respects to traditional languages such as C++, but with an environment that lets you easily write programs that run within a Web browser (such as netscape).
Many books on Java are available at the U of T bookstore. There is also a Java web site with up-to-date information.
The Java Development Kit is installed on fisher and photon, in the directory /usr/java. To write Java programs, you will need to add /usr/java/bin to your PATH variable (see setting Unix options in your .profile file). For more information, look at the man pages with a command such as
man -M /usr/java/man java
The easiest way to develop programs is probably in an interactive environment, in which you can easily debug components of the program by running them interactively. The programming languages that are part of the mathematical software and statistical packages are of this sort. They are probably your best choice for writing many programs for statistical applications.