Home Facebook Debuts XHP: More PHP Enhancement

Facebook Debuts XHP: More PHP Enhancement

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!

About ReadWrite’s Editorial Process

The ReadWrite Editorial policy involves closely monitoring the tech industry for major developments, new product launches, AI breakthroughs, video game releases and other newsworthy events. Editors assign relevant stories to staff writers or freelance contributors with expertise in each particular topic area. Before publication, articles go through a rigorous round of editing for accuracy, clarity, and to ensure adherence to ReadWrite's style guidelines.

Get the biggest tech headlines of the day delivered to your inbox

    By signing up, you agree to our Terms and Privacy Policy. Unsubscribe anytime.

    Tech News

    Explore the latest in tech with our Tech News. We cut through the noise for concise, relevant updates, keeping you informed about the rapidly evolving tech landscape with curated content that separates signal from noise.

    In-Depth Tech Stories

    Explore tech impact in In-Depth Stories. Narrative data journalism offers comprehensive analyses, revealing stories behind data. Understand industry trends for a deeper perspective on tech's intricate relationships with society.

    Expert Reviews

    Empower decisions with Expert Reviews, merging industry expertise and insightful analysis. Delve into tech intricacies, get the best deals, and stay ahead with our trustworthy guide to navigating the ever-changing tech market.