5 things we should learn from PHP

Personal Home Page came in the time everyone wanted one. In the late 90's, it became most popular language for the web.

PHP is first language for many people. However, who dares to touch another language, rarely looks back and think about PHP as some sort of hacky glue thingie noone likes.

Yet, there are lessons and gems hidden in PHP that are rarely found in other languages. We should learn them.

5. Fits into existing knowledge

You know, most of those kiddies will learn HTML as a first „language“. HTML is neat, You have normal text, add some strange tags and voilá – my Personal Kitten Page is here.

So it's easy to learn. Almost everyone can do that over a weekend or two. And PHP is there as a logical next step – you'll just add another strange brackets and it's just expanded into text.

Precompiler at it's finest.

Yes, gradually people will learn it's best to separate application logic from those templates, but this step-in-between is crucial for hooking programmer to language.

4. Straight flow (without frameworks)

Access puppy.php and have it – HTML file with brackets, parsed from start, rendered nicely to user.

No dispatcher, no confusion about what got executed, no painfull steps during debugging.

This decoupling is fine, MVC pattern is cool one. But this single point of entry, coupled with URI is so cool for clarity…

3. Functions. Hell Yeah.

Functions are easy. They are, like, You know, similar to that thing they told me in my Math class.

And I'll tell you truth: I just retrieve my kitty, put it in this damn table and render it. What is this CuteAnimalObject anyway?

2. This ugly (error) forgiveness

I'm just human, I make errors and I know it. But this site works! This little warning rendered in my page is just enough for me and I know what to do with it (finally I know what this @ is for).

I don't like those stupid compilers to stop working, or some strange exceptions thrown in my face. Anyways: who would dare to show 500 page to the users? My kittens will be shown; okey, maybe one or two will be missing, but I'll have a word in my logs.

And I'd like to work, ya know? I'll go back to fix those error properly later.

1. Developer satisfaction: Instant feedback

Add description, ctrl+s, alt+tab, F5 – and it's there! No interpreter reload. No stupid compiler running.

I wrote it. I save it. And it works. Instantly. I like it.

Conclusion

For the record, I'm stuck with old and ugly, 60k SLOC of spaghetti, cut&pasted legacy codebase, written in this favourite language by three incompetent developers (my younger self included). I hate every minute I must spend maintaining it.

PHP is an awful language, with inconsistent naming conventions, missing features and completely nonexistent consistency. It's „design feeling“ completely changes over time, making it ever worse to work with.

However, I still remember how I was drawn to it. And language that takes most of those eager to learn will win in the long run. Also remember, a lot of those important applications were not written by PhD computer scientist (missing their lambdas).

So, this is a little shout do all developers of those shiny web languages and frameworks. I know why most of those things are not supported, not easily doable or not wanted, but hey.

Until we speak fluent Erlang since our birth, there is always a room for improvement.

Published on March 22, 2010 under english php programming technology