Math 181 Computational Mathematics

9/99, 3/01

R. Robinson

A comparison of computing environments



Some conventional programming languages used for scientific computing
  See the web links page for references to some other languages.

Except for Java and Basic, most conventional languages are compiled rather than interpreted.

Basic can be either compiled or interpreted. For example, Visual Basic is compiled.

Java is "compiled" to a machine independent "byte code", which is then run by a Java "virtual machine". The virtual machine is essentially an interpreter, but is said to be faster.

Almost all CAS (including MATLAB) are typically interpreted.


In general, programs in compiled languages run faster than programs in interpreted languages.

Even faster  programs can be written in assembly language. Assembly language programs correspond in a more or less one-to-one way with machine language (rather than being compiled it is "assembled").

It is, however, more difficult than to use than the modern high level languages and is highly machine dependent.

Also, to achieve the speed you need to be a very good programmer (perhaps better than whoever wrote the compiler).



Some reasons to use compiled programming language (instead of MATLAB, Maple, etc.):
  1. For a  project that runs too slowly or is too large for MATLAB or Maple.
  2. To take advantage of large body of existing software.
  3. For more control of  I/O.
  4. To program to GUIs (using X- or MS windows).
  5. When you need control at hardware level.
  6. To make stand alone "application" programs.
  7. For a program that needs to run in real time.
  8. To take better advantage of high performance architecture features.
  9. To use parallel processing.
  10. If you are writing a CAS.
Notes:

Some disadvantages of conventional compiled programs:
  1. Lower level languages than CAS. Relatively simple mathematical operations (beyond basic arithmetic) must be programmed.
  2. Advantages of faster running time offset by much slower development time.
  3. More platform dependent than CAS.


Life cycle of compiled programs: Comments:
Compiling and linking often combined into one step.

Complicated jobs (Unix) use the "make" utility.

In windows, one frequently uses some kind of integrated development environment, e.g. Visual C++.


FORTRAN:

Really the first compiled language in regular use, Fortran was developed by John Backus at IBM  in 1957.

Currently two versions in are use FORTRAN 77 (still popular) and FORTRAN 90.

Fortran was developed for scientific computing (which in those days was essentially all computing).

Characteristics of FORTRAN 77:


Holdovers from Fortran IV (1964 Fortran) in FORTRAN 77 (which is not all that different).


Quote from Dowd and Severance:

It has been said "I don't know what language they will be using in high performance computers 10 years from now but I know it will be called FORTRAN"
There are millions of lines of FORTRAN 77 code still running and also in the public domain. Compiler optimization is targeted to the scientific computing market.

FORTRAN 90 was developed in early 1990's and includes many of the features thought to be missing from previous FORTRAN's.
 

Nevertheless, it has to some extent failed to catch on.

The C language.

Invented by Kernigan and Ritchie at AT&T Bell labs in 1978.

Closely associated with Unix operating system (C compiler is part of Unix).

The ANSI C language became the standard around 1990.

C (and C++) are used for virtually all commercial (i.e., non-scientific) software.

In some ways C is lower level than Fortran (more like assembly language). In some ways higher level (has more complex data structures).  C++ is a strange mix of low level and high level (object oriented programming).

Big difference from FORTRAN: C and C++ encourage the use of pointers.

This leads to a different preferred programming style.

However, pointers make optimization (by the compiler) difficult.



The C++ language

C++ is a superset of C (any valid C program is a valid C++ program).

It is implemented as a set of macros: C++ statements that compile down to C statements in the first step of the compilation process.

C++ was supposed to fix some of C's shortcomings (e.g. it has better I/O).

But most notably, C++ publicized the concept of object oriented programming: OOP

Objects (called classes) are structures that contain a mix of program (methods) and data (properties) organized around their function.

The concepts of modularity, information hiding, and inheritance are central to OOP.



The pointers of (inherited from C) together with the OOP philosophy make C++ a strange mix (high level and low level together).

Some people advocate it for scientific programming, but it is still not as popular as FORTRAN.

Other more pure object oriented languages exist.



Java

Perhaps the most celebrated OOP language is Java, which combines object orientation the ideas of the Java virtual machine and the Java applet.

Java is different form other interpreted languages in that it is compiled to a byte code first. In this form it is 100% portable.

Java was developed by SUN in 1994 and has been highly hyped by the media.


There have been some complaints about the way numerics have been implemented in Java.

SUN claims java is getting faster and will eventually be almost as fast as C.  The compilation to byte code does make it relatively fast compared to other interpreted languages but still noticeably slower than C or Fortran. Java also seems a little less stable than a compiled program.

In spite of these problems Java already being used seriously for scientific programming because of its portability (hardware has proven to be shorter lived than software).


Java is linked to the world wide web via applets which are special programs that run in a browser. They follow certain strict rules which prevent them from spreading viruses, etc.  Java can also run "applications".

Java Script is (sort of) a simplified version of Java that runs in browsers (browsers contain a Java Script interpreter). It is also object oriented.