5 ms·
Facebook Porting PHP To JVM
- stephen_mcd 14y agoIt's the summer of 2018. Facebook shares drop to 17 cents as their PHP to ASM compiler project nears completion.
- code-dog 14y agoNo reason it should take that long. The article suggest 6 person years - which could mean 6 people for 1 year.
- ams6110 14y agoJust like nine women can have a baby in one month?
- jmadsen 14y agoexactly. One makes the head, two make each arm, etc... of course, you can't do that with computer software
- code-dog 14y agoIn this case a team could work across the project. One on the parser/lexer one on AST translation, one of code generation, Two on the runtime and 1 on build/ci. I think that makes 6.
- kyriakos 14y agotry reading The Mythical Man Month http://en.wikipedia.org/wiki/The_Mythical_Man-Month http://en.wikipedia.org/wiki/The_Mythical_Man-Month unfortunately my boss thinks as you do..
- josegonzalez 14y agoYou either never read the book or are interpreting it wrong. The premise is that as you add more people to an EXISTING project, the amount of time it will take to complete will increase. However, if all of those people are involved from the beginning, then you are not subject to the same phenomenon - within reason of course. So while it might not be "6" developers working on it for a year, it could potentially be 9 very devoted developers cranking this out with good results towards the end of the year.
- Danieru 14y agoBrookes also talks about another issue, that in a team of 6 there are (6 choose 2) edges in the communication graph. I think this is what kyriakos was referring to.
- sandfox 14y agoErrmm, if you actually read the book properly you'll realise that the baby/mothers analogy applies to synchronous sets of work and workloads that cannot be broken down into parallel running tasks. Once architected to a suitable degree I'd imagine that there are at least a few streams of work that could be carried out concurrently.
- code-dog 14y agoYes! Someone gets it!
- josephcooney 14y agoAFAIK 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?
- abolibibelot 14y agoPhalanger ( http://phalanger.codeplex.com/ http://phalanger.codeplex.com/ ) is an implementation of PHP running on the CLR with a fairly good compatibility story and sometimes much better performance. Phalanger worked well even without using the DLR (dynamic language runtime) so a JVM implementation shouldn't be a massive undertaking (except for the lexer and parser parts...)
- nickmain 14y agoThere are already at least 2 implementations of PHP on the JVM: http://quercus.caucho.com/ http://quercus.caucho.com/ http://www.projectzero.org/php/ http://www.projectzero.org/php/
- boyter 14y agoHas anyone around here actually used either of the above and care to comment? I would be curious to know how compatible they actually are with the average chunk of PHP code, and if not how hard it is to work out whats wrong and get it running.
- sanxiyn 14y agoQuercus is known to run WordPress, MediaWiki, and Drupal without patches.
- dreamdu5t 14y agoThis is all great but... why?
- jeremiep 14y agoMy 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 14y ago[deleted]
- mh- 14y agowas this post just written with a JavaScript-buzzword generator?
- erichocean 14y agoYes.js
- jacques_chester 14y agoBecause: 1. the JVM is an open, stable, mature, fast platform for server applications. 2. Facebook are not moving off PHP any time soon. 3. For stuff outside its written-in-C standard lib, PHP is quite slow. PHP's garbage collection, JITting etc is nowhere near as advanced as the JVM's. 4. Since porting dynamic languages to the JVM is a well-worn pathway, why not try porting PHP and see how it performs? If Facebook can reduce their CPU and RAM requirements by just 10%, it pays for itself many times over vs the stock PHP runtime. And based on what I've seen with JRuby (going from 50Mb MRI runtimes down to 2.5Mb runtimes that are 3-10x faster) that's entirely reasonable.
- dataminer 14y agoWhat kind of computations were you doing on MRI which resulted in such performance boost by switching to JRuby? I have tried Rails under JRuby many times, the performance is the same as 1.9.3 and memory consumption usually higher.
- lukev 14y agoI 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?
- kyriakos 14y agoi understand your thinking but in your opinion what language is suited for this particular task? personally i doubt there's a platform that's suitable for this scale, one has to create his own, and thats what facebook's doing.
- Legion 14y agoThis 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.
- georgemcbay 14y agoI 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.
- fleitz 14y agoBecause 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.
- prezjordan 14y agoWhy do these companies like the JVM so much? Twitter, and now Facebook. Does it have that great of performance?
- jrockway 14y agoYes. http://shootout.alioth.debian.org/u64q/which-programming-languages-are-fastest.php 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.)
- SkyMarshal 14y agoMany 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.
- tedunangst 14y agoThe JVM can be bootstrapped relatively easily compared to Haskell. It's just C++ code. If I gave you a computer with a C and C++ compilers, and the ghc source, what would you do?
- jrockway 14y ago
- hdoan741 14y agoIs there any official reference to backup the claim? I doubt Facebook would spend effort on doing this since they have already port PHP to C++ with Hiphop.
- deleted 14y ago[deleted]
- kingkilr 14y agoAt 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 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 PyPy prototype, and now apparently move to a PHP on the JVM.
- apgwoz 14y agoI'm not sure why you'd laugh. Facebook is investigating a bunch of different options which may or may not yield fruit.
- theshadow 14y agoI 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?
- kingkilr 14y agoThey're not exploring a research space, they're exploring a space where the options are incredibly well known, and they're jumping from solution to solution, even after they appear to find a success.
- lparry 14y agoyeah, god forbid they feel that their initial success could be improved upon; They should put down their tools as soon as they get their first version that works /sarcasm
- sanxiyn 14y agoIf they have enough resources, they can afford to try all options in parallel. Wasteful, but although it may seem strange, it isn't like programming language implementation engineering is expensive compared to data centers.
- krob 14y agoLets 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.
- jacques_chester 14y agoIt should be noted that there is no direct evidence that this is happening, other than: "The presence of Facebook engineers at the Java Language Summit in San-Francisco" Is the author aware that Facebook is a multi-language shop? It's why they have Thrift, after all.
- sanxiyn 14y agoWhy do you quote selectively? The next part is: "along with their interest in implementing PHP using invokedynamic on the JVM". Also, JVM Language Summit, not Java Language Summit. (OP got it wrong too.) More on http://wiki.jvmlangsummit.com/Main_Page http://wiki.jvmlangsummit.com/Main_Page
- jacques_chester 14y agoI quoted selectively because the author gave no source for "their interest in implementing PHP". None. No links. No names. No quotes. No press releases. No blogs. No email archive. Nothing. Not a skerrick. Not a sausage. Not a sniff.
- sanxiyn 14y agoMost likely this was a hallway conversation at JVM Language Summit (which it seems that OP attended). I don't see any particular reason to doubt his claim.
- jacques_chester 14y agoI do, because he seems to have a bee in his bonnet about the evils of interpreters. I'm also a bit wary of leaping from one-guy-musing-in-a-hallway to FACEBOOK PORTING PHP TO JAVA.
- maratd 14y ago> Facebook are looking to move PHP on. Did Google Translate write the article?
- scottmac 14y agoI work at Facebook and have been involved in the Hiphop for PHP project for the past few years. We have our own VM written and it isn't based on the JVM. Bytecode: https://github.com/facebook/hiphop-php/blob/master/doc/bytecode.specification https://github.com/facebook/hiphop-php/blob/master/doc/bytec... Code: https://github.com/facebook/hiphop-php/tree/master/src/runtime/vm https://github.com/facebook/hiphop-php/tree/master/src/runti...