Skip to content

Instantly share code, notes, and snippets.

Created November 14, 2012 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4073519 to your computer and use it in GitHub Desktop.
Save anonymous/4073519 to your computer and use it in GitHub Desktop.
What if PHP was not that bad?

I totally agree that PHP has a lot of drawbacks and anti-features. I enjoy the depth and comprehensiveness of critics that many people provide. There’s much to learn from them. Yet I outrightly disagree with statement like, “The language, the framework, the ecosystem, are all just bad.” Ecosystem in terms of far-standing service- or product-specific libraries - maybe. But ecosystem in terms of core functions (GD, string handling, etc.) is mostly quite good. There are very nice (micro-)frameworks too. All in all I believe that usefulness and usability of a piece of technology is not a sum of its “features” and not always deteriorated much by the sum of its anti-features. “The product is what it does and not what its features are.” And what does PHP do?

Well, It enables people and among them those who are pretty new to programming easily create simple yet “real-world” web-applications. At least by standards of 1995-2005. (Today we demand single-page and real-time web apps, and PHP goes out of the game here.) How did PHP achieve that? I think that answer has two aspects. First. Documentation. PHP (prior to version 5) had pretty good documentation. (And by that I mean pretty good.) Did you saw Ruby’s documentation? Not today but as it was five years ago (main doc, stdlib doc overview)? Did you try Google search for “python sort()” back then? It had been giving you nothing. While “php usort” or even just “usort” search always got you straight to PHP online documentation page. Pamela Fox did talk about that aspect of “Developer Experience” at WDCNZ 2012. She also mentioned that PHP team was among the first ones who allowed commenting in their online documentation. And they were not teemed with spam, they were helpful and they created an experience similar to Stack Overflow years in advance. Also there was an epic “Function Reference” part of the manual which gave you an overview of what PHP “can do” in one glance! You had the repertoire of the system, you knew what you can do with it. Also examples. PHP manual always had simple yet useful examples (When PHP version 5 came out, many new OOP-related examples were terrible - contrived and unrealistic). So for people who learn by example PHP docs once were a big help too.

That was the first aspect. The second one is more interesting, I think. Let’s call it BASIC-effect. Or Lua-effect. Or maybe Processing-effect. What I’m talking about is a fine balance between low-levelness of the system and its ease of use. For example, C is low-level but it’s pretty hard for beginner to create a real-world app with it. On the other hand Ruby on Rails seems much friendlier but it’s too high-level, so with it you can only travel where rails have been laid down. In such environment you do not feel yourself as creative as when working with lower level tools. Works you produce are not as diverse and original, and you do not feel the corresponding surge of motivation.

Paradox is that despite its presumably numerous flaws PHP had attracted many people to programming. Surely we need other systems to build complex web applications. And what’s true for PHP with regard to web programming is irrelevant in other domains. E.g., for console applications you may want something else. Naturally more experienced developers may feel a need for conceptually richer and more expressive systems (LISP, Haskell). And above all that, PHP’s time is gone. The world needs modern systems that turn ordinary people into programmers without intimidating them with Eigenclasses (why other systems lived without Eigenclasses for decades and Ruby can not?) or “strings” that have dozens of methods, or objects and inheritance, and punishment for wrong indentation. In web programming the war is almost lost. New APIs look hopeless. HTML5 is complex, counterintuitive, uncomfortable (IndexedDB anyone?). And where the heck is the official documentation? (Don’t tell me that novice should even recognize that W3C specs are documentation.) I do not mean lengthy articles filled with water but concise, organized docs structured in such a way that you can overview the system quickly. JavaScript? Well, we all heard about “bad parts”. Yet it seems that Node.js takes pretty much PHP’s place these days. I think that’s a little bit sad because Callback Hell corrupts. But do we have any alternatives? Any ones that are sufficiently low-level but seem easy to enter?

P.S. Debuggability. If you typed an accidental comma in PHP it used to say something like, “Parse error: syntax error, unexpected ',' in /path/to/script.php on line 218”. That’s all. But did you try this in Django? Just one mistyped comma causes hundreds of kilobytes of intimidating and irrelevant gobbledygook to be printed on the screen. Yes I know that this is completely from novice’s perspective and who cares?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment