Live data from Hacker News

Facebook Porting PHP To JVM

nerds-central.blogspot.com

21–30 of 68 posts

Re: Facebook Porting PHP To JVM

#21
post #16
post #9

I guess someone must really love PHP, though I'm slightly confused as to why. If you're going to make such a massive undertaking anyway (it's not just the new runtime, all existing code will have to be re-tested and re-debugged), why not sink the man-hours into putting it into a new language better suited to the task from the start?

Because there are millions of man hours of PHP from FB and it will cost less than one hundred thousand to port that work to the JVM. Yes the code will have to retested, but if you rewrite then you rewrite AND retest. Working code makes a great test suite, something you lose in a rewrite.

Yes, that sounds fine (and I'm aware of the Spolsky article posted in another comment.)

But the fact is that a system of that size simply must already be split up into discrete services or components. (If it's not, then that should be their first priority. But I can't imagine Facebook is running everything they do out of one process).

So they could port each service/component one at a time, rigorously testing and improving performance as they go. Then they'd not only get the benefit of a better runtime, but also a safer, faster language. In fact, if they're anything like most companies I know, they're always in the process of rewriting one service or another to improve performance or features, whether in a new language or not. All they'd need to do would be to switch to the new language whenever they were refactoring existing code anyway.

Of course I can't make the decision for them, and they are rightly hesitant to do an entire rewrite. But it seems like they're going to fairly extreme lengths to stay with PHP.

Re: Facebook Porting PHP To JVM

#22
post #8

This is all great but... why?

My reaction exactly. I have great respect for the JVM, but PHP could simply be replaced by JavaScript for example. It seems easier to me to port PHP to Rhino or node.js than to bring PHP to the JVM. Especially considering CoffeeScript, PHP just can't keep up.

[deleted]

Re: Facebook Porting PHP To JVM

#24

Why do these companies like the JVM so much? Twitter, and now Facebook. Does it have that great of performance?

It's one of the most scalable, robust, secure, proven mainstream web platforms available. And at almost any server-side scale it performs better than PHP, Ruby, and Python.

As far as mainstream languages go, only C and C++ have a performance and scalability edge, but C++ at least comes with more complexity. JVM seems to hit the performance:complexity sweet spot.

Re: Facebook Porting PHP To JVM

#25

Why do these companies like the JVM so much? Twitter, and now Facebook. Does it have that great of performance?

Yes. http://shootout.alioth.debian.org/u64q/which-programming-lan... Note that Java compares very favorably with C. (Of course, the real thing to take away from that chart is: why don't all the JVM users switch to Haskell? It's more concise, safer, and has a better community.)

Many JVM developers for whom programming is craft rather than a day job are definitely looking at both Scala and Haskell. Lots of excellent stuff going on with both, as you point out - concise, safer.

Re: Facebook Porting PHP To JVM

#26

At this point I have to just laugh. They literally already paid for the development of a prototype for a faster PHP, and decided not to pursue that route: http://morepypy.blogspot.com/2012/07/hello-everyone.html . I have to assume they have some insane internal politics, because there's no sane technical reason to develop HipHop (static subset-of-php to C++ compiler), then start the HipHop VM, then fund the PHP on Py…

I'm not sure why you'd laugh. Facebook is investigating a bunch of different options which may or may not yield fruit.

Re: Facebook Porting PHP To JVM

#27

At this point I have to just laugh. They literally already paid for the development of a prototype for a faster PHP, and decided not to pursue that route: http://morepypy.blogspot.com/2012/07/hello-everyone.html . I have to assume they have some insane internal politics, because there's no sane technical reason to develop HipHop (static subset-of-php to C++ compiler), then start the HipHop VM, then fund the PHP on Py…

I don't understand what's wrong with exploring your options. Why would you assume that the reasoning has something to do with politics rather than trying to find a better technical solution to their problem?

Re: Facebook Porting PHP To JVM

#28
Lets ask this one question. Why rewrite python in python? Why rewrite Ruby with java? They may have realized that php is a good solution for their existing framework, the framework has an enormous unit test harness, which would take a very long time to translate, and they have nothing against the language at the company. If they are planning a jvm for php, it is probably because they have developers there who have experienced the speed increase of other jvm langauges like jruby, jthon, etc. I'd wager money that they will probably use one of the current open source translations and build on top of that, maybe gut it like crazy and use it as a foundation. A full rewrite if php in jvm would probably be extremely difficult timewise.

Re: Facebook Porting PHP To JVM

#29
post #3

It's the summer of 2018. Facebook shares drop to 17 cents as their PHP to ASM compiler project nears completion.

No reason it should take that long. The article suggest 6 person years - which could mean 6 people for 1 year.

AFAIK they have about 20 people on this....unless I've mis-construed a friend of mine's elliptical comments. In other news - when is Google's VM that all the people they hired from the CLR team going to be released?

Re: Facebook Porting PHP To JVM

#30
post #13
post #9

I guess someone must really love PHP, though I'm slightly confused as to why. If you're going to make such a massive undertaking anyway (it's not just the new runtime, all existing code will have to be re-tested and re-debugged), why not sink the man-hours into putting it into a new language better suited to the task from the start?

This is where someone posts the Joel on Software link about Netscape (I'm on my iPhone else I would). Also, developing a new implementation of PHP allows site development to continue in the meantime.

I agree with Joel about a lot of things but I don't think history lines up with his famous comments about the Netscape rewrite. Netscape was well on the decline before they began the rewrite and its problems were more lack of commercial focus (eg. their failed attempts at "groupware") rather than the technical decision to rewrite Navigator. And without that rewrite it is unlikely that Firefox would have ever existed and without Firefox, Netscape (now Mozilla) would have slid into the abyss of irrelevance a long time ago.

So while there are certainly good arguments to be made that rewrites can bite you in the ass and should often (though not always, IMO) be avoided, I wish people would stop referencing Joel's circa-2000 post unless they are willing to rewrite it in hindsight and still attempt to make his argument.

Post reply on HN