An interesting analysis of why PHP is so popular

I just read an article about “replacing PHP” as the dominant web programming language.

While there’s nothing really new discussed in the article, it does a good job of refreshing the view that PHP is more than just a language. There are two distinct advantages the paper points out:

  1. The language is batteries included as far as web programming goes.
  2. It’s installed everywhere.

Many giant web applications use PHP, which is a testament to its flexibility and power. It’s also, I would guess, the first place people turn to when writing a new web site. I think Lisp could learn a lot from PHP, and I hope to help that along, if I can.

For me personally to learn from PHP, I have to think of it as a colleague to Lisp. I have a lot of prejudice against PHP, much as people have prejudice against Lisp. For site like Flickr, Wikipedia, and Facebook–all of whom deal with enormous availability problems–to have stuck with PHP, well, that means something profound.

While previously I respected PHP programmers, I always felt that they must not understand much about actual computer science. They were stuck in a procedural world, and a glimpse of what “more advanced” languages could show them would “enlighten” them.

One of the dogmatic ideas I held was that a language that allows you to adapt the language to the problem is a necessity for programming. Otherwise you just rewrite the same boilerplate code over and over. This is an idea best described by Paul Graham. It simply isn’t true.

While it is enormously helpful to factor out boilerplate into macros and functions, essentially developing a mini-language to tackle your problem, there is another method that can accomplish the same goal. A programmer can factor out boilerplate into functions and classes, creating an API or library. The library can be reused in much the same way the mini-language can be. And it provides the same benefits.

And so you have giant PHP libraries, supporting various routine tasks. And you might not have all of the power of Lisp’s closures and recursion, but you have enough to create a giant encyclopedia or host billions of photographs. Could that be done with Lisp? Of course. Can Lisp really boast of such extravagant claims of power? I doubt it. Can Lisp learn from PHP? I say emphatically: Yes!

[Update:added response to first rhetorical question in paragraph above. Thanks to the anonymous commenter for pointing out it was unclear.]

Related Posts:

  • No Related Posts
blog comments powered by Disqus