Hacker News new | ask | show | jobs
by dkhenry 4641 days ago
At this point we almost need to stop saying facebook programs in PHP. I know this was defending PHP, but look at what is happening. Facebook ( big engineering firm, lots of developers and resources ) could not get php to work for them short of rewriting the core (HPHP ) and then adding on features to the language that most other languages have determined are useful enough to be baked into the language.

Here is my TL;DR of this article. PHP is bad we all know this and accept it. Facebook has made it better by keeping most of the syntax and chucking everything else out the window. Run your stuff on HipHop ( unless you need extensions in which case your OOL )

7 comments

Video of the talk is not up yet, and it's a little cryptic with just the slides. But one of the points I was trying to make is that PHP actually makes you more likely to be successful than a lot of its competition. The lolsy stuff on "The Case Against PHP" slides is all you ever hear because ... well, because they fit on slides. They're immediately, obviously weird. But these problems are shallow. There are deeper properties of the language and its interaction with the environment that overcome those problems, and then some.

Also, it's a little obscure for languages like PHP where we're unused to making architecture/implementation distinctions, but if HHVM is good then PHP is good. It runs the same core language as php.net. To the extent we don't, it's likely to be a bug these days. I think HHVM is a better implementation of that language than php.net, but I am biased, and that isn't the point of the talk. We're also chipping away at running other popular programs, extensions and all: http://www.hhvm.com/blog/?p=875

Edit: transposed sentence

could not get php to work for them short of rewriting the core (HPHP )

I've heard this argument before, but it's important to realize that Facebook was able to use standard PHP up until the point when they had roughly 500 million users. Unless your site has a half billion users you can't compare your use case to Facebook's.

They're making three sorts of changes: 1) removing/restricting the footguns in the language 2) adding interesting features taken from other languages (typing, traits, etc). 3) creating a new VM with better performance.

As far as I can tell, only 3 is obviously something that only affects whether you can use the language once you have a certain number of users. The first two are really about changing the language.

Maybe I should have expressed myself more clearly: The comment I replied to seemed to indicate that PHP must be bad since Facebook had a need to change it. My point was that, given the fact that Facebook has way more users than other sites and mostly serves non-cacheable pages, their needs are different than the needs of 99.9999% of other sites in the world, so the fact that they were forced to change PHP doesn't say anything about PHP's quality as a language.
The # of users really says nothing about how expressive the language you're programming in is.

And if we're talking about consumer products like facebook, it doesn't even say anything about how fast your programming language is since performance is dominated by database access time.

At best, we can try and claim that Facebook found PHP to be insufficiently expressive/safe/suited for them once they had X number engineers making Y number of changes per day.

Maybe they really could "move fast and break stuff" with 200+ engineers trying to commit to a vanilla PHP codebase.

Speaking as someone who works on a 2 million user enterprise app with standard PHP, i would have to counter that: 1) the footguns are easy to sidestep once you know them and are gradually getting removed, 2) standard php has traits and strict typing, but the typing is not for primitive types (which is what Hack adds) and 3) in nearly a decade i have had a single feature where i could have really used a faster php, whereas in practice my performance issues all come from the Oracle bottleneck because php is so easy to parallellize. Facebook could run on standard php, it would just require more hardware, and since releasing hhvm php has gotten a lot faster without breaking backwards compatibility.
I'm curious on how many servers does it run :)
PHP(.net) doesnt have strict typing ,but type hinting, which is not the same.
It does have strict typing with objects, but not literals.

If I make a function meow(MyClass $meow) { } it will throw errors if anything other than a MyClass is given to it, including NULL.

You are wrong , it has type hinting , not strict type checking. You can alias types, there is no hard types in PHP except for arrays. Your function signature check the name of the object in the namespace , not it's type.
they most probably would have made similar changes if they had used ruby or python. They have very specific problems brought on by massive scale which will expose the flaws in any scripting language.
Yes and no.

As a matter of fact Facebook would probably have run into the same problems if they had used Ruby or Python. These problems are problems of massive scale most of us will never face. Twitter had problems running on Ruby/Rails and i bet theres a case to be made for Python too. All this says is that at the scale level of facebook you will encounter the limits of dynamic typing scripting languages, but its not a problem with PHP per se and also not a problem that should hold anyone back from choosing php/ruby/python because its premature optimization.

Both Youtube and Disqus (just to mention bigger names) started delegating heavier tasks to Go, instead of Python. So yes, this case can be made for most high level languages.

    >At this point we almost need to stop saying facebook programs in PHP
This isn't the first language-incompatible change they've introduced - see XHP, which used to exist as a Zend extension(?) and is now rolled into hiphop
Judging by that TL;DR people would think that there's an article with pages upon pages of what Facebook decided to eliminate from PHP, and not to make it easier but to make it possible to mantain their codebase. No such thing can be found in the provided PDF.
They've added static typing, return types for functions, and a few other things. I believe the premise of the talk is that it's still possible to use everything else available in PHP (traits, generators, namespaces, etc.)
Tell Facebook that. They are the ones talking about it still.

Also, your TL;DR is a flat out lie.

Another hard example: A start up wants the cutting edge tech so they use hphp. The company ran out of money before it finish complied.