I hardly memorize stuff 'cause it's so easy to look up to the docs that it's not necessary. And here is what you get when you don't really know what you are looking for:
That is just nice documentation...
An example: http://clojuredocs.org/clojure_core/clojure.core/condp
The python documentation is an example of good documentation. And again, it's tied to the language's culture, where documentation has a really high priority.
I'd often like a stronger emphasis on the types of arguments and what gets returned.
I don't know enough about Java documentation.
'Array function parameters are ordered as "needle, haystack" whereas String functions are the opposite, so "haystack, needle".'
I think i could forgive php more for behaving (and being named & structured) wildly inconsistently were it not that the documentation tries to make up for this by pretending this is actually not the case.
So not only do you have this issue where the behavior of a function may be erratic but the documentation attempts to gloss over the issue by describing a function's most optimistic outcome rather than its actual behavior. Any behavioral caveats are left in the Notes section which in any other language documentation is reserved for "not thread safe" or "uses an easily guessable seed" or "execution blocks network access". Instead the Notes are used to explain "optional arguments not included change the behavior of this method to behave like this other one, but give no warning or otherwise visible indication of error."
The whole "php is defensive programming" statement holds because you can't trust the documentation to be upfront about inconsistent behavior.
There exist so many third party libraries because of the low barrier to entry. But as more people join the party, the party moves toward the average. The average third party library is an untested and undocumented mess. I do not think this is specific to PHP.
If the average PHP library is untested and undocumented, they're a couple steps ahead of the average Wordpress library.
(also, I might say, the Wordpress documentation is horrific. Hell, the entire structure of that project is horrific to work within. It's built to be easy for noobs ["the loop"], but makes it difficult to keep anything organized or nicely packaged)
People who don't have access to anything are delighted to have something. Therefore, PHP gets a foothold even though it's lower quality. This is the beginning of disruption.
The next part of disruption is improvement. And PHP is improving. At the same time, other programming systems are improving - C#, python, ruby, objective-C even Java has improved (generics etc). So it might seem that PHP will never catch up - which is probably true. But the crucial disruptive insight is that it mightn't need to: programmers might not all need all the extra improvements in mainstream languages, for all tasks. One piece of evidence is that PHP itself is already good enough for some tasks. For any advanced functionality, it's often possible to think of use-cases that wouldn't benefit from it. This means that it's possible for mainstream languages to "overshoot" what most programmers require for most tasks (to "overserve" them, like serving more food to someone who's already full). But, you might say, mainstream users are increasing in their ability to use advanced functionality as they learn more, so they can use the extra functionality (the patrons' stomachs are getting bigger). The interesting possibility is that the rate of improvement of mainstream languages may be faster than the rate of increase in the ability of programmers to use it (the servings getting bigger faster than the patron's stomachs are) - disruptive research has found that this is usually the case. It's because companies developing competitive products work really hard at improving them (to remain competitive); but consumers don't like to change their behaviour that fast.
The final stage of disruption is that programmers leave their mainstream language, and switch to PHP because although it's not as good, it's good enough for their task, and it has other benefits (not sure what they are for PHP, but for disruption it's usually: cheaper, more convenient, simpler - the latter two are true of PHP, but as it adds functionality, it would seem it must lose them. It will just copy mainstream languages).
But I can't imagine this happening, so therefore either disruption doesn't apply in this case (perhaps because a company isn't running PHP? Or because programmers themselves are unusually competitive and early-adopting, and even if some don't want to change their behaviour that quickly, there's another generation coming up real fast? Or as I said above, PHP can't retain its simplicity of being a template language while adding advanced features) - or my imagination is lacking.
It is clear why hackers get frustrated with the language. It is inconsistent and extremely tricky if you want to write secure code. The core developers are mostly concerned with endless discussions about adding buzzword compliant features that don't add any real value (Zend seems to be obsessed with being a poor man's Java so they can sell their ecosystem to "the enterprise"). Also, the community is pretty mediocre with an awful noise vs signal ratio.
So if hackers don't use PHP, who does? Clearly, PHP is very successful with people that want to tweak open source applications like Wordpress and aspiring developers or non-technical people that want something accessible that runs everywhere. Also, PHP developers tend to be cheap labor. There are plenty of them around, including in low cost outsourcing centers, that will charge you a lot less than more competent developers would. So it seems ideal to non-technical businesses looking for a cheap way to add some dynamic features to their website. Thankfully for PHP this group is a lot larger than the hacker community, so the language won't go away any time soon. Especially if you consider the fact that a lot of hackers learn their trade by writing little PHP scripts and customizing open source applications like Wordpress before moving on to something more interesting (I have to admit PHP was my first web scripting language too, back in 2000, but I quickly moved on to Python and now Clojure).
Is this disruption waiting to happen? I don't know. In fact, PHP seems to be trending downwards[0] as the generation that picked up the language before frameworks like Rails and Django were available is switching to the current languages du jour. If anything, it is not the language that is causing disruption, but applications like Wordpress that are easily accessible to non-technical people. However, hosted/SaaS alternatives like Posterous seem to be disrupting the whole idea of non-technical people installing Wordpress (at least I hope so[1]).
[0]: http://www.tiobe.com/index.php/content/paperinfo/tpci/index....
[1]: The main reason I might sound bitter about PHP is having to extinguish fires caused by idiots who write insecure PHP scripts or install open source scripts without bothering to periodically apply security fixes to counter the constant streams of exploits in said open source code while being responsible for some virtual hosting servers several years ago.
PHP developers tend to be cheap labor
I also hate the term "X developer". I never labeled myself as a Python-developer, or a Java-developer -- I'm just a developer that happened to learn whatever was necessary.Good developers are getting properly paid, regardless of the tools they put on their resume. Tiobe is also an extremely poor reference for language popularity, btw.
That said, last time I used PHP was 5 years ago simply because it isn't suited for the kind of work I do. Now I work with Python a lot, and with Ruby on the side -- because Python has mature libraries for visualization / parsing / data-mining, it has bindings for every meaningful C library under the sun, and because Python can be made to scale painlessly by means of non-blocking I/O or other tricks (as it's really mature in that regard).
I also like Ruby because its community is something to marvel at -- I never seen so much (focused) activity / cooperation and so much work done in so little time.
That's the problem with PHP -- technically, it's just an Apache plugin, done as a quick hack, reflecting in the available libraries / the community's culture, and there's no way it can escape it.
To make a bad joke -- you can pull PHP out of Apache, but you can't pull Apache out of PHP.
An interesting metric would be Google Trends[0], which shows a steady decline in search volume for "PHP" while the graph is a lot flatter for e.g. Python[1]. I don't think the number of Github projects for PHP is a great metric, because I think the Github community isn't representative of the typical PHP user, whereas it is virtually part of the DNA of e.g. Rubyists.
You're right to say that plenty of good hackers use PHP, but not because they think its a fun language to work with. You make a point out of PHP being the right tool for the job in certain scenarios, but in my experience it seldom is. Others have already made the point that cheap hosting isn't exclusive to PHP (consider e.g. cheap virtual/cloud hosting like AWS and Heroko). I can imagine using PHP for quick <10 line hacks when convenient[2] or to maintain legacy code and customize open source applications like Wordpress. Rewriting every line of code in existence using the popular language du jour simply isn't realistic. However, that doesn't make PHP the right tool for the job for fresh, non-trivial projects.
You're also right that good developers who happen to write PHP tend to get paid well. My point, however, is that there is a lot of cheap labor available that is able to write PHP (most of whom aren't good developers). This makes it a great fit for those customers that like to pay minimum wage for software development.
I understand your frustration about people bashing PHP, because in a way it is a silly example of elitism in this community to look down on PHP and its community. However, while I at least try to remain somewhat reasonable about it, my tone in regard to PHP is based on a long list of negative experiences that are presumably shared by a lot of people on HN.
[0]: http://www.google.com/trends?q=php
[1]: http://www.google.com/trends?q=python
[2]: In fact, I recently wrote a
<?php print_r($_POST); ?>
deployed on my Macbook's Apache server to quickly test some Clojure code making HTTP POST requests.The next step seems to be to disrupt Java enterprise webapps. Although that may not be exciting to a mainstream programmer, it would still be a disruption, and typical of how disruptions move upmarket, tier by tier.
fmw and bad_user have noted many important aspects of PHP, but I was really just thinking of its core idea: templates. PHP didn't originate them (eg bash does it echo hello $name; C has printf; etc), but it's taken it to the logical extreme of a program being a template, and it's the most popular embodiment (I think coldfusion and others did it too, but less successfully).
I think templates are a great idea, because they are simple and concrete. Abstraction and other meta features are powerful; but if the job doesn't need them, they only obscure what you are trying to do.
While surprisingly versatile (e.g. TXL does language translation with them), templates are limited as a general programming concept - and so PHP is probably similarly limited, perhaps to just the web (maybe it could expand to desktop applications, since they increasing use HTML for UIs - though deskapps are seemly being disrupted themselves by webapps). But it's hard to seriously entertain a fps in PHP; a compiler (though consider TXL...); a VM; a RDB; mathematica; pagerank implementation; numerical simulation; an OS.
Meanwhile, the template "technology" is accessible from other languages: python, ruby, java etc all have a broad choice of templating engines for webpage generation. So it is arguable that the technology of templating has been co-opted by the mainstream - although, PHP remains the simplest one. When the job is simplest enough, it seems PHP will win, simply because it can do the job, and it is accessible to more people.
BTW: the factors others have mentioned are also important (low cost hosting, labour etc) - though some of them can be traced to the simplicity and concreteness of templates (which made webapp creation possible for people with less skill).
I have to admit, I am a huge fan of template "technology". I think it is a brilliantly insightful and simplifying idea. They can also be seen as productions in a CFG.
That's completely silly. Every setup I have right now is Nginx and php-fpm, neither of which have any relation to Apache or, indeed, any relationship to any other aside from communication to php-fpm via FastCGI.
These generalizations are really funny, because they demonstrate a lot of the misconceptions about PHP and its community.
All generalizations are worth precisely nothing, including this one.
Personally, I'd like to see them start with example code, and then highlight a few of the more important functions, and THEN get into the gritty details.
As it is, I'm about as productive just dir()ing everything in the interactive shell, and then seeing what happens (sometimes falls down with passing options, though), and that's almost as good as the docs.
PHP though? Yuck. Although it's tons better than Joomla's documentation.
But the real reason I wanted to comment: stop dir()ing through modules! Install ipython and learn to use ? and ??. Life will be so much easier.
Edit: Checking it out now (actually already had it installed, thanks Ubuntu!), the ? and ?? things are just awesome.
Agreed, but the user comments include a huge collection of common problems and their (mostly) quick n dirty solutions. This is a part of what's making the language so accessible for newcomers. Of course it doesn't necessarily encourage best practices.
I noticed that too, and it floored me.
I should very much like to see that argument.
My impression of PHP documentation (after using it for three of the last five years) is that it's a endless pile of bullshit whose primary content is in user comments on the doc pages.
That's the core library. Third party libraries are typically wholly uncommented and undocumented.