I have heard so often that Perl is a bad language and you should never use it. Recently a college friend of mine switched to PHP, and was trying to convince me that PHP was the best thing in the world. They have all sorts of pre-built applications and libraries that make it easy to do things (sounds a little like the CPAN).
I told him about my one major roadblock with PHP. My problem is in the following code, and yes this code actually caused me trouble, this isn't a hypothetical situation:
I was dealing with a table of customer information. I had imported some production data into the test instance, and was working away. After some time, I found that any record I touched, the Zip code was replaced with an empty string ''.
I checked where the assignment was happening:
$ZipCode = $GET['ZipCode'];
(or however you get things from GET parameters, its been so long.)
I checked the SQL update statement:
$sql = "UPDATE customers set ZipCode = $ZipCode WHERE ...";
I checked the database:
SELECT ZipCode FROM customers WHERE ...
The code to display the page:
print "Zip code: $ZipCode\n";
... still displayed just fine.
And the code for the text field:
print "Zip code: <input type='text' maxlength='10' value='$ZIPCode' />\n";
Now if you see the problem after the first time through, then you are more fortunate than I.
For those that don't see the problem here, there is a case sensitivity issue here between $ZipCode and $ZIPCode.
I spent half a day working on this problem that would have been solved in Perl with 'use strict' or VB with 'option use explicit' or would have never happened in C or C++ or just about any compiled language.
My friend told me that this is solved by being careful, and having good coding standards. I agree that it may be mitigated by good coding standards, but what will prevent me from fat-fingering the word $ZipoCode, or any of the possible permutations on that. No amount of code standards fix a fat fingered spelling. This is fixed at run time with the interpreter saying 'WHOA JIMMY, WHATCHA DOIN?' If PHP had something like 'use strict' then I might very well be a very sloppy PHP programmer right now, but alas my senior developer suggested that I try re-writing what I had in a different language and see if that is better.
So, in conclusion: I do not consider a language useful or 'good' until it has something that can tell me explicitly that I am using two variables here:
$ZipCode
$ZIPCode
and not just fill one with an empty string an move on.
I am not against PHP, but I cannot recommend it as a language to solve any problem until this is solved.
As a Perl programmer, I am comfortable in my little nest that I have created, but I feel that must not ignore all the other languages out there simply because I like my language. You probably know the phrase: "When all you have is a hammer, all your problems begin to look like nails." As such I want to keep open to learning other languages, but the lack of variable name declaration is one way to keep me away.
I told him about my one major roadblock with PHP. My problem is in the following code, and yes this code actually caused me trouble, this isn't a hypothetical situation:
I was dealing with a table of customer information. I had imported some production data into the test instance, and was working away. After some time, I found that any record I touched, the Zip code was replaced with an empty string ''.
I checked where the assignment was happening:
$ZipCode = $GET['ZipCode'];
(or however you get things from GET parameters, its been so long.)
I checked the SQL update statement:
$sql = "UPDATE customers set ZipCode = $ZipCode WHERE ...";
I checked the database:
SELECT ZipCode FROM customers WHERE ...
The code to display the page:
print "Zip code: $ZipCode\n";
... still displayed just fine.
And the code for the text field:
print "Zip code: <input type='text' maxlength='10' value='$ZIPCode' />\n";
Now if you see the problem after the first time through, then you are more fortunate than I.
For those that don't see the problem here, there is a case sensitivity issue here between $ZipCode and $ZIPCode.
I spent half a day working on this problem that would have been solved in Perl with 'use strict' or VB with 'option use explicit' or would have never happened in C or C++ or just about any compiled language.
My friend told me that this is solved by being careful, and having good coding standards. I agree that it may be mitigated by good coding standards, but what will prevent me from fat-fingering the word $ZipoCode, or any of the possible permutations on that. No amount of code standards fix a fat fingered spelling. This is fixed at run time with the interpreter saying 'WHOA JIMMY, WHATCHA DOIN?' If PHP had something like 'use strict' then I might very well be a very sloppy PHP programmer right now, but alas my senior developer suggested that I try re-writing what I had in a different language and see if that is better.
So, in conclusion: I do not consider a language useful or 'good' until it has something that can tell me explicitly that I am using two variables here:
$ZipCode
$ZIPCode
and not just fill one with an empty string an move on.
I am not against PHP, but I cannot recommend it as a language to solve any problem until this is solved.
As a Perl programmer, I am comfortable in my little nest that I have created, but I feel that must not ignore all the other languages out there simply because I like my language. You probably know the phrase: "When all you have is a hammer, all your problems begin to look like nails." As such I want to keep open to learning other languages, but the lack of variable name declaration is one way to keep me away.

