Print

Print


On Jul 14, 2004, at 4:28 PM, Dan Nagle wrote:

> Hello,
>
> On Wed, 14 Jul 2004 09:15:52 +0200, Drew McCormack
> <[log in to unmask]> wrote:
>
> <snip>
>
>> One thing which I haven't seen brought up, which is in favor of higher
>> level languages like C++ and Java, is algorithmic performance. The
>> algorithm you choose can often be much more important than the extra
>> cycles a compiler can save you. An advantage with C++/Java like
>> languages is simply that they are better at abstraction, and this can
>> make writing complex algorithms easier. The fortran version of the
>> algorithm would nearly always run faster, but writing the fortran
>> version may be considerably harder.
>
> How, exactly, are C++ and Java "better at abstraction"
> than Fortran 2003?
>
> <snip>
>
> --
> Cheers!
>
> Dan Nagle
> Purple Sage Computing Solutions, Inc.

I was wondering whether someone would throw that one up. I take the
point, but to me Fortran 2003 is still many years away as a practical
solution. There may be a couple of compilers supporting the OO stuff in
the coming year or so, but I'm sure broad support will be at least 3
years, and early implementations will likely be flaky.

In my view, Fortran 2003's OO features are also not quite as powerful
as C++ or Java's. In particular, I think not having something akin to
Java's interfaces is a mistake. Single inheritance is fine --- even
preferred --- but there must be some way to 'mix in' functionality that
stretches across classes. Unless I'm mistaken, Fortran 2003 doesn't
support such a mechanism.

Of course, C++ has also long supported genericity, and Java is just
starting. This can be quite important for abstraction at a low level.
In C++ you can effectively abstract the contents of an inner loop, for
example: using templates you can inline arbitrary content into a set of
nested loops, which can be very useful if you tend to require the same
loop structure at many points in your code. In Fortran and other
languages, you can achieve the same by passing a function pointer, and
calling the function from within the loops, but this will generally be
much slower.

Other more obvious examples of the advantages of genericity are being
able to replace single precision reals with double precision, without
having to duplicate any code, or replacing real numbers with complex
numbers (in an algorithm that can use both).

So, while I welcome Fortran's new OO features, and agree they will
improve the abstractive power of Fortran, I would stop short of
suggesting that they will be on a par with other languages at this
time. I'm sure as time progresses, more features will be added.

Drew
----------------------------------------------------
Drew McCormack

www.maniacalextent.com