Jump to content

Fortran 2008


Canardia
 Share

Recommended Posts

Well, I'm still young, only 42! :)

I started programming already before I had a computer, so I made some logic machines with LEGO elements, where you could for example drop a marble in, and the program decided from which hole the marble came out.

My first computer at age 9 or so, was a industrial paper machine processing unit which had Nova Advanced BASIC.

Well now I know Lumooja is almost completely out to lunch, since the math doesn't work. I thought you were serious about FORTRAN being faster then C/C++ in I/O writing, but I couldn't wrap my brain around it since you can embed assembly language into C/C++ for the most optimization and therefore the fastest possible code for reading and writing to disk. I guess in the end it depends on what functions you use for your tests, but I can't see FORTRAN being faster than C/C++ and even if it was I don't see it being faster by much.

Intel 2nd Generation i5 Quad Core Running at 3.30GHz. 8GB RAM, GeForce GTX 460 1024MB DDR5.

Link to comment
Share on other sites

Wiki says in the 1950s, so it could be also 1950 or 1951, because FORTRAN II appeared in 1958. In late 1953, John W. Backus submitted a proposal to his superiors at IBM to develop a more practical alternative to assembly language for programming their IBM 704 mainframe computer, so John must have developed FORTRAN I already since 1950 or earlier. I bet the alpha and beta version worked just fine too, long before it was released to the public.

 

FORTRAN I was originally developed by IBM at their campus in south San Jose, California[1], near the Leadwerks Headquarters, in the 1950s for scientific and engineering applications, it then came to dominate this area of programming early on and has been in continual use for over half a century in computationally intensive areas such as numerical weather prediction, finite element analysis, computational fluid dynamics, computational physics and computational chemistry, and of course recently also realtime 3D video game and simulation development using the Leadwerks Engine 2 [3]. It is one of the most popular languages in the area of high-performance computing [2] and is the language used for programs that benchmark and rank the world's fastest supercomputers.

 

Come on Lumooja...this is the kind of stuff that is so damn easy to get right with just a quick bit of research. http://en.wikipedia.org/wiki/Fortran

 

A draft specification for The IBM Mathematical Formula Translating System was completed by mid-1954. The first manual for FORTRAN appeared in October 1956, with the first FORTRAN compiler delivered in April 1957.

 

1957 it is then.

 

How come Fortran is the easiest language then also, besides being the fastest? :)

Look, array and matrix math is super easy: "a = c / b", now a, b and c can be arrays or matrices and it just works.

Or this: "a = 1", fills up the array or matrix a with values 1.

The expression: "Z(1) = Y + W(1) ! PROJ039" can be easily written also on a punchcard if your company hasn't upgraded their mainframes in a while:

 

Easiest, or easiest to you? What paradigms does it offer? Can you work with it as a functional language? Pattern matching? Closures? What threading models does it offer?

Fortran may be easy to learn initially, but keep in mind that a lot of it's paradigms (especially it's threading models for cluster computing) are fairly difficult to master.

There are three types of people in this world. People who make things happen. People who watch things happen. People who ask, "What happened?"

Let's make things happen.

Link to comment
Share on other sites

Well now I know Lumooja is almost completely out to lunch, since the math doesn't work. I thought you were serious about FORTRAN being faster then C/C++ in I/O writing, but I couldn't wrap my brain around it since you can embed assembly language into C/C++ for the most optimization and therefore the fastest possible code for reading and writing to disk. I guess in the end it depends on what functions you use for your tests, but I can't see FORTRAN being faster than C/C++ and even if it was I don't see it being faster by much.

 

I personally really enjoy his "tests". Very subjective. More importantly, I love how he only tested the absolute bare bone basic features and concluded that Fortran was faster*.

 

*Don't get me wrong, Fortran _IS_ damn fast. On average however, it's on par with C or C++. Where it shines is that Fortran is designed for cluster computing, an area where C++ fails hard.

There are three types of people in this world. People who make things happen. People who watch things happen. People who ask, "What happened?"

Let's make things happen.

Link to comment
Share on other sites

Hm... seems that BMax is some clone of Fortran! Very similar languages :) Thank you Lum.

Is there stand alona compiler like TCC?

Yes, you only need to install the latest mingw, and add c:\mingw\bin to your system path, and it works.

I downloaded this mingw-get-inst-20110530.exe (only 562KB) and it asks what you want to install, so you can choose only Fortran if you want a minimal Fortran compiler setup, but I would choose also C++, because you need it sometimes too (also here it's similar to BlitzMax: BlitzMax needs MinGW C++ too, to compile some BlitzMax programs which use C++ also):

http://sourceforge.net/projects/mingw/files/MinGW/

 

When it's installed you can compile your Fortran program like this:

gfortran game.f

 

And if you want to compile a C++ program it goes like this:

g++ game.c

 

Both will create a.exe, so you can rename it as game.exe, or you can add: -f game to the compiling lines above, then it creates game.exe directly.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

I personally really enjoy his "tests". Very subjective. More importantly, I love how he only tested the absolute bare bone basic features and concluded that Fortran was faster*.

 

*Don't get me wrong, Fortran _IS_ damn fast. On average however, it's on par with C or C++. Where it shines is that Fortran is designed for cluster computing, an area where C++ fails hard.

One single reason why Fortran is faster than C/C++ is that the Fortran compiler will load the values once and store them in registers.

It can do so because in Fortran pointers/arrays cannot overlap in memory, not even in multi-threading, while in C/C++ the compiler doesn't know if they do, and it takes a seperate copy into memory of all pointer values which might overlap.

 

In C99 and C++0x there is a new register keyword, which should overcome this slowness problem in C/C++, but most C/C++ compilers do the register keyword automatically and it is not adviced that the programmer uses it, because he might put pointer values as register which disturb the compiler's optimizations and thus make the code even slower. However, even with the automatic or manual register keyword, Fortran still makes faster code, so there must be a lot of other reasons too why it's faster.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Well now I know Lumooja is almost completely out to lunch, since the math doesn't work. I thought you were serious about FORTRAN being faster then C/C++ in I/O writing, but I couldn't wrap my brain around it since you can embed assembly language into C/C++ for the most optimization and therefore the fastest possible code for reading and writing to disk. I guess in the end it depends on what functions you use for your tests, but I can't see FORTRAN being faster than C/C++ and even if it was I don't see it being faster by much.

Example code please in Fortran or C++ or both (I can translate to either if you have only one language example), but without code there is no evidence. In theory everything works fine, but in practice things are often different. For example Intel put some delay code into their C++ compiler which made it create on purpose slower machine code on AMD CPUs than on Intel CPUs, and they got sued for that :)

I would love to code in Motorola 68060 assembler, but the problem is that barely any computer has those CPUs anymore.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

At the same time when I write the Fortran headers, I'm making also a UnitTest for LE2 which tests every command in LE2, because I need to test that each command works in Fortran too. It will be like a sandbox showroom demo, where the player can walk around and see different stands with different commands of the engine. The full source code of the demo will be available too, so it might be even useful as an example how to do certain things in LE2, or also generally how to make game logic.

post-2-0-86683100-1308756126_thumb.png

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

  • 1 month later...

One single reason why Fortran is faster than C/C++ is that the Fortran compiler will load the values once and store them in registers.

It can do so because in Fortran pointers/arrays cannot overlap in memory, not even in multi-threading, while in C/C++ the compiler doesn't know if they do, and it takes a seperate copy into memory of all pointer values which might overlap.

 

How can it be so sure that they won't overlap? Does it do runtime checking (which would be pretty slow...)?

 

You can promise the C/C++ compiler that two pointers won't overlap using __restrict:

 

int fast(int * __restrict A, int * __restrict B)
{
   *A = 5;
   *B = 7; // RESTRICT promises that A != B
   return *A + *B; // no stall; the compiler hangs onto
   // 5 and 7 in the registers.
}

int slow(int *A, int *B)
{
   *A = 5;
   *B = 7;
   return *A + *B; // LHS stall: the compiler doesn't
   // know whether A == B, so it has to
   //  reload both before the add
} 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...