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 Byerswrites, “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!