Page 3 of 4

Re: New PHP from Facebook?

Posted: Wed Feb 03, 2010 6:31 am
by arjan.top
PCSpectra wrote: LOL
It's why I went out and bought a brand new cutting edge computer system i7 quad core with 12GB of DDR3?? Memory...If Eclipse is running like ahog on this machine I give up on Eclipse ever being a performant IDE. :P
total memory does not matter, you have to tell jvm how much memory heap can take

http://wiki.eclipse.org/FAQ_How_do_I_in ... Eclipse%3F

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Wed Feb 03, 2010 8:48 am
by JNettles
I find it refreshing when a private company decides to contribute back to the community. Picture for a moment that you're Facebook - you need a tool. You create a tool for yourself. Your tool works great, so great that you open source it so that others can use it too. I fail to see the downside or the "underhandedness" in all this.

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Wed Feb 03, 2010 5:09 pm
by alex.barylski
It was internal development for their private use. Do you always develop your internal stuff in the open? now they decided to make it open. why all the negativity?
Haha...I think he is simply bringing to light, the opinions of opposition, nothing more, nothing less. :)

If there was such a thing as a perfect solution or software system, there would never be controversy and how boring would life become?

Cheers,
Alex

Re: New PHP from Facebook?

Posted: Wed Feb 03, 2010 5:26 pm
by Christopher
Jenk wrote:Why didn't they do it in the open? They've basically said "This is how we think PHP should be, so here it is." and are now plugging their speed increase in a "HEY GUYS, COME USE OUR PHP INSTEAD!" kind of way, by the looks of it.
First, you are assuming that they knew exactly what they were going to implement when they started. Since they say the software is essentially a Beta and needs much more work, it sounds like they got it to a workable proof of concept (i.e., some part of Facebook can use it) and then released it. Honestly, I have less of a problem with this than the other Facebook libraries which are designed to bring more people and money to Facebook. That is the Microsoft way ... only release things that connect to your software and make you more money. I don't see how opensourcing HipHop makes Facebook a dime. It just potentially makes PHP more powerful. Imagine if the PHP Group figures out a way to integrate it into PHP so you can seamlessly run interpreted or compiled? Or it gets built into APC or something like that? The point of opensource is that people create a solution to their problem and release it, then others can take the software places the original developers weren't interested in or didn't think of.
Jenk wrote:What they should have done was make their intentions known, and then allow some form of input from the community. Not take from a community driven project, hide away, and then unleash a largely unknown and unfamiliar, yet "better" version onto the same community. At least for the beginning it will make anyone who uses this compiler dependent upon the FB devs for support/guidance/etc. Until someone finds a glaring hole, most probably.
Your attitude is that they have taken from rather than have added to a PHP? They don't say it is better. In fact the clearly state the limitations in what they implemented. Yet it is not good enough that they did a good thing by opensourcing it ... you add a "What they should have done" caveat.
Jenk wrote:That is the "dirty takeover". The spotlight has shifted from the PHP team to Facebook, who will no doubt be wearing the "I'm the PHP Daddy" T-shirt.
I think if you had written HipHop in private over the last year -- and opensourced it -- I would buy you that T-Shirt and called you "PHP Daddy". ;)

PS - the consensus in the blogs seems to be that HipHop is not very useful currently except for a very few types of sites, but that perhaps it could be expanded into a more generally useful system. It is PHP 5.2 not 5.3, so work needs to be done to upgrade it. It only supports the extension that Facebook uses, so more work is needed. And it does not support the full language (eval() is mentioned as one thing not supported) so yet again more work.

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Wed Feb 03, 2010 7:23 pm
by Weirdan
Sorry to interrupt your highly political discussion on what facebook should and shouldn't do, but has anyone seen the code yet? Their announce points to non-existing project on github.com and that's all... opensourcing the project means providing access to the code, or am I missing something?

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Wed Feb 03, 2010 7:44 pm
by josh
They said they'd release it "this evening" and an international day lasts 48hrs. They better hurry up though.
Each day of the week is extinguished, dies, at midnight on the East edge of the International Date Line.
http://home.hiwaay.net/~edbutton/48time.html

:drunk:

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Thu Feb 04, 2010 12:35 pm
by Benjamin
I'm not sure it would be possible to compile code inside eval prior to runtime. I don't see how it would be possible to compile what could be dynamic source code.

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Thu Feb 04, 2010 12:52 pm
by Eran
They specifically mention that eval is not a part of their compilation engine.

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Thu Feb 04, 2010 1:21 pm
by Christopher
Yes, some parts of the language (like eval() and create_function()) are not supported. Most people don't use eval() (and shouldn't ;)), so that should not be much of a problem. They mentioned somewhere that they determine the type of variables and convert them to a C++ type. That may effect some code and would require testing/auditing. Probably the fact that it is PHP 5.2 and the lack of support for some extensions would be the biggest hindrances for most developers. And, of course, the fact that the compiled pages are their own web server (bypassing Apache) so some front-end system is needed to send requests to the right place.

Here are some more links to blogs discussing HipHop:

http://terrychay.com/article/hiphop-for ... -php.shtml
http://php100.wordpress.com/2010/02/03/hiphop/
http://www.sitepoint.com/blogs/2010/02/ ... th-hiphop/

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Thu Feb 04, 2010 7:09 pm
by josh
I see it as more of use for glue applications. In the article they wrote they normally would just write C++ utilities and call into them from regular PHP. I bet they are only running Hip Hop for certain algorithms. They did mention it is running 90% of facebook's code (I don't know about you but way less than 10% of my code is actually controller code, where regular PHP would be needed). Once you decide to let your regular controllers run in regular PHP you'd just identify certain "services" in your app that could be sped up and compile just those? That's how I look at this tool. Any uses of non standard extensions would probably be encapsulated. I bet they keep certain services running regular PHP for exactly that reason. (facebook fetches 3rd party images, resizes images, etc.. it obviously is using _some_ sort of tool for that other than raw PHP).

For example facebook may call a command line utility for resizing images. Maybe in your app that utility could run regular PHP as opposed to PHP with hip hop.

Have they released any source code yet?

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Thu Feb 04, 2010 9:53 pm
by Christopher
Watch the video to get a feel for their specific problem and how HipHop solves it.
josh wrote:Have they released any source code yet?
They said "Soon". ;)

I think one important thing to look for is if they find a way to reduce the duplication of effort between PHP and HipHop. For example, they recoded many of the PHP extensions in C++ and insinuated that they fixed some of the tread-safe problems. Will they find a way to use the best code for both? The fact that PHP is C and HipHop is C++ seems to be a real problem.

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Fri Feb 05, 2010 1:04 pm
by volomike
Here's what I'd like to see. Let's say I have a class Foo, and about 80% of its class methods are the bottleneck of my enormous project. It would be great to be able to use HipHop to compile just this portion of the project into C++, and then somehow load it right back into PHP as an extension. That way, I can stick with PHP for much of the project, but convert my slower classes into C++ and load them as extensions, without needing to know C++.

Can anyone confirm if this is possible?

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Fri Feb 05, 2010 1:52 pm
by Christopher
volomike wrote:Can anyone confirm if this is possible?
I think you could use HipHop for specific pages, but not for specific classes within an app. Currently, HipHop compiles an executable that is its own webserver. So is runs separately from Apache. If you had a section of your website that was processor intensive the you could serve that section separately.

The other place where HipHop might be of interest is for utilities that are called on the command line. These may have been coded in another language for speed previously. Now with HipHop you can code everything in PHP and get CLI apps that are much faster. Another example might be if you had a separate server that only provided a web service or some data feed -- that might be a candidate for HipHop.

It will be interesting to see if application hosting, such as WordPress, will switch to HipHop. Since they only serve one app it might make sense to compile it.

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Sat Feb 06, 2010 3:28 am
by josh
"Narrow Interfaces" is a good design goal. Your classes should not have too many methods. If you follow this guideline its easy enough to stub out the old PHP class so that it calls the command line with it's inputs, and return's the command line utility's outputs. Coding in narrow interfaces is good for numerous reasons, this being one of them.

Re: PHP to C++ compiler from Facebook - HipHop

Posted: Sat Feb 06, 2010 2:43 pm
by volomike
First off, I have to admit, Facebook is now phenomenally faster. Not just a little faster -- phenomenally faster. I don't know what they did, whether this is in fact HipHop that has done this, but Facebook is now super fast. Go see for yourself. It actually makes Facebook nice to use rather than something I did every once in a blue moon. (I prefer Twitter.)

But anyway, it would be nice if a product existed that let me write PHP code, and then it would convert to C++ as a PHP-ready extension. However, if none will ever exist, then I guess I'll make do with just outsourcing C++ work to Asian offshoring, should I need it. Another opp. looks to be to make a SOAP/REST service on a dedicated server where the other end is made with HipHop.

Does anyone as old as me remember the days of Visual Basic as the prominent dev platform for business? Anyway, in that platform we used to have competitive companies who would make an extension we could load in that would do things faster than VB could normally handle. So, likewise, it would be great to see something like that for PHP. For instance, a vendor could say, "Use our C++ extension for PHP and we'll give you alternative functions that do many of your common tasks but twice as fast as the original PHP functions."