CCL: [CCL]: Cleaning up dusty deck fortran and converting to C/C++



 Sent to CCL by: "Perry E. Metzger" [perry : piermont.com]
 --Replace strange characters with the "at" sign to recover email
 address--.
 > 1) When Perry says Fortran, as near as I can tell he really means
 > f77 or earlier versions of fortran.  It is to my mind completely
 > disingenuous to say "fortran", referring to the capabilities of
 > these versions of the language, and completely ignore the fact that
 > the fortran language has evolved to a significant extent, and can
 > now come very close to C's ability to handle more sophisticated data
 > structures and algorithms.  This is like referring to the
 > capabilities of B, and calling it C.
 Er, C has more or less been the same language for more than 30
 years. The declaration syntax got improved a bit and a few other
 tricks like void arrived, but you could write more or less the same
 stuff in it in 1977 that you can today.
 But, yes, it is true that F90/F95/F2003 are substantially better
 languages than F77. They do in fact have the ability to handle
 substantially more sophisticated data structures and types. However,
 if you have a "dusty deck" (the topic that started us off here), and
 you have the opportunity to start afresh, you're still better off
 moving to something else.
 > 2) I concur that f90/95 lacks any real object implementation and cannot
 > easily do a number of things that C++ can do;
 I'd like to be clear that I don't like C++ -- it is far too large a
 language, and is almost impossible even for a professional to keep
 fully in mind. It is poorly designed in many ways -- bloated and yet
 still dangerous. However, if one sticks to a small subset of its
 capabilities and is careful one can achieve reasonable results.
 > as for lisp, I last dealt with it over 20 years ago, and while I
 > think it is conceptually "way cool", I have not seen a big
 stampede
 > to implement systems using it for a whole bunch of reasons.
 Well, the biggest reason is that it is just plain too weird for most
 people who haven't made a substantial effort with the language. First
 of all, the syntax is alien to most people -- and as with APL, that
 alone keeps people far away. Then the language is filled with
 meta-level programming concepts like programs operating on data
 structures that happen to be other programs (such as macros) which are
 quite alien in and of themselves.  Scheme, a dialect of lisp, allows
 you to do even odder things than most lispers are used to -- including
 the fact that the state of the program (a "continuation") is a first
 class data type, which may be captured and operated on the way other
 languages allow you to, say, capture the location of a data structure
 in a pointer.
 I'm not per se advocating that people use lisp -- I think the culture
 shock would be pretty high, you'll have a lot of trouble finding other
 people who can read your code, and you won't find large libraries of
 pre-written numerical routines. It is, however, an extremely high
 productivity environment. Once you get used to it, you can throw
 systems together orders of magnitude faster.
 A good essay on the topic: http://www.paulgraham.com/iflisp.html
 > b) Sorry, but at least in my experience, f90/95 does a better job dealing
 > with a variety of mathematical issues, with arrays as a really important,
 if
 > unsatisfyingly simple, data structure (including DYNAMIC multidimensional
 > arrays with decent indexing),
 You can allocate a multidimensional array dynamically in C and index
 it just like you index any other array.
 > and with number crunching performance issues.
 In general, that's at worst a compiler issue. There is nothing
 inherent to either language that gives it an advantage in compiling
 numeric code. Modern C compilers do very well on numerical
 performance, though. People with substantial numerical performance
 demands use them for writing things like video games, and they can't
 afford second rate code.
 One does, however, have to know one's tools. For example, if you don't
 know to use stuff options like -mfpmath=sse when compiling GCC, you
 won't get SSE vectorized code on a modern Pentium, and that makes a
 big difference in performance. You also want to tell the compiler to
 inline transcendental functions as FPU instructions or it
 won't. Proper use of "inline" and other declarations also helps. Many
 systems programmers don't care about this stuff so they won't know to
 tell you to do it, but a quick read of your documentation will tell
 you about it.
 Most importantly, though, it is important to profile performance
 critical code and to understand what actually is the bottleneck. That
 is true whether you're writing Fortran, C or anything else. You can't
 fix what you don't understand.
 > If you choose to go the C/C++ route, fine, but just be sure you really
 > understand the tools, and plan on spending perhaps more time than you
 really
 > have to spare on gaining proficiency.  And don't think for a minute that
 > somebody who took one course and has never been in the trenches is going to
 > immediately be a great trailblazer.
 That's excellent advice in general. You have to know your tools well
 in order to use them well. A five star chef has to spend years learning
 technique in order get to the point that he can consistently turn
 what's in his head into something on a plate. That means knowing his
 equipment intimately. The non-professional neither has the equipment
 nor would have the skill if he did have it.
 Someone doing serious (not casual, serious) work on computers has to
 expect the same sort of effort is involved.  The good part is that if
 you learn your craft well, you can produce things that normal people
 simply cannot because they don't understand their tools.
 Perry