Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Facebook had hundreds of millions daily active users before writing a compiler.

In other words, Facebook felt compelled to write a compiler when they had hundreds of millions daily active users.



If you have hundreds of millions of daily active users then needing to write a compiler isn't the end of the world.


> If you have hundreds of millions of daily active users then needing to write a compiler isn't the end of the world.

It's not the end of the world because they have deep pockets and a problem domain where preserving the interface (I.e., keep everything still running on PHP) and optimizing the infrastructure that provides it is more cost effective and least disruptive than switching to a tech stack that is more performant.


Compiling PHP into machine code sounds pretty much impossible, are they using some subset of the language? Does the compiled code use a garbage collector? Or reference counting?


> are they using some subset of the language?

They're using a derived language called Hack.

> Does the compiled code use a garbage collector? Or reference counting?

Not sure but it's open source so I'm sure you can dig up the answers one way or another: https://github.com/facebook/hhvm


[flagged]


Please follow the site guidelines and edit swipes and putdowns out of your comments here. They're not what this site is for, and destroy what it is for.

https://news.ycombinator.com/newsguidelines.html


> This may be shocking to you, but _all_ code is effectively compiled to "machine code" eventually.

I'm not sure you understood the point. It means nothing to claim that deep down it's all opcodes or electrons flowing. What matters is being able to transform the code targeting the high level interface to the lowest level interface in a way that remains usable and regression-free. Sometimes compilers for widely popular languages introduce bugs and weird behavior too.


I don't think you understood the comments above, but I definitely don't understand your point...

Compilers introduce bugs, yes. Compilers are code, and code can have bugs and regressions.

But the comments above make no mention of bugs are regressions. They said compiling php into machine code is "impossible."

Going form high level interfaces to lower level is the easy part. It's what all interprets and compilers do already.

Having different intermediate forms is also a very common practice. There is nothing special about php here. Except for maybe it's underserved reputation of being an obtuse language.


Such a pedantic response, the archetypical HN comment, I can sense the pretentious smirk on your face while writing it, thanks. Words still mean something, we don't compile a dynamically typed, interpreted scripting language such as PHP for a reason and as it turns out Facebook didn't "compile PHP" either but a dialect of the language.

https://en.wikipedia.org/wiki/Hack_(programming_language)


Please don't respond to a bad comment by breaking the site guidelines yourself. That only makes things worse.

https://news.ycombinator.com/newsguidelines.html


Facebook transpiled it before using the HHVM.

https://en.wikipedia.org/wiki/HipHop_for_PHP




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: