Silly example of a Fortran code. It prints squares and cubes of numbers from 1 to 20:
PROGRAM TRY_FORTRAN
INTEGER X
PRINT 200, "X", "X^2", "X^3"
DO X=1, 20
PRINT 100, X, X**2, X**3
END DO
100 FORMAT (I20, I20, I20)
200 FORMAT (A20, A20, A20)
END
To compile this file, I run the fortran compiler with the option that recognizes the "free-form" source code (I don't like the fixed-code source):
g77 -ffree-form try_fortran.f
and now I can run the resulting executable (which has the default name is a.out):
./a.out
8.2.10 expect
expect
Scripting language for "programmed dialog". See man expect and email us a good illustration of how to use it :)
8.2.11 Delphi
kylix
This is a brand-new (Feb.2001) commercial offering from Borland (aka Inprise). In short, it is a Linux port of the famous object-oriented Pascal ("Delphi"). kylix is unlikely to be on your Linux distribution CD, you must pay for it, but if you want the best rapid application development (RAD) platform with a code portability between Linux, MS Windows and the Web, large number of pre-built components, etc., kylix is likely the best. In my opinion, Delphi is significantly better than MS Visual Basic.
8.2.12 Java
javac
java
The Java language compiler and interpreter. Under Linux, both javac and java are actually scripts which call kaffe with appropriate options (try cat /usr/bin/java).
A trivial example for a java "standalone" program. I use my favourite text editor, e.g. kate (in X terminal) to type in the following java code:
/* Comments are marked like in C++
* A java class to display "Hello World"
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World.") ; // Print "Hello World." followed by a newline
}
}
I save this into a file named try_java.java. Now, I can compile it using:
javac try_java.java
This creates a file called HelloWorldApp.class which contains the "bytecode" (semi-compiled code which requires an interpreter to run). I can run it on the command line using:
java HelloWorldApp
For an example on how to embed a simple java applet into an html web page, have a look at http://java.sun.com/docs/books/tutorial/getStarted/cupojava/unix.html from which my java "standalone" program was borrowed.
8.2.13 Using makefiles
make
Run the "make" utility to build (compile, link, etc) a project described in the Makefile found in the current directory.
make is used to bring a system "up to date", whenever a change in one file requires an action elsewhere. make is "intelligent" in that it will not make changes unless the change is required, as determined by the file modification date/time. Normally used for buiding software packages (compiling, linking ...), make is also used for other tasks, e.g., system administration. Makefile looks as follows:
target : prerequisites
[Tab]commands
where target is usually a file (but does not have to be, it can be a "phony" target), and prerequisites are files on which target depends. If target does not exist or is older than any prerequisites, "commands" are executed. The first line above is called "the rule", the second "the action". Please note that any action line must start with the tab character. Here is an example Makefile that makes an executable file called "edit":
my_program : main.o command.o
cc -o my_program main.o command.o
main.o : main.c defs.h
cc -c main.c
command.o : command.c defs.h command.h
cc -c command.c
clean :
rm my_program main.o command.o
To use this Makefile to create an executable file called "my_program', I type:

