Live data from Hacker News

Why so much hate for PHP?

news.ycombinator.com

11–20 of 74 posts

Re: Why so much hate for PHP?

#11
post #2

A quick dive into any PHP-related topic on HN should yield significant answers. Part of the hatred comes from the fact that the way people know PHP is from 2005, when it was essentially one really long procedural program. It's not so much that people ignore the recent upgrade in tooling/modern language constructs so much as people aren't familiar that they exist. However, these is still a lot of vitrol for PHP. Becau…

Care to point folks to an example of a more modern PHP script that shows off improvements since the state of things in 2005?

Re: Why so much hate for PHP?

#12

Essentially because it wasn't a well-thought out language, but a hack, it became used widely, but that lack of thoughtfulness shows on larger projects quite a bit. It is a hack that need to become more formalized with time, but it hasn't quite done that. Whenever I still see "needle" and "haystack" in documentation I think "Wait what is this? Oh right..." >Facebook uses it Not really, I mean Facebook doesn't use the…

Furthermore, the only reason Facebook stuck with php and made massive changes to make it somewhat usable is because of its huge legacy codebase. They would have much rather be working in a different language these days.

[deleted]

Re: Why so much hate for PHP?

#13
Several reasons, I think.

For one, it's no secret that PHP was an amateur undertaking that inadvertently ended up powering >80% of the web.

It started off as a bunch of helper functions that were meant for Rasmus Lerdorf's personal use. He has frequently acknowledged that he was never particularly skilled and that PHP was never meant to be used on such a large scale. Among the countless WTF moments you would expect from a personal project, PHP once used strlen() as a hashing function. [1]

Thus, PHP ended up having a very inconsistent design and an awful typing system. It ended up becoming quite baroque, it has never had a formal specification and it has no coherent idea of what it wants to be. This is exemplified by PHP's relatively recent appropriation of Java idioms in an attempt to bring vague Nygaard OOP.

Third, it's fundamentally a templating language and it doesn't encourage any cohesive design patterns or practice. Most PHP sites don't even use frameworks, but rather go with the Mozart (or rather, spaghetti) style of copy-paste programming. There is no clear separation of concerns.

Fourth, the PHP community has always been dominated by amateurs. I can't really direct you to any objective statistics, but in general PHP has a disproportionately high amount of leechers and newbies, largely because it has been so deeply ingrained into the public consciousness as the de facto language of the web, without knowing of the better designed general-purpose alternatives.

Fifth, some concrete examples of PHP's horrific internals. [2] [3] [4]

Alternatives? Anything, really. Python, Ruby, Perl, Common Lisp, Haskell... whatever floats your boat. A minimal web framework is a trivial application to write. That's why there's so fucking many of the goddamned things.

[1] http://news.php.net/php.internals/70691

[2] http://www.phpwtf.org/

[3] http://www.phpsadness.com/

[4] http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de... (the famous article)

Re: Why so much hate for PHP?

#14
post #11
post #2

A quick dive into any PHP-related topic on HN should yield significant answers. Part of the hatred comes from the fact that the way people know PHP is from 2005, when it was essentially one really long procedural program. It's not so much that people ignore the recent upgrade in tooling/modern language constructs so much as people aren't familiar that they exist. However, these is still a lot of vitrol for PHP. Becau…

Care to point folks to an example of a more modern PHP script that shows off improvements since the state of things in 2005?

http://laravel.com/

Re: Why so much hate for PHP?

#15
TL;DR: Because we used it.

Like many people, many years ago I learned php. It was easy to deploy, and make simple dynamic websites. Many hosting services provided support for it. I was quite happy to use it for these things.

Then in 2008 I interned at Facebook. At the time, there had not yet been any attempts to improve the language by Facebook itself. Using php in an actual codebase - real world software - made me realize just how terrible it was. I vowed to never use it again. I even presented some of the worst aspects of php in my intern presentation to the executive team. Mark was quite intrigued. At the time there were talks of how to deal with many of the problems, but nothing had been figured out by time I left.

Its deficiencies are too numerous to simply list here, so I'll give you a high level summary (which many have also said similar things). Php is a giant hacked language originally not designed for real software and then features added on. It's syntax is the worst of any used language; it's language features are severely lacking; its implementations are contradictory, confusing, and destructive. In short, it is not easy to read, it is easy to shoot yourself in the foot, it is not able to scale both in complexity and performance; and its libraries are a mess.

Re: Why so much hate for PHP?

#16
post #6
post #2

A quick dive into any PHP-related topic on HN should yield significant answers. Part of the hatred comes from the fact that the way people know PHP is from 2005, when it was essentially one really long procedural program. It's not so much that people ignore the recent upgrade in tooling/modern language constructs so much as people aren't familiar that they exist. However, these is still a lot of vitrol for PHP. Becau…

> Ruby is hilarious slow, for example. [citation needed]. Also, relevant Stack Overflow debate is available. [1] TL;DR: yes, of course Ruby is slower than, say, C, but today's bottleneck isn't hardware, it's developer productivity. (Developer time costs way more than hardware.) [1] https://stackoverflow.com/questions/2529852/why-do-people-sa...

Depends on the task. Most of my programming is on the sysadmin side. So automation and log processing are two of the biggest things I deal with. I love Ruby to death. I'd program in it all the time if I could. And it works really well for automation. But for processing massive amounts of data? Not so much.

I even did some tests a year or so ago when I was writing a script to merge together data from multiple log files and a couple of databases, including data transformations, merging/collation and sorting of, oh 100GB or so of raw log data a day.

My first tests with Ruby were running pretty slow, so I decided to write the script out as I'd planned in both Ruby and Perl and compare the results on subsets of the data.

I used none of Ruby's OO features, I just did straight simple data structures, hashes and arrays, etc. Ruby has far better infrastructure for dealing with these things built in, and so I wrote the Ruby script in a couple of hours. The Perl script took me a couple of days--admittedly my Perl is rusty, but I wasn't doing anything complicated. But the language just doesn't have as much stuff built in.

Anyway, at the end I had two scripts with exactly the same logic, and I'd even had to implement some things (like Ruby's Array#uniq, which I assume (but don't know) is written in C) from scratch in Perl. So yeah I wasted 16 hours on the Perl script, but you could follow them line by line and they were identical.

Run them one after the other to compare, and the Perl script is literally 100 times faster and uses a tenth of the RAM. I told my Python-loving friends about this and they guffawed at the silly Ruby guy, but it was depressing.

So yeah, Ruby is slow at runtime compared to other languages. Usually that doesn't matter, but sometimes it matters a lot.

Re: Why so much hate for PHP?

#18
Homo sapiens is evolved to ingest, internalize and re-propagate ideas. That was our survival advantage on the savannah hundreds of thousands of years ago; that was how we out-competed other species using our big brains to carry out complex, improvised plans.

But that evolved trait now can be seen in how we conform to the ideologies and groupthinks of political tribes and groups. Homo sapiens seeks out tribes and discerns their ideologies and internalizes them and then re-propagates.

We are a species of ant-like primates, and instead of spraying chemicals or from musk scent glands, we spray ideology, the ideology of our adopted tribes.

The elite use this evolved trait of propaganda-ingesting in order to manipulate us.

Anti-php is one of the central tenets of HN ideology. To be a full member of the tribe you must internalize and re-propagate this ideology.

Re: Why so much hate for PHP?

#19

There are a lot of reasons already discussed, this one is especially famous: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de... PHP is not a exceptionally bad platform from a technical perspective, it usually gets the job done, is reliable, easy to operate and performant. But i guess the real reason why so many developers - including me - hate PHP is that plain PHP is pretty boring. It doesn't have opini…

The CodingHorror blog have been quite vocal on the tour too : http://www.codinghorror.com/blog/2012/06/the-php-singularity...

Re: Why so much hate for PHP?

#20
post #17

Don't forget the epic php bashing post - http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...

Does no one who posts this in PHP threads even bother to check if it's been posted like three or four times already?
Post reply on HN