The problem with PHP isn't merely that you can write cleaner code, or more maintainable code, in other languages. The other languages also offer abstractions that are difficult or impossible to make use of in PHP.
But, that said, I agree with the point of your essay. It really doesn't matter that a hacker's first language is lingustically impoverished. The entire point of being a hacker is that you go on to learn several more languages. And I don't buy the argument that your first language indelibly warps your mind -- that's an argument from the era of old-school microcomputer BASIC, the kind with line numbers, no function calls, and only global scope. That was a terrible language, far more impoverished than PHP ever was, yet I and everyone I know started with it, and we all grew out of it just fine.
The other point I'd make is that far too much attention is paid to the reasons why PHP sucks, when we should instead be trying to figure out why PHP even exists. Specifically, we should be trying to figure out why all the PHP programmers didn't learn Perl instead, and (more importantly) why Java didn't displace PHP despite its massive marketing advantages and its (supposedly) better design.
>The other point I'd make is that far too much attention is paid to the reasons why PHP sucks, when we should instead be trying to figure out why PHP even exists.
Because you can go to GoDaddy today and pay $3.99 for a hosting account and start writing PHP code right next to the HTML in your site. It's simple. If all you know about web programming is HTML, then PHP is an easy next step.
Also, it's widely used.
Does Perl do that? I don't know. I don't think Ruby or Python come close to the simplicity. It took me way longer to set up my first Rails server than it did to write my first PHP function.
I agree that PHP's superior usability for newbs begins in the first five minutes. But I don't think that's the whole story. You can also embed Perl, Ruby, or (I presume) Python in a simple HTML page. (Though I believe that there is no canonical, preinstalled, universally accepted way of doing so, which is a big usability problem.)
And I don't know of any technical reason why Perl couldn't come installed on a $3.99 web hosting account. (Perhaps it did, back in the day. I no longer remember. I did web programming in Tcl back then.) I've also heard that Python is fairly easy to host, and even Ruby is getting there -- Heroku gives you Rails, for perhaps even less effort than it takes to use your cheap webhost's PHP. You don't even have to figure out ssh or FTP to use Heroku.
But, alas, the problem is bigger than that. It's not just the first five minutes of Perl that are tough. It's the twenty hours after that. And something like Rails, which requires you to be familiar with databases and OOP, is on yet a higher plane of difficulty.
Hilariously ironic: I recently upgraded PHP and something got borked with my Debian repos, so I did an apt-get upgrade to push everything to the latest version. Something seems out of whack with my new Apache, it's hogging a lot of memory, which is a bit of a problem since I'm on a VPS and have no swap space. I restarted Apache and everything seems fine, so I'm assuming it's fixed, but I'll keep an eye on it.
I personally see nothing at all wrong with PHP. I'll go read some of the other posts, but I wonder what's so bad about it. (OK, except that built in function names have no pattern to the naming.)
I think people hate it precisely because it's so easy to get started with. Have you ever met people who, the more obscure something is, the more they like it?
Linux is now too mainstream for them, so they use hurd. You see it with health food too - regular health food is too mainstream, so now you must eat local. Soy used to be eaten only by health nuts, now that it's mainstream, they say not to eat it.
These are people who hate all the regular languages and love the obscure ones (I won't name them for fear of flame wars). You can like an obscure language, but if you also hate the regular ones, you just want to be different and that's all.
I haven't followed PHP closely throughout its history, but I think at least some of the hate comes from questionable features that used to be a problem, like magic quotes or register globals (and the underlying problem that PHP would let you write code without knowing what you're doing, and thus ending up with horribly insecure web code). I think a lot of that has been fixed, but the perception lingers.
Another reason to dislike it is that it occupies a somewhat awkward niche in the language spectrum. It's not as strict as something like Java, which can make it more difficult to use for large projects. It's not as powerful or expressive as something like JavaScript or Ruby/Python, which makes it a lot less fun to use.
The only thing PHP really has going for it is that it's the closest you can get to a language that allows you to just write code that works "on the web", without having to fiddle with any server configuration or install anything (and it has a good set of libraries well-suited to this purpose).
These are people who hate all the regular languages and love the obscure ones
Yes, this is all true. Being different is fun!
But some people use real programming languages because they understand programming, not because being intelligent is "obscure". It is possible to get started with PHP quickly, but I can hack applications together very quickly in Perl and Lisp too. The difference is that these quick hacks turn out to be maintainable and extensible. Hacking around PHP's brokenness gets very tiring very quickly. (PHP is like writing C that executes 1000x slower and requires more use of the shift key.)
Just because PHP is easy doesn't mean that it's the only language that's easy -- pretty much everything but Java and C are just as easy. (And with the right tools, these are pretty easy too.)
I think that most lovers of "obscure" languages (I'm thinking Lisp, Erlang...) couldn't care less about being different. These languages challenge your mind and allow you to solve problems more efficiently.
Or have you every seen a serious project done in Whitespace, Brainfuck, etc?
Sorry for adding a 3rd post to the PHP-as-a-first-language series of HN topics, but everything I would reply to them I already put in my post, so I figured I may as well submit instead.
no offense: you don't have idea. Learn very well some other good language and you will see the difference. This is natural in programmers, until they don't know what is the next step what they have now sounds good, but often it is not.
I'm perfectly fluent in C and Java. If writing a thread library and process scheduler isn't the next step (or 3 past it) I don't know what is. I wouldn't comment saying one thing is better than another (which, you may note, I didn't) unless I'd tried both.
The argument here seems to be that PHP is great because you can use it to get things done quickly.
But Python and Ruby, among other languages, are also available for Web programming, and you can get things done quickly in them as well. Plus, you can do some things in them much more easily than in PHP.
I think the most important thing in the development of any hacker is to constantly scratch the creative itch. A close second to that would be to constantly explore.
While PHP scores better on those measures than some other languages, I think developers that use it day-in and day-out eventually find it painful to use. At that point, the language becomes a burden, because it discourages you from creating and exploring.
I think it boils down to where you are on the learning curve and how much heavy lifting you need/want to do on a regular basis.
But Python and Ruby, among other languages, are also available for Web programming, and you can get things done quickly in them as well. Plus, you can do some things in them much more easily than in PHP.
I hold out great hope for these languages, but they are still very new. (Technically, the languages themselves are as old as PHP or older, but their popularity in the web problem space is new.)
Some of the advantages of being old are easy to appreciate, like the fact that PHP is so easy to deploy that most cheap shared hosts deploy it as a matter of course, and the fact that it runs really fast. Others are more subtle. There are enormous user communities centered around user-focused, PHP-based toolkits like Wordpress and Drupal. Ruby and Python just don't have these yet, but that may just be a question of time. The Drupal community is now huge, but it took nearly eight years to get to this point. There are a few Ruby and Python-based projects which aim to be the equivalent of Drupal (everybody wave to the Insoshi folks!), but they're only a year or two old.
Which is too bad, because Ruby is so much more satisfying than PHP. The future cannot arrive soon enough.
If you're going to disagree with me (and of course you're more than welcome to), please elaborate on your position. Simply stating that I'm wrong contributes nothing to the discussion.
Plus I'd like to hear differing opinions, especially since PHP tends to bring such heated debates.
To put it less shortly, I will have to write my own article.
But I always wanted to do one.
"Solving the web problem" means nothing unless we can define what the problem is. If the problem is to quickly push out a dynamic page, then PHP is good, at least as good as ASP or JSP in their PHP-ish mode.
Its adoption rate also shows it's a good solution to the "push dynamic pages out" problem, but there are at least two angles to this problem: the point of view of the programmer and the point of view of the server manager. I suspect the adoption rate has a lot to do with the availability of "US$ 2.99 hosting" options, most of which offer PHP. So, it can be popular both because it's a really good option, because it's dirt cheap or a combination of both.
You emphasize the rapid results thing, which is good - if the larval programmer doesn't get some feedback, he or she won't stay interested long enough to learn. But there are other ways of giving feedback - a GUI, for instance. Or printing to the console. No web is required here except for the reason PHP is web-centric.
And then, there are the structural problems with PHP. No namespaces, too much magic in type conversions and so on. Believe-me: I have seen a generation of programmers lost because they were poisoned by Clipper and then by VB. They never really recovered. Maybe ther never will.
But, that said, I agree with the point of your essay. It really doesn't matter that a hacker's first language is lingustically impoverished. The entire point of being a hacker is that you go on to learn several more languages. And I don't buy the argument that your first language indelibly warps your mind -- that's an argument from the era of old-school microcomputer BASIC, the kind with line numbers, no function calls, and only global scope. That was a terrible language, far more impoverished than PHP ever was, yet I and everyone I know started with it, and we all grew out of it just fine.
The other point I'd make is that far too much attention is paid to the reasons why PHP sucks, when we should instead be trying to figure out why PHP even exists. Specifically, we should be trying to figure out why all the PHP programmers didn't learn Perl instead, and (more importantly) why Java didn't displace PHP despite its massive marketing advantages and its (supposedly) better design.