Live data from Hacker News

Ask HN: State of PHP at Facebook?

news.ycombinator.com

1–10 of 88 posts

Re: Ask HN: State of PHP at Facebook?

#3
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 Facebook is such a big company means that they can afford to have entire teams working on these proprietary languages, much in the same way Google had the ability to assign full-time engineers to maintaining their internal container infrastructure (Borg, the predecessor to Kubernetes). Because of this, I don't see why they would give up control of some of their stack to people outside their company, who may not share their values. This isn't exclusive to Facebook's PHP developers...they have their own libraries for C/C++, Swift, JavaScript, and much more. It's a big company, the developer tools are going to be a lot bigger than most other workplaces.

Again, this is pure speculation. But most of these big companies do the same or a similar thing. Both Apple and Google have invented their own languages, the difference is that Facebook doesn't have an app platform that requires you to use Hack/PHP, thus nobody is going to just pick it up for no reason unless it compels them in other ways (e.g. Go)

Re: Ask HN: State of PHP at Facebook?

#4
Over the last few years many contributions from Facebook have made it into PHP mainline 7 & 8, and we've seen respective performance gains.

Unsure how extensively they continue to use their PHP to C++ compiler internally.

Re: Ask HN: State of PHP at Facebook?

#5
post #4

Over the last few years many contributions from Facebook have made it into PHP mainline 7 & 8, and we've seen respective performance gains. Unsure how extensively they continue to use their PHP to C++ compiler internally.

The PHP to C++ compiler hasn't been used for something on the order of 10 years.

At least as of two years ago, pretty much entire web-facing portion of Facebook was written in Hack (which descends from PHP, but has what feels like every syntax feature you could stuff into an Algol-like language). Hack is run on HHVM, which is a bytecode VM that can JIT compile to machine code.

Re: Ask HN: State of PHP at Facebook?

#6
post #4

Over the last few years many contributions from Facebook have made it into PHP mainline 7 & 8, and we've seen respective performance gains. Unsure how extensively they continue to use their PHP to C++ compiler internally.

The php-to-c++ compiler was replaced many years ago with a JIT called HHVM.

Re: Ask HN: State of PHP at Facebook?

#7
HHVM is open source and seeing active development with weekly releases: https://hhvm.com/blog/

My understanding is they're waiting on the language stabilizing before making a push to open it up to the broader software engineering community.

They're still heavily invested in Hack and releasing research papers like https://engineering.fb.com/2021/03/03/developer-tools/hhvm-j....

Migrating to another language without an incremental adoption path likely isn't feasible for them

Re: Ask HN: State of PHP at Facebook?

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

Re: Ask HN: State of PHP at Facebook?

#9
I don't work at FB but can say with second hand experience that the company is "all in" on Hack/HHVM. The language has diverged far enough from PHP that moving back is simply not feasible.

As for "considerations of using some open source language", individual teams are mostly free to use whatever best fits their use case, similar to what you may expect at any company of that size. Pretty much every major language is in use at FB somewhere or the other. And HHVM is also open source.

Re: Ask HN: State of PHP at Facebook?

#10
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 FB's Hack + HHVM stack is much easier to work with and felt more productive than any other backend stack I've used. It's important to consider that a huge portion of Facebook's backend is one giant HHVM monorepo (called www). The consistency and uniformity has allowed FB to build lots of tooling and developer productivity on top of this one stack. For example, when you add feature flags, the tooling will automatically create a diff (PR) to remove the feature flag once it has been fully rolled out for a few weeks.

There are rough edges and weirdnesses, but HHVM is pretty actively being improved. Old mutable builtins are being (or have been) removed, the type system has gotten better, better error and warning messages all the time. FB is very responsive to data on developer productivity.

EDIT: Another anecdote, when I first joined I was working on both the Instagram python codebase and the Hack API codebase (some of Instagram's APIs are in Hack/HHVM). I constantly wondered why we didn't migrate the Hack code to python, and talked with various people about proposals and potential paths to do the migration for the APIs I worked on.

After a few months of working in both codebases, I completely flipped. After witnessing insane bugs and horrible architectural contortions designed to mitigate python performance issues, I wondered why we didn't just migrate the python codebase to Hack. Python (on cpython/cinder) is just not ready for large scale web services, and Hack is a much more productive environment than Java/C++/Rust for backend.

Typescript may be an even better option, but has some issues of its own.

Post reply on HN