🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2290

Re: Re: Fortran vs. C for numerical work

#2290
From: Marc Sabatella
Date: Tue, 04 Dec 1990 16:45
52 lines
3289 bytes
>But I really don't understand the
>arguments coming from Fortran enthusiasts. So, would someone care
>to explain why, from the point of view of Fortran, C can be
>said to have a complex syntax and to be difficult to learn?

I had the same experience as you - I learned BASIC, Fortran, Pascal, and three
different assembly languages before learning C, and found the latter the
simplest, syntactically.  I think that is mainly because I had assimilated a
basic understanding of semantics and learning one more syntax for well
understood semantics was not a big deal.

There are a few things a newcomer would consider "hard" about C, but of course
in most cases, if you only plan to do Fortran-like things, you would never
care.

Pointers: Fortran doesn't have them, so they could confuse someone who has
never seen one.  Coming from a Pascal background, though, I had been frustrated
at the lack of generality in its pointer scheme (you can't take the address of
a variable?  What about pointers to functions?) so C seemed a natural fix.
To a Fortran programmer, thugh, jumping from no pointers to practically
unrestricted pointers could be intimidating.  If you could avoid pointers, this
wouldn't be a problem, but you need them to implement pass by reference in C.
So this is the next hurdle for Fortran programmers: understanding the
distinction between value and reference.  Pascal programmers have it easier in
that it is more transparent, but at least going from Pascal to C, you have a
basic understanding of how the two modes work, so it is pretty natural to
translate syntax.  Until you want to pass a pointer by reference, and start
having to deal with pointers to pointers to...

Scoping: Fortran has only the most primitive scoping constructs.  With C, you
get to deal with the overloading of the word "static", with "extern"
declarations, and remembering when a declaration "char a[]" is interchangeable
with "char *a" (function arguments) and when it is not (extern declarations).

I/O: C's may be simpler to implement, but it can be intimidating to have 17
different functions, all of whose purpose is to read a few characters from a
file.

Loop constructs: why so many of them?  The "for" statement is more generalized
than your average numerical program will ever need.

Assignment/conditional/post/pre/increment/decrement operators: you can avoid
them if you want, but too often you see code that is rendered unreadable by
overuse of these.

Boolean operations: expressing them in numerical terms is an unnecessary (for
most Fortran programmers) generalization.  And why do you need parentheses
around the "if" argument?

Other things like having to declare variables before using them, etc - things
we all take for granted, can seem like arbitrary syntactic restrictions to a
Fortran programmer learning C.
Technical Details
Message-ID: <8960029@hpfcso.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!ucsd!ucbvax!hplabs!hpfcso!mjs
References: <1990Nov30.220756.9196@ariel.unm.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!ucsd!ucbvax!hplabs!hpfcso!mjs
From: mjs@hpfcso.HP.COM (Marc Sabatella)
Newsgroups: comp.lang.misc
Subject: Re: Re: Fortran vs. C for numerical work
Message-ID: <8960029@hpfcso.HP.COM>
Date: 4 Dec 90 16:45:09 GMT
References: <1990Nov30.220756.9196@ariel.unm.edu>
Organization: Hewlett-Packard, Fort Collins, CO, USA
Lines: 52