Live data from Hacker News

Why so much hate for PHP?

news.ycombinator.com

1–10 of 74 posts

Why so much hate for PHP?

#1
PHP is the first dynamic scripting language I learned and have been using it ever since. Facebook uses it. Can someone explain what it's issues are and any suggest any comparable alternatives? Thanks!

Re: Why so much hate for PHP?

#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. Because it is so easy to use, many people are able to pick it up without any prior SE experience--these people tend to create poorly-designed, slow-running, and, perhaps worst of all, dangerous (vis a vis security) code.

The other major complaint that exists has to do with inconsistency/insanity in PHP's function signatures/naming/evolution. For example: mysql_escape_string and it's sister, mysql_real_escape_string. Although, anyone working with modern PHP probably will never touch these functions.

What is overlooked is that it has an extensive base of developers, it DOES scale (this is proven), and the language is improving (as well as the tooling (PHPUnit, XHProf, CI tools), frameworks, package management etc). And although Facebook does use it, it's important to note that, AFAIK, PHP only exists as a thin layer in between "display HTML" and "communicating with backend servers which are going to handle the majority of the work, save for presentation-layer type stuff."

There are a few alternatives to PHP, but they each have their warts too. Ruby is hilarious slow, for example.

Re: Why so much hate for PHP?

#3
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…

Thanks so much for your time! I was wondering whether you would suggest using PDO or mysqli for connecting to mysql via PHP?

Re: Why so much hate for PHP?

#4
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 PHP that a common person uses.They've made so many changes and their codebase is so huge. Facebook also uses the D programming language, HipHop, and probably more tools than I'll ever know. Wasn't chat at Facebook first written in Erlang?

Re: Why so much hate for PHP?

#5
post #3
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…

Thanks so much for your time! I was wondering whether you would suggest using PDO or mysqli for connecting to mysql via PHP?

From my personal experience I would suggest working with PDO. It is easy to implement, supports multiple drivers if needed and has named parameters in your prepared statements. The difference in terms of performance should be insignificant - although I think in some cases mysqli tends to execute faster.

Re: Why so much hate for PHP?

#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...

Re: Why so much hate for PHP?

#7

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.

Re: Why so much hate for PHP?

#9
PHP does what it does relatively well, but it's a quirky muddle of a language and its design is very tightly bound to a CGI-style model of web development.

Anything can be hacked around, of course, as Facebook has proven. But you could write Facebook in Bash or DOS Batch Language if you were willing to. But newer frameworks and languages that were designed with modern web development in mind are more to a lot of people's liking than PHP's style.

Really, the best way for you to answer your question is to dig in and learn how to develop a webapp using Ruby or Node.js or Python and the amazing frameworks that are built on those languages. Dig in for a couple of years and then on the other side you'll understand better. You may still prefer PHP, but even if you do, I'll bet the PHP code you write will be better for having learned how the "other guys" do things.

Re: Why so much hate for PHP?

#10
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 opinions on anything and no exciting concepts or language features. Now you can use great frameworks that implement great ideas in PHP, but because PHP has been around for a long time, much of the code out there and still in production is spaghetti code that is no fun to work with and the only option to change that is often a complete rewrite.

Post reply on HN