News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

C++ and Fortran

Started by jj2007, October 19, 2016, 09:39:58 AM

Previous topic - Next topic

jj2007

Jeff Cogswell, go parallel:

QuoteRegarding C++ and Fortran

Although I've focused exclusively on C++ on Go Parallel, Fortran is a language often preferred by scientists. There are many reasons for this, including the fact that a scientist's job is to do science, not spend years mastering a programming language. C++ takes a long time to master, and as such, full-time scientists often don't have time to invest in it. It's not that they can't; it's that it isn't their job. And further, they usually aren't building massive applications to be used by millions of people. Instead, they're writing quick applications to assist them in their work, often with only a couple people ever using the programs. Fortran, then, is just better suited for their work.
:t

rrr314159

Sure, we all know C++ sucks (back in 1985 it wasn't bad but today ...). However most scientists these days use some good Basic instead of Fortran - don't they? I switched to Basic for scientific work long ago, when the first compiled Basics came out. Never have used PowerBasic but I know many here love it. In what way is Fortran better? Perhaps, there are more scientific libraries available for it?
I am NaN ;)

jj2007

I have used Fortran IV around 1980, in a research facility, but afterwards I forgot it completely and switched to (Gfa) Basic. But around 2010, I worked in another research centre, and to my surprise some of the hardcore modelers there use Fortran (sometimes with MatLab). Perhaps it's really the availability of libraries. And C++ really sucks, but that doesn't explain why they wouldn't use plain C instead.

rrr314159

I've always found Fortran better than C for math and science. Of course C works also, it's just more trouble, especially for math formulas (FORTRAN, of course, means "Formula Translation"). But if anyone has a different opinion, I can't say they're wrong.
I am NaN ;)

hutch--

Interestingly enough I can make sense of FORTRAN but COBOL looked like hieroglyphics to me.

rrr314159

COBOL is a pretty ugly language but of course it's easy enough when someone is paying you to do it. Otherwise I wouldn't touch it.
I am NaN ;)

Gunther

FORTRAN was the first high-level programming language. Many software was ported from computer generation to computer generation. That's why there is so much FORTRAN software. If a program has hundreds of thousands of lines of code, there is usually little desire to rewrite the software in another programming language.

Quote from: rrr314159 on October 19, 2016, 11:58:25 PM
COBOL is a pretty ugly language but of course it's easy enough when someone is paying you to do it. Otherwise I wouldn't touch it.

That's true, but it has a few advantages in financial mathematical calculations. Furthermore, one could use PL/1 instead.

Gunther
You have to know the facts before you can distort them.

FORTRANS

Hi,

Quote from: jj2007 on October 19, 2016, 12:24:02 PM
Perhaps it's really the availability of libraries. And C++ really sucks, but that doesn't explain why they wouldn't use plain C instead.

   As rrr314159 says FORTRAN is better than C for math and modelling.
Primarily because C is somewhat obfuscated using funny symbols,
pointers, and such.  The start up effort is less with FORTRAN.  Over
BASIC (way back when anyway) it supports DOUBLE PRECISION and
COMPLEX data types.

Quote from: hutch-- on October 19, 2016, 06:33:50 PM
Interestingly enough I can make sense of FORTRAN but COBOL looked like hieroglyphics to me.

   COBOL had two characteristics that defined it for me when I
looked at it.  One was it was set up to format tables and financial
information for output.  And that is an ugly task in BASIC, FORTRAN,
or COBOL.  But COBOL was setup for it.  Second it was a restricted
language to allow multiple programmers to work on a program.  Or
have someone take over another programmer's code.  If there is
not too much you can do, someone else should be able to figure it
out without too much effort.  C, FORTRAN, and Assembly programs
are usually easier to rewrite from scratch rather than reuse another's
program.  YMMV.

Regards,

Steve N.

rrr314159

Quote from: FORTRANS on October 20, 2016, 02:47:30 AM... because C is somewhat obfuscated using funny symbols,
pointers, and such.

I didn't want to say it, might start a holy war, but you're right
I am NaN ;)

GuruSR

Quote from: rrr314159 on October 19, 2016, 12:09:47 PM
Sure, we all know C++ sucks (back in 1985 it wasn't bad but today ...). However most scientists these days use some good Basic instead of Fortran - don't they? I switched to Basic for scientific work long ago, when the first compiled Basics came out. Never have used PowerBasic but I know many here love it. In what way is Fortran better? Perhaps, there are more scientific libraries available for it?

Wait, wait, wait.  C was never good, back in the '80s when the comp sci got ahold of a preview copy of C, I looked over the stuff and was asked if they should provide a course for it, my thought was no, assembler will get more jobs (and that was right).  C basically is lazy application development from the get-go.  Assembler is where the hardware level is.  I'd love to see your "My Ford Touch" pull up a C library crash, just as it shorts out your console causing your vehicle to roll to a halt (hopefully not into a cop car).

Funkiest languages, APL and B.  Worst moment ever...  crashing the main server at Waterloo...  my bad.  Well, not really my bad, someone didn't lock root access out from the terminal I was at.  :greenclp:

GuruSR.
Learned 68k Motorola Asm instruction set in 30 minutes on the way to an Amiga Developer's Forum meeting.
Following week wrote a kernel level memory pool manager in 68k assembler for fun.

TWell

QuotePrevious 16-bit versions of Microsoft C/C++ and Microsoft Visual C++ supported the long double type as an 80-bit precision floating-point data type. In later versions of Visual C++, the long double data type is a 64-bit precision floating-point data type identical to the double type. The compiler treats long double and double as distinct types, but the long double functions are identical to their double counterparts. The CRT provides long double versions of the math functions for ISO C99 source code compatibility, but note that the binary representation may differ from other compilers.
For example this kind of things spoiled C++ for some scientific works.

BTW:
But what is that C "thing", inside joke?
C isn't for sloppy programmers.

jj2007

Quote from: TWell on October 20, 2016, 10:43:00 PM
QuotePrevious 16-bit versions of Microsoft C/C++ and Microsoft Visual C++ supported the long double type as an 80-bit precision floating-point data type.
For example this kind of things spoiled C++ for some scientific works.

Workaround: use Intel libraries...
Quote from: jj2007 on October 20, 2016, 09:31:33 AMThe output shows that the Intel compiler returns REAL10 precision:Bessel J0(5)=-0.17759677131433830435    (Wolfram Alpha)
Bessel J0(5)=-0.1775967713143383044     (Intel)
Bessel J0(5)=-0.1775967713143382590     (CRT)

hutch--

I don't see C as a problem, it has some crappy old fashioned notation but you can get used to throwing it around with practice. It used to have nearly an infinite collection of libraries that made it close to universal but the rise of C++ lost much of the integrity of C and with the last 15 years of encapsulation theory you have to know it very well to write decent code. The problem as usual is its being targeted at the imbecile level with excessive hand holding, clutter and protection against yourself measures.

Now of course the opposite is assembler, it does not protect you against yourself, it bites the hand that feeds it and you can have as much or as little clutter as you want.  :biggrin:

GuruSR

I don't hate C, just don't program in it.  The original C code segments that I disassembled were written in assembler...  Those days, you *could* write half decent code in C, but now, finding those properly made code segments now-a-days are all written in C, and sadly, not very efficiently.  But as one C programmer said, "If your machine can't run the code smoothly, buy a better one."  Odd how when we were talking about C programming in a game console forum.  I almost made the quip about waiting for the XBox 720, though I made another about hacking it with a Pentium 4, apparently the moderator was laughing so hard at it, he printed the response out and left it on the breakroom wall for others to laugh.  C programmers doesn't mean Crazy, really, it doesn't!  (And no, I didn't put <SARCASM> around that, because they really aren't, now assembler programmers...  No comment!)

GuruSR.
Learned 68k Motorola Asm instruction set in 30 minutes on the way to an Amiga Developer's Forum meeting.
Following week wrote a kernel level memory pool manager in 68k assembler for fun.

MichaelW

All I recall of Fortran is that it seemed clumsy and archaic. For the BASIC languages, and in particular QuickBASIC, the mathematical expression notation was very well designed, making it easy to code calculations of the sort involved in stress analysis, for example. Starting with the move to Visual Basic, Microsoft increasingly compromised their BASIC languages (for example with the IMO idiotic introduction of the Variant type), at least for my purposes, and now with 64-bit systems that cannot natively run 16-bit code, I have switched to using C. FreeBASIC is available in 32 and 64-bit versions (as well as a DPMI version), and accepts the QuickBasic expression syntax, but for calculations I don't have the confidence in it that I had in QuickBASIC (no slight intended to the FreeBASIC developers, who have done an excellent job).
Well Microsoft, here's another nice mess you've gotten us into.