ReadWriteWeb

Last week, we were chasing our tails in giddiness over HipHop, a newly open-sourced PHP runtime developed in house at Facebook.

Today, amid the rabid excitement over Google Buzz, Facebook quietly pumped some more code into the world. XHP is a new way to write PHP that "augments the syntax of the language to both make your front-end code easier to understand and help you avoid cross-site scripting attacks," according to Facebook engineer Marcel Laverdet. "XHP has enabled us to build better websites faster; our Lite site was written entirely with XHP."

Here's what a few developers, including PHP creator Rasmus Lerdorf, had to say about it.

Lerdorf describes XHP as "a new PHP extension today that supports inlining XML... It adds an extra parsing step which maps inlined XML element to PHP classes.

"The main interest, at least to me, is that because PHP now understands XML it is outputting, filtering can be done in a context-sensitive manner."

He also comments on XHP's significant performance issues and speculates how XHP would work specifically at Facebook.

"Running XHP on plain PHP is definitely out of the question. But, knowing that Facebook uses APC [alternative PHP cache] heavily and looking through the code (see the MINIT function in ext.cpp) we can see that it should play nicely with APC... So, when you combine XHP with HipHop PHP you can start to imagine that the performance penalty would be a lot less than 75% and it becomes a viable approach."

Meanwhile, over at Hacker News, Wikispaces creator James Byers writes, "For me, XHP is far more interesting than HipHop. And I say that as someone who administers a pile of single-application CPU-bound PHP servers. This completely and forever changes the templates-vs-just-PHP debate, and I'm glad - it's the kind of evolution PHP needs to continue to be taken seriously."

Tipjoy co-founder and current Facebook engineer Ivan Kirigin also chimes in with strong praise, saying, "XHP rocks so [expletive deleted] hard, it isn't even funny. It is just so much better than alternatives.

"IMHO, It is the only PHP tool I use at Facebook that is better than alternatives in other languages. I'm looking at you, Django templates! The notation perfectly represents the objects, with no cruft associated with object oriented programming. That is really rare."

Here's XHP on GitHub, and here's the documentation wiki. Take a look, and let us know what you think in the comments!



Comments

Subscribe to comments for this post OR Subscribe to comments for all ReadWriteWeb posts

  1. Documentation wiki link should be http://wiki.github.com/facebook/xhp/

    Posted by: Robin Millette | February 9, 2010 11:44 PM



  2. I must be missing something. The devs quoted in this article are so effusive about this, but to me it seems kinda ... ugly.

    What about separation of concerns? This seems like a fine solution if you've got html and php commingled in your code, but that's really bad practice. It seems like this would actually encourage more of that type of programming. Granted, the commingled html and php would be safer and easier to digest, but from my point of view, it shouldn't be done at all.

    The ability to define custom classes and associate them with custom XHP tags is cool, but it can be accomplished in other ways. Indeed, I have a hand-rolled framework which I use for all my projects, and it has this exact functionality built in. The difference is that my module tags live in the html, and all the logic for them lives in the php. There's a clean, bright line between the presentation layer and the application layer. XHR seems to be just the opposite of this.

     Posted by: Warren Benedetto Author Profile Page | February 9, 2010 11:50 PM



  3. Oh okay. Having looked at the wiki (link above is wrong) this is adding support for XML literals. It's also a feature of VB.NET.

    Posted by: commenter | February 10, 2010 1:30 AM



  4. They should've switched to pure .NET ages ago. ASP.NET 4.0 is light years ahead of this XHP/PHP jumbled mess.

    Posted by: Dev | February 10, 2010 8:52 AM



  5. XHP PHP blah blah blah... Facebook's "customers" don't care. unfortunately for the past year or so the Facebook programmers have been making VERY unpopular changes to their user interface. XHP apparently has been allowing the Facebook programmers to create these unpopular changes more quickly. Perhaps too quickly.

    Posted by: x y | February 13, 2010 5:22 AM



Leave a comment

Optional: Sign in with Connect Facebook   Sign in with Twitter Twitter   Sign in with OpenID OpenID  |  
RWW SPONSORS



FOLLOW @RWW ON TWITTER

ReadWriteWeb on Facebook
ReadWriteCloud - Sponsored by VMware and Intel





TEXT LINK ADS



RWW PARTNERS