Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

PHP to Fortran comparison

JohnNichols
Valued Contributor III
894 Views

From the PHP manual

Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.

------------------------------------------------------------------

In thinking that PHP is an improvement on Fortran - some other post on this forum, they are wrong, this makes debugging programs a nightmare, you have to print out and check every variable. 

You type $aveage instead of the real $average and you get a zero variable. 

------------------------------------------------------------------

I remember I think before implicit none.  

0 Kudos
6 Replies
Steve_Lionel
Honored Contributor III
879 Views

PHP is far from alone in not having variable declarations. I remember learning SNOBOL4 in college that behaved much the same way. APL as well has no declarations. Indeed, many programming languages are not "declarative". As I note in Doctor Fortran in "IMPLICIT Dissent" - Doctor Fortran (stevelionel.com) , the original Fortran did not have declarations either.

0 Kudos
JohnNichols
Valued Contributor III
858 Views

Some times  the Gods are still smarting over the issues from Troy.  

A whole day to track down one variable with two names across multiple files.   If you have to use PHP to create graphs from your Fortran data, don't.  

Also I was reading your IMPLICIT dissent, when did you write the missive, there is not a date on it, which makes it hard to determine if your references are recent or before some long ago time.  

Finally on your twitter site you use in your latest post  a method to quickly create CSV files, the interesting challenge arises from  the Europeans who swap . and ,.  It would be nice if the numbers looked like ,0.000 instead of ,.0000.  It is hard to write code to fix this problem, I have it and  I get a lot of these files.  

 

 

0 Kudos
GVautier
New Contributor II
839 Views

Don't forget Basic. It also had no variable declaration if my memory is good.

0 Kudos
JohnNichols
Valued Contributor III
817 Views
0 Kudos
andrew_4619
Honored Contributor III
835 Views

I remember many year ago in the 80s grumbling when the boss insisted that all variables had to be declared and the compiler option set to enforce it. How times change! The prospect of code with implicit typing  is just too awful to now contemplate. 

0 Kudos
jimdempseyatthecove
Honored Contributor III
813 Views

The (a) problem with implicit typing is it can hide typographical errors. This is problematic in two ways:

1) You are not notified of the typographical error at compile time

2) Possibly worse, it hides the problem at debug time

misSpeltName = something
...

Placing a break point on line 2 and examining variable misSpeltName, you will find the correct value (but which is place in the wrong variable... or should we argue as to if the target variable in line 1 is wrong or the use of the differently spelldName elsewhere is wrong. The algorithms in narrow scopes are valid but the variable naming is inconsistent.

Jim Dempsey

0 Kudos
Reply