I Have Tried Fortran
This week I have done a lot of low level programming. I have played a lot with my first love (C) and I have been flurting with MASM (Microsoft Macro Assembler) but now I am trying something new. I started to read about the well known Fortran! To make you a shot resumé of the of Fortran, it has been created in by a guy named John Backus at IBM in 1954… Yes, it one of the oldest programming language and at this time it was revolutionary because it was already an alternative to the complexe Assembler. Even if this language has the reputation today of being incredibely hard to learn, at the time it was more friendly than Assembly and Algol. Since its creation, Fortran has influenced many programming languages like C, BASIC, Algol 58 and many others. Lets be honest, this language is pretty useless nowadays and I would never recommend to learn in because the language is dying, there are only few jobs opportunities with it and it is not really efficient if you need to create big things. But if you are a troll like me and like this kind of stuff, you will see that it is cool. Now I will show you how to write a program in Fortran, if you want to follow you can download CodeBlocks with the Fortran setup here:
My First Fortran App
Now lets take a look at the Fortran code. Here it is a simple application where the user try to find the sum and the application will show a different message depending on if he gave the right answer.
! A fortran95 program for G95 program main ! Start of the main implicit none ! Dont know.. integer re_i, en, a, b, answer ! Here we declare our variables a = 10 ! We assign a value to our variables b = 10 print *,a," +",b," = ?" ! Print an equation answer = a + b ! Store the sum in the var answer read *,en ! Take an entry if(en == answer)then ! Start of a if print *,"Yeah! You Rock!" else print *,"No! You Suck!" end if ! End of the if print *,"The answer was Answer: ", answer ! Print the answer re_i = system("pause") ! Prevent the console from closing end ! End of the main
This is not the oldest version of Fortran, this is Fortran 95 and the first time I saw this syntax I tought it was very weird. The weird thing is that the text is not really framed by any brackets or parentheses and for the conditions you use if and end if. Fortran is also very low level… with a modern language like Python you could probably make this program in 5-10 lines of code. Brief, I’m not here to bash Fortran, we can say that it obsolete (and it is true) but we can’t forget that this language brought us to the moon in the 60s.