Common Compiled Languages

C/C++

C and C++ are the most popular compiled languages for general use over the past several decades. Both are commonly used for scientific programming. Most compilers and interpreters are written in C and C++.

C is a very simple, but powerful high level language that was developed in unison with the Unix operating system. In fact, most of the Unix operating system is written in C. C became the dominant general-purpose programming language on other operating systems such as DOS and Windows during the 1980's. DOS and Windows are also largely written in C. C is best known for producing the fastest code possible in a portable high-level language.

C++ is an extension of C that adds a wealth of new features, many of which are aimed at object-oriented programming. Object-oriented programming encourages more modular design of programs, which can be critical for large applications. Most modern languages now have features to support object-oriented programming.

Unlike C, C++ is an extremely complex language that requires a great deal of knowledge and experience in order to use effectively. It is a powerful tool for scientific programming, but has a much high learning curve than C. Mastering the C++ language and keeping up with the new features that are frequently added is a career in and of itself.

Note also that it is possible to write object-oriented code in any language, as covered in Chapter 29, Object Oriented Programming. There are numerous resources on the web detailing how to apply object-oriented design principles in C.

Fortran

Fortran (Formula Translator) was the first major high-level language, created by a team at IBM led by John Backus in the 1950's. Fortran is a compiled language, originally designed for scientific computing, and has been the most popular scientific programming language throughout most of computing history. Fortran has always had many convenient features for scientific computing, such as built-in mathematical functions, and seamless, efficient support for complex numbers. Performance of Fortran programs is comparable to C or C++.

Fortran is still the language of choice in many areas of scientific computing, including weather forecasting, molecular modeling, etc. A great deal of Fortran software is under active development today, and the future of Fortran appears to be bright.

Conclusion

For the average scientist or engineer who needs to write fast code, C is a good starting point. It is a simple language that can be mastered in a relatively short time, unlike C++. It also provides all the features that are needed by most scientific programmers.

Practice

Note

Be sure to thoroughly review the instructions in Section 2, “Practice Problem Instructions” before doing the practice problems below.
  1. What is the primary difference between C and C++ from the perspective of a scientist learning to program?

  2. Is Fortran still useful, despite being from the 1950s?