Scientific programming

for non-programmers

by Nikolai Shokhirev

IT Tutorials  | ABC Tutorials  |   Home

Introduction

There are some fields (e.g. science, engineering, education) where the development of ideas, concepts, models and methods is more time-consuming than the accompanying computations. In such areas tools like Mathematica (http://www.wolfram.com), MATLAB (http://www.mathworks.com) and Maple (http://www.maplesoft.com) are widely used. 

There are also several free tools:

MAXIMA is a fairly complete computer algebra system. (http://www.gnu.org/software/maxima/) Symaxx/2 is a graphical front-end for the Maxima computer algebra system (http://symaxx.sourceforge.net/).

Clones of MATLAB: GNU Octave is a high-level language, primarily intended for numerical computations. (http://www.octave.org/). Scilab is a scientific software package for numerical computations (http://scilabsoft.inria.fr/). Freemat is a matrix-oriented development environment for engineering and scientific applications (http://sourceforge.net/projects/freemat/).

Advantages of tools for doing symbolic and/or numeric calculations:
1. Abundance of built-in methods and features
2. Flexibility with a variety of supporting techniques 
3. Scripting and programming abilities for further enhancement 

Drawbacks:
1. Necessary to learn a lot of features
2. Restriction of flexibility by predefined approaches
3. Necessary to learn tool-specific programming methods or
4. Use of  third party add-ins

The alternative approach is to use high-level programming languages. Note that, in such areas programming is usually only a tool. This approach has its advantages and disadvantages as well.

Advantages:
1. Relatively small number of language elements
2. Flexibility is (almost) unlimited
3. Potential high efficiency
4. Self-sufficiency
5. Freedom!

Disadvantages:
1. Necessary to write programs from scratch
2. Relatively low productivity (for non-professional programmers)

To whom this tutorial is addressed

Platform/Language/Tool selection

Platforms

The most popular platforms are

  1. Windows
  2. Linux (and the other Unix-like systems)
  3. Java (this is a language and a platform itself)
  4. .Net-platform

Windows software dominates in the areas of word, data, and image processing (Mac-programming is out of the scope of this tutorial). To be realistic, we should focus on Windows with the possibility of migrating to Linux.

Languages

Visual Basic (VB) is among the most popular programming languages in the world. It has an advanced development environment with a component-based Graphical User Interface (GUI) design. However VB is not designed for numeric calculations and lacks good numeric libraries.  

All classical scientific algorithms were developed in the 60's in Algol and Fortran (see e.g. [1, 2]). Fortran was designed specifically for numerical calculations (ForTran = Formula Translator). Later, it evolved towards Object-Oriented Programming (OOP). Fortran still beats all languages at all platforms in efficiency. Unfortunately, Fortran was completely eliminated from computer science courses and now even many engineers do not know it. 

Later the algorithms were rewritten and further developed in many other languages. In particular, a lot of numerical libraries were developed in C++ and Java.

Java is a pure OOP cross-platform language, but the development (specially GUI) is a tough task for non-professional programmers (see, however, Borland's JBuilder).

C++ was the first successful OOP language. But actually, it is an OO extension of the low-level c-language. C++ is clamed to be for universal programing. However, programming in any particular area is not an easy task [3] (for a non-professional programmer, see the sub-title above).  

Scientific/engineering programming does not require a lot of object-oriented programming (OOP). Pure procedural languages (e.g. C and Fortran) work just fine. In my opinion the choice of language is not important for our purpose (the quick sort will beat the bubble sort in any language). More important are development and debugging tools, compilers, text and graphic support, and the performance to price ratio. 

Development tools

Microsoft Visual Studio has excellent visual design support both for VB.Net and C#. However Visual C++ IDE is far behind of the first two. 

Borland products (Delphi, C++Builder, Kylix, C#Builder, JBuilder) have a unique combination of features. They traditionally are very efficient and user friendly. They all extremely simplify the graphical user interface development (Rapid Application Development - RAD). Open, personal and academic editions are free or relatively  cheap. The integrated development environments (IDE) for Object Pascal and C++ are available both for Windows and Linux.

 Language

Platform / Tool

 Windows  Linux
 Object Pascal   Delphi  Kylix
 C++  C++Builder   Kylix 3  

I would recommend Delphi versions 4 to 7, C++Builder 5 and 6, Kylix 3 (it contains both Object Pascal and C++ IDE's). Delphi 8 is for the .Net platform. Delphi 2005 is multi-language (including C#) IDE and supports Win32 and .Net but it is not available in a personal edition. Object Pascal is a high-level language with the object model similar to Java. Borland's  Pascal compiler is extremely fast and produces very efficient code.

Also worth mentioning is Lazarus, the Delphi-like IDE for Free (Object) Pascal. This is a real RAD IDE with code completion and other advanced features. It is currently available for Windows and Linux Mac and some other platforms. This is an open-source (free) tool.

Another nice (and free) development tool for the .Net platform (C# and VB.Net) is #develop .C# was developed by Anders Hejlsberg [4], the author of Turbo Pascal and the chief architect of Delphi.

DevCpp and DevPas are the free tools from Bloodshed Software for C++ and Free Pascal. They have full-featured IDEs, although they are not RAD tools  (see also http://www.c-view.org/soft/devcpp/   http://www.maybe-phil.net/websites/no-skill/jnrdev/en/howtosdldevcpp/ http://www.wxwindows.org/devcpp.htm ).

Links to the comparison of some discussed visual tools [5-10].

References

  1.  J. H. Wilkinson, C. Reinsch, Handbook for Automatic Computation, Volume II, Linear Algebra, Springer-Verlag, New York, Heidelberg, Berlin, 1971
  2. George E. Forsythe, Mike A. Malcolm, and Cleve B. Moler, Computer Methods for Mathematical Computations, Englewood Cliffs, N.J.: Prentice Hall, 1977.
  3. Sean Barrett. Why C++ Sucks, http://nothings.org/computer/cpp.html 
  4. Anders Hejlsberg http://en.wikipedia.org/wiki/Anders_Hejlsberg 
  5. Marco Cantù. Comparing OOP Languages: Java, C++, Object Pascal, http://www.marcocantu.com/papers/ooplang.htm 
  6. Dan Miser. Delphi and C# comparison, http://distribucon.com/blog/archive/2004/04/26/178.aspx 
  7. Ernesto De Spirito. A comparison between Delphi and Visual Basic, http://www.latiumsoftware.com/en/articles/00010.php 
  8. Steve Scott. Microsoft Visual Studio .NET: A View From Across The Fence, http://www.thedelphimagazine.com/samples/1212/1212.htm 
  9. C++ Builder vs. Visual C++, http://boumchalak.net/content/view/98/2/ 
  10. Microsoft Visual C++ vs. Borland C++Builder. http://www.slim.sytes.net/~kztakeda/comp/bcb/vc_bcb_e.html 
  11. VC++ vs. C++Builder, http://www.devhood.com/messages/message_view-2.aspx?thread_id=31628  

Tutorials

Downloads

IT Tutorials  | ABC Tutorials  |   Home