Live data from Hacker News

Ask HN: State of PHP at Facebook?

news.ycombinator.com

11–20 of 88 posts

Re: Ask HN: State of PHP at Facebook?

#11
All of the “www” code (backend which serves all the web apps and APIs) is Hack. And a lot of that code is generated via internal frameworks like Ent which is a graph abstraction over database access.

There doesn’t seem to be any incentive to switch www away from Hack: it wouldn’t reduce the learning curve very much due to all those internal frameworks, and would remove the opportunity to optimize the language for the www codebase.

There are open source languages used in the internal backends though (services behind www). Most of it is C++.

Re: Ask HN: State of PHP at Facebook?

#12

I don't work there and don't know anybody who works there, but I do know that they have been using proprietary dialects of PHP for some time. React's JSX was influenced by XHP, and XHP was released in 2010 but apparently was in use for years before then. So from an outsider's perspective, it seems like Facebook has been using proprietary extensions or entirely proprietary languages for over a decade. The fact that Fa…

Not sure what you mean by “proprietary”. They use hack/hhvm which is open source. It’s not super popular but slack also uses it.

Re: Ask HN: State of PHP at Facebook?

#13

Though it is internally-built, Hack is already open source at https://github.com/facebook/hhvm/ . FB uses a pretty wide array of languages internally -- I don't know if they release statistics publicly, but you can filter/search their open-source projects by language at https://opensource.fb.com/projects/#filter .

I believe Hack is also used by a number of other companies, the most prominent being Slack [1]. FB probably uses almost every language in at least some context: Hack, C++, Python, Haskell, OCaml, Rust, JS, Obj-C, Swift, Java, Kotlin are all ones that I’ve heard referenced by friends who work there, though that’s likely nowhere near exhaustive.

[1] https://slack.engineering/hacklang-at-slack-a-better-php/

Re: Ask HN: State of PHP at Facebook?

#15

The answer to your first question is yes. Your second question is based on an incorrect premise. Hack is internally built, but it is also open source: https://github.com/facebook/hhvm I joined Facebook in 2019 and left this year. Prior to FB, I worked mostly with python, javascript, and C++. Even at FB, I worked mainly in python (instagram backend), but spent a lot of time in the Hack codebase. My experience was that…

Out of curiosity, am I right in thinking that Instagram is built atop Django?

Re: Ask HN: State of PHP at Facebook?

#16

The answer to your first question is yes. Your second question is based on an incorrect premise. Hack is internally built, but it is also open source: https://github.com/facebook/hhvm I joined Facebook in 2019 and left this year. Prior to FB, I worked mostly with python, javascript, and C++. Even at FB, I worked mainly in python (instagram backend), but spent a lot of time in the Hack codebase. My experience was that…

Out of curiosity, am I right in thinking that Instagram is built atop Django?

Yes. Instagram doesn't use the Django ORM though, and I believe they built their own async view implementation since it existed before Django went async.

Re: Ask HN: State of PHP at Facebook?

#17
post #11

All of the “www” code (backend which serves all the web apps and APIs) is Hack. And a lot of that code is generated via internal frameworks like Ent which is a graph abstraction over database access. There doesn’t seem to be any incentive to switch www away from Hack: it wouldn’t reduce the learning curve very much due to all those internal frameworks, and would remove the opportunity to optimize the language for the…

For anyone interested, it looks like there's an open-source version (close, at least) to Ent at https://github.com/ent/ent.

Re: Ask HN: State of PHP at Facebook?

#18

Earlier quoted context omitted.

Out of curiosity, am I right in thinking that Instagram is built atop Django?

Yes. Instagram doesn't use the Django ORM though, and I believe they built their own async view implementation since it existed before Django went async.

Gotcha! Thanks for sharing.

Re: Ask HN: State of PHP at Facebook?

#19

Though it is internally-built, Hack is already open source at https://github.com/facebook/hhvm/ . FB uses a pretty wide array of languages internally -- I don't know if they release statistics publicly, but you can filter/search their open-source projects by language at https://opensource.fb.com/projects/#filter .

I believe Hack is also used by a number of other companies, the most prominent being Slack [1]. FB probably uses almost every language in at least some context: Hack, C++, Python, Haskell, OCaml, Rust, JS, Obj-C, Swift, Java, Kotlin are all ones that I’ve heard referenced by friends who work there, though that’s likely nowhere near exhaustive. [1] https://slack.engineering/hacklang-at-slack-a-better-php/

And Erlang (mainly in WhatsApp)

Re: Ask HN: State of PHP at Facebook?

#20
Migrating to Hack from PHP was huge undertaking requiring years to conclude, and that almost kept the same syntax and semantics where possible.

What would the benefit of spending thousands of engineer years (read: billions of dollars) on a rewrite be? Especially when it would nearly certainly come with a huge performance regression compared to continuing to use HHVM which has come with years of optimization for working especially with Facebook's web codebase.

In addition to the need to rewrite a gargantuan codebase and loss of the optimized runtime, it would mean throwing away a huge amount of expertise, tooling, and basically all of the source control history context.

There really isn't much to gain.

That said, the fraction of Facebook's code that is Hack continues to shrink, thanks to the continued growth of backend services and the clients being written in Hack (before there was server-rendered XHP, but now it's predominantly React).

Post reply on HN