Next: Scientific programming in C
Up: Introduction
Previous: Programming methodologies
What is the best high-level language to use for scientific
programming? This, unfortunately, is a highly
contentious question. Over the years, literally hundreds of high-level languages
have been developed. However, few have stood the test of time. Many languages
(e.g., Algol, Pascal, Haskell) can be dismissed as ephemeral computer
science fads. Others (e.g., Cobol, Lisp, Ada) are too specialized
to adapt for scientific use.
Let us examine the remaining options:
- FORTRAN 77:
- FORTRAN was the first high-level programming language to be developed: in fact,
it predates the languages listed below by decades. Before the advent of FORTRAN, all programming
was done in assembler code!
Moreover, FORTRAN was specifically designed for scientific computing. Indeed, in the early
days of computers all computing was scientific in nature--i.e.,
physicists and mathematicians were the
original computer scientists!
FORTRAN's main advantages are that it is very straightforward, and it interfaces well with
most commonly available, pre-written subroutine libraries (since these libraries
generally consist of compiled FORTRAN code). FORTRAN's main disadvantages are all
associated with its relative antiquity. For instance. FORTRAN's control
statements are fairly rudimentary, whereas its input/output facilities are positively paleolithic.
- FORTRAN 90:
- This language is a major extension to FORTRAN 77 which does away with many of
the latter language's objectionable features. In addition, many ``modern'' features,
such as dynamic memory allocation, are included in the language for the first time. The major
disadvantage of this language is the absence of an inexpensive compiler.
There seems little prospect of this situation changing in the near future.
- C:
- This language was originally developed by computer scientists to write operating systems.
Indeed, all UNIX operating systems are written in C.
C is,
consequently, an extremely flexible and powerful language. Amongst its major
advantages are its good control statements and
excellent input/output
facilities. C's main disadvantage is that, since it was not specifically written to be a
scientific language, some important scientific features (e.g., complex arithmetic)
are missing. Although C is a high-level language, it incorporates many comparatively low-level
features, such as pointers (this is hardly surprisingly,
since C was originally designed to write operating systems). The low-level features of C--in particular,
the rather primitive implementation of arrays--sometimes make scientific programming more complicated than need be the
case, and undoubtedly facilitate programming errors. On the other hand, these features allow
scientific programmers to write extremely efficient code. Since efficiency is generally the most
important concern in scientific computing, the low-level features of C are, on balance,
advantageous.
- C++:
- This language is a major extension of C whose main aim is to
facilitate object-orientated
programming. Object-orientation is a completely different approach to
programming than the
more traditional procedural approach: it is particularly well suited to large projects involving
many people who are each writing different segments of the same code. However, object-orientation
represents a large, and somewhat unnecessary, overhead for the type of straightforward, single person
programming tasks considered in this course.
Note, however, that C++ incorporates some non-object-orientated extensions to C which are extremely
useful.
Of the above languages, we can immediately rule out C++,
because object-orientation is an unnecessary complication (at least, for our purposes), and FORTRAN 90, because of the absence of an inexpensive
compiler. The remaining options are FORTRAN 77 and C.
I have chosen to use C (augmented by some of the useful, non-object-orientated
features of C++) in this course, simply because I find the archaic features of
FORTRAN 77 too embarrassing to teach students in the 21st century.
Next: Scientific programming in C
Up: Introduction
Previous: Programming methodologies
Richard Fitzpatrick
2006-03-29