The MASM Forum

Miscellaneous => The Orphanage => Topic started by: jj2007 on October 19, 2016, 09:39:58 AM

Title: C++ and Fortran
Post by: jj2007 on October 19, 2016, 09:39:58 AM
Jeff Cogswell, go parallel: (https://goparallel.sourceforge.net/exploring-exclusive-functions-intel-mkl/)

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
Title: Re: C++ and Fortran
Post by: 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?
Title: Re: C++ and Fortran
Post by: jj2007 on October 19, 2016, 12:24:02 PM
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.
Title: Re: C++ and Fortran
Post by: rrr314159 on October 19, 2016, 05:07:33 PM
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.
Title: Re: C++ and Fortran
Post by: hutch-- on October 19, 2016, 06:33:50 PM
Interestingly enough I can make sense of FORTRAN but COBOL looked like hieroglyphics to me.
Title: Re: C++ and Fortran
Post by: 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.
Title: Re: C++ and Fortran
Post by: Gunther on October 20, 2016, 02:12:18 AM
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
Title: Re: C++ and Fortran
Post by: FORTRANS on October 20, 2016, 02:47:30 AM
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.
Title: Re: C++ and Fortran
Post by: rrr314159 on October 20, 2016, 04:36:43 AM
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
Title: Re: C++ and Fortran
Post by: GuruSR on October 20, 2016, 02:42:32 PM
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.
Title: Re: C++ and Fortran
Post by: 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. 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.
Title: Re: C++ and Fortran
Post by: jj2007 on October 20, 2016, 11:31:27 PM
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)
Title: Re: C++ and Fortran
Post by: hutch-- on October 21, 2016, 01:28:19 PM
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:
Title: Re: C++ and Fortran
Post by: GuruSR on October 23, 2016, 06:17:23 AM
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.
Title: Re: C++ and Fortran
Post by: MichaelW on October 23, 2016, 11:17:06 AM
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 (http://freebasic.net/forum/viewtopic.php?f=1&t=24363) 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).
Title: Re: C++ and Fortran
Post by: GuruSR on October 23, 2016, 11:42:01 AM
Quote from: MichaelW on October 23, 2016, 11:17:06 AM
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 (http://freebasic.net/forum/viewtopic.php?f=1&t=24363) 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).

IBM Dos QBasic or the QuickBASIC someone else wrote?  I know I could run it in Vista, probably in a dos window in 7 too.  Reminds me of dealing with the floating point bug in certain cpus...  Wow, days gone bye...  And wait, you don't like Variants?  Basically that is a simple term for "stupid DWORD pointer".  Microsoft LOVES variants, a lot of the code you find in scripts and such (batch files) are variants.  They just point to whatever is needed, objects, values, etc.

GuruSR.
Title: Re: C++ and Fortran
Post by: MichaelW on October 23, 2016, 12:23:28 PM
Quote from: GuruSR on October 23, 2016, 11:42:01 AM
IBM Dos QBasic or the QuickBASIC someone else wrote?

And that a very large number of people tested.

Quote
And wait, you don't like Variants?

Unnecessary complexity, and risky automation. What type of thinker performs calculations where the data types of the variables, and of the result, are not firmly fixed, from the POV of the program and of the programmer?
Title: Re: C++ and Fortran
Post by: jj2007 on October 23, 2016, 02:36:42 PM
I started programming with FORTRAN IV around 1982. A few years later I had no problems to switch to BASIC because the two languages seemed to me almost identical, syntax-wise. Then I used a GfaBasic+Assembler combo for two decades or so, first with 68k, then with x86 assembler. So when I stumbled over C about five years ago, I had already a lot of x86 experience. And my impression of C was WOW, what a strange language: They have to do all that low level stuff for the simple things that I do with Masm32, except that it looks more obfuscated and [needs] {brackets} and; semi; colons; all; over; the; place. And they have buffer overflows and fall thru in switches, very strange. One can get used to C, but it's really assembler without the benefits of assembler. Now C++ is yet another story, by far the ugliest crap I've ever seen in programming (oh, wait, I forgot there is QT, that desperate attempt to squeeze Linux and Windows into a single straightjacket :eusa_boohoo:).

If I had to choose a Basic dialect today (I don't have to (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm)), it would be FreeBasic. It seems very fast and looks like a modern version of the best traditional Basic dialects.
Title: Re: C++ and Fortran
Post by: GuruSR on October 23, 2016, 02:41:54 PM
Quote from: MichaelW on October 23, 2016, 12:23:28 PM
Quote from: GuruSR on October 23, 2016, 11:42:01 AM
IBM Dos QBasic or the QuickBASIC someone else wrote?

And that a very large number of people tested.

Which one, QBasic...  I do remember that one offered compiling of sorts, doubt it really did any real compiling, think it was more of a standalone program afterwards that basically had the main basic functionality added to the source that would run it when executed.

Quote from: MichaelW on October 23, 2016, 12:23:28 PM
Quote
And wait, you don't like Variants?

Unnecessary complexity, and risky automation. What type of thinker performs calculations where the data types of the variables, and of the result, are not firmly fixed, from the POV of the program and of the programmer?

I'm sorry, I should have put the <SARCASM> </SARCASM> around that question, as it was intended.  And over the years, I've seen some half-brained things Microsoft has done with their OSes that would make any one run to Apple.

GuruSR.