Just so you know, I don't know FORTRAN at all.
A little something from the end of
this page
Programmers tend to over-estimate the usefulness of the programs they write. The approximate value of an optimization is:
number of runs × number of users × time savings × user's salary
- time spent optimizing × programmer's salary
Now the first biggie is which languages do you know?
It's no use learning FORTRAN if some report or other says that it has a 10% advantage, if it takes you months to learn, and years to get good at it. Any naive programming on your part will soon erode any advantage there may have been, simply from not knowing how to use the language to it's best.
Consider how expressive the language is. C++ would seem to have the upper hand here. The STL allows you to focus more on the problem rather than the solution. For example, if you want a list in C++, just use the STL list container. In C, you'd have to write (or dig out from some previous project) a whole new list implementation (and debug it). Put bluntly, if you can write it in a week in one language, but it might take 3 months in another, does this affect your choice?
Also consider how long it takes to debug such a program - what tools are available to help you? Modern IDE's for C++ help you a great deal, are there similar feature rich tools for FORTRAN?
How easy is it to write bug-free code in the language of your choice?. C is notorious for having many traps for the inexperienced C coder, many of which can remain hidden for a long time.
With the exception of Java (as already noted), all the languages are compiled to native instructions for the target machine. In a like-for-like program, you're just not going to see orders of magnitude differences between one language and another.
Quite often, the easiest thing to do is wait for Moore's law to do it's bit and buy much faster hardware later on.
> The big problem with C/C++ is multi-dimensional arrays.
What an odd thing to say.
But given you said "Passing a 3D array as int***", I can see how you've always had problems.
Code:
#include <stdio.h>
void foo ( [COLOR=blue]int a[2][3][4][/color] );
int main ( void ) {
int x, y, z;
[COLOR=blue]int a[2][3][4][/color];
foo ( a );
for ( x = 0 ; x < 2 ; x++ ) {
for ( y = 0 ; y < 3 ; y++ ) {
for ( z = 0 ; z < 4 ; z++ ) {
printf( "%d ", a[x][y][z] );
}
printf("\n");
}
printf("---\n");
}
return 0;
}
void foo ( [COLOR=blue]int a[2][3][4][/color] ) {
int x, y, z;
for ( x = 0 ; x < 2 ; x++ ) {
for ( y = 0 ; y < 3 ; y++ ) {
for ( z = 0 ; z < 4 ; z++ ) {
a[x][y][z] = x + y + z;
}
}
}
}
Passing arrays to functions in C or C++ is simple, you simply copy/paste the declaration of the array you want to pass to the function into the declaration/definition of the functions parameters (the blue bits). Not a '*' to be seen, and notice how the array syntax inside the function is exactly the same as the array syntax in main.
Some fussy compilers will no doubt warn you that the left-most dimension is immaterial, so you might need to edit the function down to this.
[tt]void foo (
int a[][3][4] );[/tt]
But that's all you should ever need to do.
Sure, if you want some stars, then you could write
[tt]void foo (
int (*a)[3][4] );[/tt]
but don't make the mistake of assuming this is in any way the same as
[tt]void foo ( int ***a );[/tt]
because it isn't.
Too many people get hung up on either
equivalence, or assume that since arrays are passed as pointers that they have to riddle all their functions with pointer syntax.
--