[SciPy-user] python (against java) advocacy for scientific projects

Sturla Molden sturla@molden...
Tue Jan 20 13:48:27 CST 2009

On 1/20/2009 7:33 PM, Matthieu Brucher wrote:

> You're wrong. Pointers are there since the begining. It's Fortran
> nasis. Fortran 77 code is full of pointers when using dynamic
> allocation. 

Cray pointers are not standard Fortran. Apart from that, Fortran 77 does 
not have pointers. There is no dynamic allocation with Fortran 77, 
except if you use non-standard Cray pointers.

Fortran 90 (and later) have pointers, but pointers can only point to 
variables declared as targets (or dynamically allocated memory). What 
Fortran disallows is pointer aliasing, except for variables explicitly 
declared as 'pointer' or 'target'. This way, a Fortran compiler always 
knows what could be aliased and what is not.

Fortran 90 does not need pointers for dynamic allocation. Memory can 
also be allocated to allocatable arrays, which may or may not be aliased 
by pointers, depending on declaration.

If you don't use pointers, nothing can be aliased - and the compiler 
will just assume this is true.

Fortran pointers are not simply memory adresses. They are 'doped array 
structures', with dimensions, bounds and strides, very similar to 
NumPy's view arrays. If you pass a C pointer to a Fortran method that 
expects a Fortran pointer, it will usually fail.

ISO C (not ANSI C) has a 'restrict' keyword that informs the compiler it 
can treat a pointer as unaliased. ANSI C and ISO C++ can be just as 
efficient as Fortran. This is due to non-standard compiler pragmas, 
which informs the compiler about pointer aliasing.

Speed differences within an order of magnitude seldom counts. This can 
easily be solved by using more hardware or waiting a bit longer. The 
time spent coding is much more important, at least for scientific 
projects. Though for commercial work it will be different, as you have 
customers and competitors to consider.

For code that involves arrays and loops, it will be easier to program in 
Fortran than C++.

If you are going to make calls to the OS, C will easier than Fortran. 
The OS was written in C, and you just have to include the header and 
link the appropriate library.

Sturla Molden

More information about the SciPy-user mailing list