Hacker News new | past | comments | ask | show | jobs | submit login

You're right, that with proper vigilance, PHP is a very productive tool. No one is criticizing you for correctly perceiving the business value there.

I used PHP professionally for almost four years, at places like Flickr and Wikipedia. It definitely packs a lot of power - it's fast at what it does, has every library you probably want built in already or available with a little config. And, out of the box, it matches the request-response loop in web programming much more simply than most languages do.

Unfortunately, even with these good qualities, PHP just has a lot of misdesign in it. It's not elitism to point this out.

Just look carefully at your own practices and you'll see that a lot of what you do is defending yourself against bad practices that PHP is subtly (or unsubtly) trying to impose on you. It's telling that PHP is a template language, but in order to achieve useful results, you really have to use another template language on top of it, like Smarty or Symfony or whatever the cool thing is these days. And even so, to this day, Rasmus thinks that such frameworks are misguided, and that real programmers should just use the built-in templating of PHP (i.e. embedding blocks of code in HTML) and nothing else. How anyone can work for over 15 years on the web and still think this is beyond me.

For most of its existence PHP's only guiding principle was expediency and one-off hacks. That's how you get a 'feature' where you can inject evil values into the script just by parsing CGI arguments. Or, the ability to just ignore errors by prepending an at sign. This is almost NEVER a good idea, and introducing a feature like that means that in any large project you never can be sure what's really going on, without actually looking for all instances of this all the time.

And what kind of language makes a keyword like 'array()'? PHP is a supposedly dynamic language, but it almost goes out of its way to make manipulating complex data structures difficult. Compare to Perl and Python, which make deep data structures easy and also easy to transform and manipulate. Instead PHP has insecure, hacky misfeatures like variable variable names. This is something that beginner programmers often want, until they learn about actual data structures.

I have a feeling you may not be all that familiar with other languages, or for that matter, PHP. There are experts who choose PHP, but they acknowledge these difficulties.




A thoughtful critique of PHP. Good. Here's the thing, for those of us who use PHP on a daily basis, we are all well aware of all of this.

I have almost 100K lines of PHP code and only one of them spits out HTML. That would be the line that fetches the initial HTML template which is static and spits it out. After that, everything is XHR and web sockets. The DOM is manipulated directly by client-side JavaScript.

Why use PHP? Libraries to use any database I can imagine. Existing libraries for any API I can imagine. Language maturity. Familiarity and similarity to C.

I know the mines and I stay away. On top of that, those maintaining the language are aware of them too and they are slowly deprecating them.

> PHP is a supposedly dynamic language, but it almost goes out of its way to make manipulating complex data structures difficult.

Why would you use complex data structures in PHP? If you did, why try to manipulate them?

PHP is a language that is made for the web. On the web, anything that is computation heavy, like data manipulation, should be done on the client's side. Not that JavaScript is much better at data structures and manipulation, but at least it probably has a monster of a CPU and a boatload of RAM to smooth things over.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: