Prusak.com

Serving up my thoughts since 2004

Month: November 2004

Article Update

In my last article I said I would be continuing my understanding PHP in three weeks. Things are not going according to my original schedule and I thought I would give you all an update.

Previously I spoke of the three pillars that hold up any great PHP programmer. At the time I had in my head something along the lines of:

  • An excellent command of PHP’s built-in functions.
  • Extensive real world experience building web based applications.
  • A thorough knowledge of general computer programming concepts

After I started to do some research for the article itself, it became apparent that I was missing a crucial element: Software Engineering. For those of you that aren’t 100% absolutely positive they know exactly what that means, you should check out the wikipedia entry on the subject. For the click-lazy, software engineering deals with ALL aspects of creating software, not just the programming part.

I was then trying to come up with the structure for the article. One of the ideas, which I’ve had in my head for a while, is to cover in detail a single request for a web page from start to finish. If you’re thinking you already know everything that happens when viewing a web page created in PHP, think again. I’m talking about everything from DNS lookups to databases indexes to operating system memory management techniques to TCP/IP. And of course PHP internals as well.

To make a long story short (hmmm… to late for that) a very prominent web site read my “How did we get here” article and has asked me to write a series of articles for them. Hopefully you’ll be able to start reading them in January. I can’t go into detail right now, but I can assure you it will be worth the wait.

Ophir

PHP – A Programmer’s Perspective

This article will hopefully give you a better understanding of PHP, and how we get here in the first place.

Too many people know PHP without really understanding what’s going on under the hood.
The big picture as well as the small details. Not just the “how” but also the “why” and the “why not”.

First, I’d like to give you a better understanding of why I’m writing this article and how we got here in the first place. Afterwards I’ll help you get a better understanding of PHP.

I’ve been doing web development (mostly back-end) since 1995 (I actually introduced Zeev Suraski to PHP). I’ve been involved in projects ranging from complex sites with millions of page views a day, to helping kids write their first PHP script. Recently I’ve changed tracks, from mostly development, to teaching PHP. The title on my business card now reads “PHP Educator”. I was a technical instructor for 2 years in the army so this comes as second nature to me.

As part of my new role I have been exposed to a lot of people who want to learn PHP. In addition, I have become more aware of existing learning materials and other resources for people who want to learn PHP. This includes the PHP manual at php.net, various php “how to” web sites, articles, books, mailing lists, users groups, etc.

While many of the ideas in this article have been in my head for quite a while, it wasn’t until I started teaching that I connected the two main ideas I’d like to write about:

  1. There are two very different types of PHP programmers.
  2. Many of the “Learn PHP” articles online are evil.

After explaining why the two different types of PHP programmers are different, it should become obvious why most online articles are evil.

In many ways PHP has changed the landscape for computer programming. It has certainly lowered the entry barrier to programming:

  • It can be embedded into an HTML document.
  • It has a very easy learning curve: most people can start writing their own scripts within a couple of hours.
  • Most Unix-based web-hosting packages include PHP support, more than any other programming language.1
  • It has given the public a whole new motivation to write computer programs: anyone who is involved in creating web pages and wants dynamic content can easily do it.
  • You can even download it to your PC or Mac and run it locally.
  • All of this comes without a hefty pricetag; PHP is free!

I’ll be the first to say I am very glad that PHP has opened up the door to programming to so many people. Unfortunately, some issues have arisen because of the way most people learn PHP.

PHP was written from the ground up to solve a specific task – creating dynamic Web pages. In many ways, this makes PHP different from most other programming languages. In order to be exposed to most other programming languages, you would probably be a programmer, an aspiring programmer, or someone who is heavily into computers. For these people, programming is the “end”, not the “means”.

I know I got into programming this way. I learned programming because it was fun. There wasn’t a specific task I needed to accomplish. I just enjoyed it. Later, I got my Bachelor’s Degree in Computer Science.

On the other hand, many of the people who are exposed to and want to learn PHP, don’t really want to be programmers per se. They just want to create dynamic web sites. PHP is the means, not the end.

So, let’s say you’re cool with HTML, CSS, maybe even some JavaScript and you’ve decided to take the plunge and learn PHP. Since you’re already very familiar with web and you probably learned HTML from the web (online tutorials and view->source) then why not do the same with PHP?

There is the php.net online documentation as well as plenty of online tutorial sites, and all of this information is FREE. You can read a few introduction tutorials, a few How-To articles and voila – you’ve just written your first guestbook in PHP.

The problem is that you’ve been learning how to use PHP to solve specific problems and not computer programming in general. These tutorials have been feeding you fish, but no one is teaching you how to fish for yourself.
All of this brings us back to why there are two different types of PHP programmers.

I think there are two main groups that most PHP programmers fall into.

1 – People who write computer programs for their day job. Most of these people either have some formal education in computer science, or have been programming for a while and are self taught and know the fundamentals of computer science.
For simplicity’s sake, I’ll call these people programmers.

2 – People whose day job involves the web or computers but their title is not “programmer”. These are usually web designers2, system administrators, PC technicians, etc. For them, PHP is something that can add value to their work, but is not their direct responsibility.
For simplicity’s sake, I’ll call these people “designers”.

The designers are very different from the programmers.. They lack a proper foundation of computer science fundamentals. The problem is that they don’t know what they’re missing. In other words, “they don’t know what they don’t know”.

This brings us to why many of the “Learn PHP” articles online are evil.

They’re written by the designers. Of course they mean well, but the articles often explain a specific solution to a specific problem. They usually teach by example, going into detail with the “how” but not the “why”. These people had a specific problem and were able to solve it with a specific solution. It works even if it’s not the “right” solution.

If all you know how to use is a hammer, everything looks like a nail.

Before I continue, I’d like to point out that in many cases, it doesn’t matter.
If you’re writing an intranet application that allows company employees to choose what they want for dinner, who cares how it’s written. If it works – it works. Period.

Unfortunately, the “if it works – it works” concept has crept into the professional realm as well. This is one of the biggest problems a company has when trying to evaluate programmers. You can’t “see” a computer program in the same way you can see a building or a piece of furniture.

Sure you can view the source, but that means nothing to non-programmers. All the client really cares about is if it works, not how it works. This means that your code could be:

  • Insecure (easy to break into)
  • Inefficient (gets really slow with large data sets)
  • Non-scalable (won’t work for more than 100 users)
  • Unmaintainable (difficult to understand and modify)

But it works.

For those of you who want to write applications that don’t just work, first you must understand how to write good software in general. My goal is to help you understand.

In my next article, I’ll help you understand the three pillars that hold up any great PHP programmer.

As always, comments are very much appreciated.

Ophir

Footnotes:

1. OK, I don’t have the facts to back-up the “more than any other language” but please send me data either proving or disproving this.


2. By Web designers I do not mean people who create a PSD in photoshop and hand it over to the “tech guy”. I am referring to people who’s primary concern is the front end and are fluent in PC or Mac usage. They are experts in all aspects of web related “front end” technologies. This includes HTML, CSS, DHTML and some JavaScript. They understand the pros and cons of using a gif vs a jpeg (or png) image. They understand how page caching and cookies work.

My Old Blog

I just realized that I started a blog back in June 1996.

That’s right. Way back in prehistoric times. Of course back then the term blog didn’t exist. It’s just nice to see that I was ahead of my time. Of course after three entries and almost zero feedback I called it a day. So now, over eight years later I’m giving it another try.

Here is it (from archive.org) http://web.archive.org/web/19990129050949/www.netvision.net.il/~ophir/imho/

New and Improved

After not making any real changes to my personal web site since 2000 (other than updating my resume) I’ve decided to go down the path of Blog.

Here it is.

Enjoy.

If you really want to see the older version of my web site, here it is.

© 2017 Prusak.com

Theme by Anders NorenUp ↑