REAL A, B, C INTEGER AROWS, ACOLS, BROWS, BCOLS, CROWS, CCOLS DIMENSION A(AROWS, ACOLS), B(BROWS, BCOLS), C(CROWS, CCOLS) call matmult(A, B, C, AROWS, ACOLS, BROWS, BCOLS, CROWS, CCOLS)You might ask: "What is wrong with that?" There is nothing wrong but it is ugly and not optimal with respect to coding efficiency. So what is the problem? The problem is that you have to know about the internal representation of a matrix at any time you use it. As a consequence you have to keep your mind on details which are far below the abstraction level you usually think at. If you look into typical scientific program packages (FORTRAN) you will most likely find subroutine calls with very long lists of parameters (I have seen a hundred parameters). This is a typical symptom of a lack of abstraction. You might say: "But I was told to use parameters instead of common blocks!" If you have nothing better this is true: You should use parameter passing instead common blocks. However, having a hundred parameters in one subroutine call is not really funny. Have you ever tried to understand such a program later?
Polemically speaking one might say that the highest level of abstraction FORTRAN provides is that of the basic arithmetic operations (+,-,*,/), functions and numbers. This is much too less. Theoretical physics and mathematics are in fact a playground for high level abstractions. If you use FORTRAN you restrict yourself to a pocket calculator.
Turning back to the above example what you really meant is:
Matrix A, B, C; C = A*B;Exactly this is possible with C++. Now you might argue that FORTRAN90 provides you with the type "Matrix" and you can do something similar. That might be true. But the point is: FORTRAN90 does not provide you with the power to implement and integrate anything new as if it were an intrinsic element of the language. In other words: Within C++ there are hardly any intrinsic high level data types but C++ provides you with a very powerful grammar enabling you to integrate whatever you can think of. There is much more about object orientation but this is at the heart of it.
Finally, let me show another example from coupled cluster:
Expression T = ClusterOp(1) + ClusterOp(2) + ClusterOp(3); // T_1 + T_2 + T_3 Expression Heff; Heff = exp(-T)*H*exp(T);This really works... You can try it out here.
Declarative statements in FORTRAN are for example
INTEGER a DIMENSION a(10)Declarative statements in C++ for the above Matrix example could be
class Matrix { Matrix operator * (const Matrix &) const; ... };This actually does nothing but tells the compiler (and anyone else) that two matrices may be multiplied returning a new Matrix.