July 2009 Archives

PHP needs 'use strict;'

| 7 Comments
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.

blog wierdness

| 2 Comments
It seems that before this, I didn't allow comments, nor did I have the proper tags for my entries, so I am not sure if anything was getting counted for ironman ...

Here is hoping Ironman is tracking my stories properly now.

olegm

Once a week -- Frozen Perl Planning start

| 1 Comment
A problem with this ironman blog, is that I am required to blog every week, even though I may not have a lot to say about perl or perl6.

So, instead of blogging about the features of the language, I will post about the progress on Frozen-perl.

Current Status: tenative hold on the venue.
Next todo: get the venue down payment in.

Pretty simple, just need to do it.

Getting involved in the Perl community or any open source community is fairly simple as long as you follow a few guidelines.

there are two different scenarios for a newcomer to a community:
  1. you want to be involved, but you don't know how
  2. you know what project/area you want to be involved with.
For the first item, I highly recommend getting on the listserve for the YAPC in your region of the world, and the local Perl Mongers (PM) group. Go the PM meetings, learn from them, become a familiar face. Find out what projects they are working on, and if one interests you then you have moved into the second scenerio.

For the Second scenario, this is the easier way to get involved. If it is a project, install git or svn and get the source code of the project on your local machine working. Start small by submitting bugs, and move up to fixing bugs, and then to feature requests.
If you cannot contribute code to the project for whatever reason (hey! some people have families and lives), then help out in anyway that you can. For example, I put up a BOF page for the CGI-APP folks to get together at YAPC last month, It know its simple, but noone else had done it, and it may not have happened if I hadn't pulled it together. It might have, but we'll never know.

Guidelines to follow for either group:
These groups have a certain culture already established. Spend some time lurking, get to know how they operate before sending emails to the whole group.

These groups/communities already have leaders and 'elders'. These people are the ones to answer questions and provide direction. They have put a lot of time, effort, and love into this project, and they don't need some noobie coming in and creating a mess/causing drama. It is likely that they have experience that you don't, so listen and learn from them.

Look for a need and do what you can to fill it. When I became the leader of Frozen Perl 2009 workshop, I had already been invloved for a year, and I asked the previous leader if I could take over, since he seemed uninterested/unable to continue. I didn't "take" the position away, rather, I saw a need for a new leader, and asked if I could take the load away from the previous leader.

All in all, you just need to dive in, and get involved. There is no magic solution to help you, and you won't likely be asked into the community you want, so ask them how you can help.



If you are hoping to get more people into the Perl community, or the community surrounding your open source project, you need to ask them personally. Sending messages out en-masse may yield a few hits, but taking the same amount of time, and asking a few people directly will get better results.

For example, this blog is a direct result of MST asking me for a feed URL, not because we had a conversation about it, but because I told him that I liked the ironman challenge, and I found his lightning talk entertaining. In response, he told me he expected a feed URL for my blog.
Oh sh*t. Now I need to actually do something. Granted, it was unlikely that mst would remember me, or even know my name if I didn't follow through, but I had a well known member of the community ask me to do something for the good of the community. Now I am writing this blog, once a week, because Matt asked me almost offhandedly for a feed URL. If he hadn't spent that 20 seconds to ask me, but instead just said thank you for the compliment, this blog wouldn't be here.

In my own personal experience, I asked via a mass email if folks in my department at the University of Minnesota would like to help prepare and submit a bit for YAPC.
Zilch,
zero,
nada,
nothing.
I then asked a few people directly, and got several "yeah sure, I'd love to help". As a result, we had a nice team of people for our bid for YAPC.

In fact my own involvement with the Perl community with talks and Frozen Perl was because my coworker asked me to help organize the event and submit talks. Now two years later I have written four 20 minute talks, helped organize two Frozen Perl workshops (leading one of them), and put together a complete YAPC bid. All because two years ago at this time, a coworker asked me to share the knowledge I did have, even though I wasn't an expert on any Perl topic.

The moral of this story is: If you want a vibrant community you need to be like MST and ask individuals to be involved. Ask them to do what they are good at. If your group needs to have a moderator on the listserve, or someone to organize social events at an event like YAPC or OSCON, that is a good job for someone who cannot code on your project.

This gives the non-technical folks or people unfamilliar to your project a chance to really help. Sometimes these jobs are just as important as the jobs for the 'really smart' guys. Imagine if noone ever organized hackathons/class space for Patrick Michaud to work on/teach Parrot. The Parrot project would look very different if he had to do all that work.

My topic for next week: Getting involved in the Perl community - how to get involved yourself

Which language to learn?

I was reading an article on slashdot, and I was angered by the writers comment: I also feel that I am going to come out of school not having the expertise required in a single language to land a good job. The most important thing the education gives you is the knowledge of concepts that is applicable to any language. It is far more frustrating to tell someone to use a quicksort, and get a blank look, than to tell them to use the built in 'xyz' function and get the same blank look. Not understanding what a specific piece of the language does, is fixable by a google search. Not understanding how an algorithm performs is fixed by a 15 week college course.

As an employee that teaches students what they need to know to work on projects, I would rather teach you what perl's bless does, than to teach you how objects work, and why you should use an object.

The writer of the main slashdot article is only concerned that he doesn't know a single language well enough to do any work, when it is far more important to know how to do the work, and then to learn the tools that the project manager has chosen.

Perl is not dead (Part 3)

The Perl community has stuck around, despite the old really bad Perl programs that have been written. They have written and maintained modules on the CPAN. The CPAN is the single best feature of Perl. Without the libraries on CPAN, Perl wouldn't be able to stand the test of time against the other newer languages like Python or Ruby.

The Perl community is very much alive too. There are workshops and conferences put together by volunteers, because they love the language. I am one of those people, and I personally have thrown hundreds of hours into planning and executing perl workshops.

Perl is not dead (part 2)

Perl is the internal combustion engine of the programming world. There are a lot of newer sexier languages, that just don't have the installed base yet, and don't have the legacy code yet to drag it down. In five years I would like to hear people who have to learn ruby so that they can maintain today's newest Ruby on Rails application. I doubt it will be any better than any other language or framework. Don't get me wrong, Rails is a great framework, but after five years of code rot, any project becomes a beast to maintain.


About this Archive

This page is an archive of entries from July 2009 listed from newest to oldest.

June 2009 is the previous archive.

August 2009 is the next archive.

Find recent content on the main index or look in the archives to find all content.