Computers have become an important part of scientific research and technical development. They are essential both for collecting and analyzing experimental data and for solving complicated mathematical problems arising from theoretical considerations. Due to modern computing environments many scientists and engineers do not any programming in compiled languages like C or Fortran at all, but if they do they should do it in efficient way.
It is hard to define exactly what is Scientific and Technical Efficient Programming (STEP) but two main features are clear.
- It is not evident whether the result is right or wrong. It is even difficult to say what do we mean by “wrong”, it might be bug in the code or inaccuracy in the model or numerical instability, and it is much more difficult to prove that result is correct.
- Scientific application should always be tuned to get peak performance. The more computer power we have the more accurate results we can get, more complex problem can be solved.
These characteristics make standard programming and debugging techniques described in the most of programming books and courses useless. STEP demands scientific knowledge, the proficiency in numerical analysis, computer architecture and programming languages. All attempts to screen the programmer from “gory details” are bound to failure, unless problem is very simple.
In my opinion only two of modern languages namely C/C++ and FORTRAN/Fortran are fit for STEP. (I see C++ as improved C and Fortran as improved FORTRAN.) None of them is better than other and both have their strong and weak points. One can write good or bad (or ugly) program in any language. From the performance point of view nothing can beat assembler.
All function that affects performance is written in assembler and C code is just used for wrapper of assembler functions or complicated functions. Also I use many inline assembler functions,unfortunately most of commercial compiler can’t handle inline assembler.
Kazushige Goto,GotoBLAS2 FAQ
C is more flexible and closer to hardware but some important constructions are absent, mainly multidimensional arrays (though it has more flexible but less efficient one – array of arrays). Working in industry I used C and C++ for numerical alculations and even rewrote some FORTRAN codes. However I recognized that most of my code deals with very rigid structures which simply reflect standard FORTRAN ones. Actually it is not surprising since most of numerical algorithms were desingned with FORTRAN in mind.
One the other hand most of FORTRAN deficiencies were corrected in Fortran. It is modern programming language, with dynamic memory allocation, standard C interoperability and a lot of other good things.