From: Craig Burley <burley@tweedledumb.cygnus.com>
Subject: Re: Final kick at the "Merced Guessing Game"
Date: 1997/10/19 [thread overview]
Message-ID: <y667quuzhq.fsf@tweedledumb.cygnus.com> (raw)
In-Reply-To: 3447C681.167E@lanl.gov
William Clodius <wclodius@lanl.gov> writes:
> Craig Burley wrote:
> >
> > Care to explain what *low-level*
> > constructs C is offering that Fortran doesn't offer, aside from
> > pointers?
>
> Guaranteed ability to pass some arguments by value, or have a well
> defined result in the presence of aliasing (whether or not the initial
> programmer or the user of the code knows what that well defined result
> is).
C has an IMO important linguistic/syntactic advantage in that
the programmer (and thus the compiler) *knows* that "foo (a);"
will not modify `a', indeed. Fortran's version of this is
"CALL FOO((A))", and of course the FOO *subroutine* can be
fairly easily determined to not modify its argument. However,
in practice, the typical compiler cannot determine that all
calls to FOO are done via (A) and/or that FOO itself can take the
argument by value, so it must assume pass-by-reference.
So, when passing an argument by value as a *mechanism* is faster
in an important way, then I think this is an important advantage
to C.
(Note that I *could* argue that Fortran compilers "could" [and in
fact, I've been told some do] determine that pass-by-value would
work and thus implement the faster form anyway...but what a
super-fancy compiler can *intuit* from code made intentionally
obtuse by the failings of a language is *not* the issue here,
else, as I've pointed out elsewhere, we might as well say that
C and/or the x86 assembly language is "just fine" for achieving
maximum speed on *all* future architectures.)
BTW, another thing I prefer in C, though it's purely linguistic
and has no performance implications, is that function references
are syntactically distinct from array references. I don't usually
bring this up, because, for some reason I haven't quite grokked
yet, Fortran programmers don't seem to experience any problems as
a result of this in practice.
However, Fortran does offer the ability to do aliasing, when
it is important enough to do. Instead of
SUBROUTINE BIGMUL(A,B,C,N)
REAL A(N),B(N),C(N)
DO I=1,N
A(I)=B(I)*C(I)
END DO
END
you provide:
SUBROUTINE BIGMULA(A,IA,IB,IC,N)
REAL A(MAX(IA,IB,IC)+N-1)
DO I=0,N-1
A(IA+I)=A(IB+I)*A(IC+I)
END DO
END
This makes it clear to the compiler (and the person reading the
code, both the caller and callee, pretty much) that aliasing
is designed into the routine. (Strictly speaking, you can't use
intrinsics, like MAX(), in an array decl, I believe; but you can
either expand it to the appropriate expression, or just use `*'.)
> Compared to Fortran 77, not Fortran 90, structures.
Not sure this is superior for performance. Guaranteed it is for
expressability. I've already said I've seen real gross Fortran
code that achieves what amounts to the same thing, performance-wise,
as C structures, though I suspect even if people wanted to force
the issue and use Fortran, they'd end up with the same problem
C imposes on Fortran users by not having multi-dimensional arrays:
the compiler would have to be *lots* smarter to figure out how to
do some nifty optimizations.
On the other hand, C does offer a few ways of being more flexible
in how to specify initial values for variables and aggregates.
One thing I love about C is its file scoping, for example, which
allows several procedures to share static data, which explicitly
permits the compiler (and programmer) to make all sorts of usable,
practical assumptions about the kinds of things that can be done
vis-a-vis the static data.
Then again, C offers nothing like "COMMON /X/ A(1000000)", especially
when in a BLOCK DATA combined with "DATA A(1)/1./". This *can* have
a substantial performance impact, although I suspect that, in
practice, most such cases would be mitigated by the fact that
the Fortran was "written around" not having dynamic allocation (which
C has, of course). (The reason? The Fortran initialization literally
says "the first element of A is 1; the rest are uninitialized",
while C doesn't allow specifying that portions of variables are
uninitialized, or even static/extern ones IIRC, the latter being
mostly a linguistic failing except when the aggregate sizes of
gratuitously zero-initialized entities is large enough to impact
executable size and startup time.)
> Unions (but much of that can be kluged using EQUIVALENCE). (Then again
> unions themselves are usually kluges in their application.)
Yup, I don't see a clear win here, though, personally, I prefer
C's unions to Fortran's EQUIVALENCE.
> There is also the problem of API's on C implemented systems, name
> mangling, the possibility of copy-in/copy-out Fortran argument passing,
> i.e., the interlanguage interfacing problem. None of this is strictly a
> problem with the Fortran language per se, but does influence its
> useability as a runtime library on most current systems.
Yup, I mentioned that elsewhere, except the part about copy-in/copy-out
passing, which is a practical advantage in favor of Fortran on some
systems.
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
next prev parent reply other threads:[~1997-10-19 4:00 UTC|newest]
Thread overview: 207+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-10-08 4:00 Final kick at the "Merced Guessing Game" Robert Harley
1997-10-08 4:00 ` William Clodius
1997-10-08 4:00 ` David Chase
1997-10-08 4:00 ` brianh
1997-10-08 4:00 ` boo
1997-10-09 4:00 ` Eric Hildum
1997-10-09 4:00 ` brianh
1997-10-11 4:00 ` Jan Vorbrueggen
1997-10-12 4:00 ` boo
1997-10-13 4:00 ` Carl Perkins
1997-10-13 4:00 ` Michael Williams
1997-10-13 4:00 ` Craig Burley
1997-10-13 4:00 ` Paul Rubin
1997-10-13 4:00 ` Craig Burley
1997-10-13 4:00 ` William Clodius
1997-10-14 4:00 ` Richard A. O'Keefe
1997-10-14 4:00 ` Shankar Unni
1997-10-15 4:00 ` Richard A. O'Keefe
1997-10-15 4:00 ` Paul D. DeRocco
1997-10-15 4:00 ` William Clodius
1997-10-15 4:00 ` Joe Buck
1997-10-16 4:00 ` Richard A. O'Keefe
1997-10-16 4:00 ` Craig Burley
1997-10-17 4:00 ` Shankar Unni
1997-10-15 4:00 ` Achim Gratz
1997-10-14 4:00 ` Michael Williams
1997-10-14 4:00 ` Richard Black
1997-10-15 4:00 ` Michael Williams
1997-10-15 4:00 ` Dr. Richard Black
1997-10-16 4:00 ` Richard A. O'Keefe
1997-10-15 4:00 ` Craig Burley
1997-10-18 4:00 ` Bruce Hoult
1997-10-15 4:00 ` Paul Hsieh
1997-10-13 4:00 ` boo
1997-10-15 4:00 ` Craig Burley
[not found] ` <623ek6$ef5$1@news.iastate.edu>
1997-10-16 4:00 ` Craig Burley
1997-10-16 4:00 ` SimGraphics
1997-10-17 4:00 ` Craig Burley
1997-10-17 4:00 ` David Chase
1997-10-18 4:00 ` Victor Yodaiken
1997-10-20 4:00 ` Eric Hildum
1997-10-17 4:00 ` William Clodius
1997-10-19 4:00 ` Craig Burley [this message]
1997-10-18 4:00 ` Peter L. Montgomery
1997-10-19 4:00 ` Craig Burley
[not found] ` <3456700e.14141203@news.demon.co.uk>
1997-10-28 5:00 ` Dirk van der Knijff
1997-10-20 4:00 ` Richard A. O'Keefe
1997-10-20 4:00 ` Peter L. Montgomery
1997-10-16 4:00 ` Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game") Ian Dall
1997-10-16 4:00 ` Craig Burley
1997-10-17 4:00 ` Richard A. O'Keefe
1997-10-17 4:00 ` Keith Adams
1997-10-17 4:00 ` [Reposted due to Enlow UCE cancel]: " John Bayko
1997-10-20 4:00 ` Paul D. DeRocco
1997-10-17 4:00 ` John Bayko
1997-10-18 4:00 ` Kelly Hall
1997-10-20 4:00 ` [Reposted due to Enlow UCE cancel]: " Eric Hildum
1997-10-09 4:00 ` Final kick at the "Merced Guessing Game" Gregg E Economou
1997-10-10 4:00 ` Jan Vorbrueggen
[not found] ` <61ho3v$3m0$1@goanna.cs.rmit.edu.au>
1997-10-09 4:00 ` boo
1997-10-09 4:00 ` William Clodius
1997-10-10 4:00 ` Tyson Richard DOWD
1997-10-12 4:00 ` boo
1997-10-13 4:00 ` Steve Tate
1997-10-13 4:00 ` boo
1997-10-13 4:00 ` Victor Yodaiken
1997-10-14 4:00 ` Aaron Spink
1997-10-14 4:00 ` Jason.Ozolins
1997-10-15 4:00 ` boo
1997-10-15 4:00 ` David Chase
1997-10-13 4:00 ` Bernd Paysan
1997-10-13 4:00 ` boo
1997-10-13 4:00 ` Aaron Spink
1997-10-14 4:00 ` boo
1997-10-18 4:00 ` tgg
1997-10-18 4:00 ` [Reposted due to Enlow UCE cancel]: " tgg
1997-10-13 4:00 ` Patricia Shanahan
1997-10-15 4:00 ` boo
1997-10-15 4:00 ` Patricia Shanahan
1997-10-10 4:00 ` boo
1997-10-11 4:00 ` Paul DeMone
1997-10-11 4:00 ` Toon Moene
1997-10-11 4:00 ` Patricia Shanahan
1997-10-13 4:00 ` Gregg E Economou
1997-10-13 4:00 ` Patricia Shanahan
1997-10-14 4:00 ` Richard A. O'Keefe
1997-10-15 4:00 ` boo
1997-10-16 4:00 ` Toon Moene
1997-10-16 4:00 ` Timothy A. Seufert
1997-10-16 4:00 ` boo
1997-10-17 4:00 ` Richard A. O'Keefe
1997-10-20 4:00 ` Jason.Ozolins
1997-10-20 4:00 ` [Reposted due to Enlow UCE cancel]: " tgg
1997-10-10 4:00 ` Richard A. O'Keefe
[not found] ` <EHrwv9.2w3@world.std.com>
1997-10-10 4:00 ` David Gould
1997-10-10 4:00 ` Maynard Handley
1997-10-11 4:00 ` new languages Preston Briggs
1997-10-10 4:00 ` Final kick at the "Merced Guessing Game" David Gould
1997-10-16 4:00 ` Patricia Shanahan
-- strict thread matches above, loose matches on Subject: below --
1997-10-09 4:00 Robert Harley
1997-10-08 4:00 Robert Harley
1997-10-08 4:00 ` Michael Meissner
1997-10-09 4:00 ` Richard A. O'Keefe
1997-10-08 4:00 Robert Harley
[not found] ` <343C0387.41C6@lanl.gov>
1997-10-08 4:00 ` boo
1997-10-09 4:00 ` David Chase
1997-10-08 4:00 ` boo
1997-10-09 4:00 ` William Clodius
1997-10-09 4:00 ` Patrick Chase
1997-10-10 4:00 ` boo
1997-10-09 4:00 ` David Chase
1997-10-07 4:00 Robert Harley
1997-10-07 4:00 ` Martin Rodgers
1997-10-07 4:00 ` Nick Maclaren
1997-10-07 4:00 ` Shankar Unni
1997-10-08 4:00 ` boo
1997-10-09 4:00 ` Patrick F. McGehearty
1997-10-10 4:00 ` Richard A. O'Keefe
1997-10-15 4:00 ` David Chase
1997-10-16 4:00 ` William Clodius
1997-10-03 4:00 Robert Harley
1997-10-06 4:00 ` Richard A. O'Keefe
1997-10-06 4:00 ` boo
1997-10-07 4:00 ` Carlie Coats
1997-10-07 4:00 ` Paul Hsieh
1997-10-07 4:00 ` boo
1997-10-08 4:00 ` Carlie Coats
1997-10-07 4:00 ` Serge Pachkovsky
1997-10-07 4:00 ` Martin Rodgers
1997-10-07 4:00 ` Greg Weeks
1997-10-07 4:00 ` Martin Rodgers
[not found] ` <343AAE5A.A3FCC9D@no.informatik.spam.tu-muenchen.thanks.de>
1997-10-09 4:00 ` Torben AEgidius Mogensen
[not found] ` <EHsr7B.Dt8@bit3.com>
1997-10-10 4:00 ` Torben AEgidius Mogensen
[not found] ` <61cv5e$qn$6@vixen.cso.uiuc.edu>
1997-10-08 4:00 ` William Clodius
1997-10-07 4:00 ` Richard A. O'Keefe
1997-10-06 4:00 ` Graham Hughes
1997-10-07 4:00 ` boo
1997-10-07 4:00 ` William Clodius
1997-10-07 4:00 ` William Clodius
1997-10-08 4:00 ` Richard A. O'Keefe
1997-10-08 4:00 ` William Clodius
1997-10-08 4:00 ` William Clodius
[not found] ` <y4wwjon203.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>
1997-10-08 4:00 ` William Clodius
1997-10-08 4:00 ` Stanley Chow
1997-10-09 4:00 ` William Clodius
1997-10-10 4:00 ` Larry Kilgallen
1997-10-10 4:00 ` Zalman Stern
1997-10-11 4:00 ` Andrew Cruickshank
1997-10-12 4:00 ` Paul D. DeRocco
1997-10-13 4:00 ` Michael Williams
1997-10-08 4:00 ` Gregg E Economou
1997-10-08 4:00 ` Richard A. O'Keefe
1997-10-08 4:00 ` David Chase
1997-10-08 4:00 ` James C. Stutts
1997-10-02 4:00 Robert Harley
1997-10-02 4:00 ` Nick Maclaren
1997-10-03 4:00 ` Richard A. O'Keefe
1997-10-02 4:00 Robert Harley
1997-10-02 4:00 ` Nick Maclaren
1997-10-02 4:00 ` Stanley Chow
1997-09-30 4:00 Paul DeMone
1997-09-30 4:00 ` Guy Harris
1997-10-01 4:00 ` Tom Thornhill
1997-10-01 4:00 ` Tom Thornhill
1997-10-01 4:00 ` Paul DeMone
1997-10-01 4:00 ` Jim Hull
1997-10-01 4:00 ` Richard A. Schumacher
1997-10-01 4:00 ` Nick Maclaren
1997-10-01 4:00 ` J. Corbally
1997-10-01 4:00 ` Nick Maclaren
1997-10-01 4:00 ` Ketil Z Malde
1997-10-01 4:00 ` Michael D. Nahas
1997-10-01 4:00 ` brianh
1997-10-01 4:00 ` Stefan Monnier
1997-10-01 4:00 ` Nick Maclaren
1997-10-01 4:00 ` Allen Kim
1997-10-01 4:00 ` P Murray
1997-10-01 4:00 ` Nick Maclaren
1997-10-02 4:00 ` Vesa Karvonen
1997-10-02 4:00 ` Joseph H Allen
1997-10-02 4:00 ` Wilco Dijkstra
1997-10-03 4:00 ` Stefan Monnier
1997-10-03 4:00 ` Jason.Ozolins
1997-10-03 4:00 ` Alex Colvin
1997-10-06 4:00 ` Richard A. O'Keefe
1997-10-08 4:00 ` Zalman Stern
1997-10-03 4:00 ` Stefan Monnier
1997-10-02 4:00 ` Andrew Glew
1997-10-02 4:00 ` Torben AEgidius Mogensen
1997-10-02 4:00 ` Patrick F. McGehearty
1997-10-02 4:00 ` brianh
1997-10-03 4:00 ` Michael Williams
1997-10-01 4:00 ` John Wilson
1997-10-02 4:00 ` Stefan Monnier
1997-10-03 4:00 ` Richard A. O'Keefe
1997-10-02 4:00 ` Jon Leech
1997-10-03 4:00 ` Mike Smith
1997-10-03 4:00 ` Nick Maclaren
1997-10-03 4:00 ` Rob Barris
1997-10-03 4:00 ` Andrew Glew
1997-10-05 4:00 ` Gianni Mariani
1997-10-04 4:00 ` Nick Maclaren
1997-10-04 4:00 ` H. Eckert
1997-10-05 4:00 ` Andy "Krazy" Glew
1997-10-06 4:00 ` Nick Maclaren
1997-10-02 4:00 ` Eric Hildum
1997-10-01 4:00 ` Paul DeMone
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox