Re: The Decline of C/C++, the rise of X

beliavsky_at_aol.com
Date: 07/29/04


Date: 28 Jul 2004 19:41:21 -0700

anon21h@yahoo.co.uk (Eric) wrote in message news:<5ed9ec27.0407260757.3c17a0c0@posting.google.com>...
> beliavsky@aol.com wrote in message news:<3064b51d.0407241431.71ef14f4@posting.google.com>...
> > ericmuttta@email.com (Eric) wrote in message news:<ca5584cb.0407200224.5a463e9@posting.google.com>...
> >
> > What about Fortran? The Fortran 2003 standard adds object-orientation,
> > interoperability with C, and floating point exception handling, among
> > other features. There are more than 10 companies selling Fortran 95
> > compilers, showing that it IS being used to write new code.
>
> Ah I see Fortran lives on! With the likes of C++ template
> meta-programming challenging Fortran in numerical performance, is
> there anything new Fortran is doing to stay ahead?
>
> > Modern Fortran satisfies many of your criteria:
> > (1) it does not rely on a virtual machine
>
> Good. It would probably not have the fame it has in the numerical
> world if it did!
>
> > (2) one can write procedural or OO code (with some aspects of
> > functional programming, including PURE and ELEMENTAL functions)
>
> Great. PURE functions seem guessable enough, but what are ELEMENTAL
> ones?

One change in the Fortran 90 standard was that built-in
functions like SIN can act on arrays of any dimension, as well as
scalars, returning an array of the same shape as the argument(s). If
there are several arguments, they must be conformant (arrays of the
same size, or scalars). Such functions are called ELEMENTAL. Fortran
95 introduced user-defined elemental functions. All ELEMENTAL
functions must be PURE (not have side effects), but the reverse is not
true. Here is an example

function foo(x,y) result(z)
real, intent(in) :: x,y
real :: z
y = sin(x*y)
end function foo

program xfoo
print*,foo(2.0,3.0) ! prints sin(6.0)
print*,foo(2.0,(/1.0,2.0,3.0/)) ! prints sin(2.0),sin(4.0),sin(6.0)
print*,foo((/2.0,3.0,4.0/),(/5.0,6.0,7.0/)) ! prints
sin(10.0),sin(18.0),sin(28.0)
end program xfoo

> > (3) code is relatively easy to read -- it looks like basic math
> > notation
>
> Operator overloading?

Fortran 90 has derived types (similar to C++ classes but without
inheritance), for which operators can be overloaded.

> > There are no templates or Standard Template Library, although there
> > are many intrinsic functions to manipulate arrays.
>
> Hmmm, I suspect Fortran may be forced to eventually evolve and support
> templates seeing how C++ is on its tail.

I agree that C++ templates are powerful. But they are also and
advanced feature
that places heavy demands on a compiler. I wonder if the costs to
compiler vendors of implementing them -- passed on the compiler
customers -- would exceed the benefits to customers. I have noticed
with Microsoft Visual C++ that if I use the Standard Template Library
and have a syntax error, the resulting error messages is often
terrifying. With Fortran, I almost never get an incomprehensible
syntax error message.

It is possible in Fortran to write portable numerical codes that work
for single, double, and quadruple precision.



Relevant Pages

  • Re: Double precision arrays and subroutines
    ... arrays. ... What happens is that, in Fortran, these two program units are ... The subroutine and the program that calls it are compiled ... and normally the compiler doesn't know about one when it's ...
    (comp.lang.fortran)
  • Re: some confusing in subroutine
    ... is the code correct in Fortran IV? ... Find a way to switch off bounds checking on your compiler. ... Replace the declarations with assumed size arrays: ... Replace the declarations with assumed shape arrays: ...
    (comp.lang.fortran)
  • Re: Who uses clapack?
    ... Fortran 95 still has many advantages over C and C++: ... the ability to pass one- and multi-dimensional arrays to functions ... >Have you ever seen those bills for a Fortran compiler for an ... Lapack documentation is at http://www.netlib.org/lapack/lug/index.html ...
    (sci.math.num-analysis)
  • Re: A question on Newtons Method
    ... >> I can't believe you'd advise a noob to use a compiler which is still ... > production codes and codes from textbooks. ... > The Fortran standard generally does not specify the required behavior ... >> another important class of hassle which most numerical programmers ...
    (sci.math.num-analysis)
  • Re: Language efficiency of C versus FORTRAN et al
    ... > that a FORTRAN compiler can. ... > not least because I don't understand FORTRAN. ... when you pass arrays to "subprograms". ... If C or Fortran programmers do this, ...
    (comp.lang.c)