Thursday, February 11, 2010

Thoughts on XHP

I am really happy to hear that Facebook has now officially released XHP, an E4X type of implementation for PHP. My initial thoughts are that PHP was built as a templating engine, and so this innovative approach to templating will only help solidify PHP as the best templating engine for the web. But after reading Rasmus' take on the performance hit that you might sustain from using XHP, I'm not so sure.

In fairness I have not yet actually tried this extension out yet (it is an extension, not like HipHop). The amount of data that you would run through the XHP tags would presumably by fairly small amount of data. I am wondering if it is possible to say use the short tags to write something like:

<?=<b style={$style}>{$container}</b>?>

It might go against the whole "simpler to read" idea, but if ease of use is the goal, then I think that it would most certainly accomplish that. On the upside, this would also keep templates cachable, while enabling a fairly simple syntax to provide designers with. All in all, I think that I will just have to test it for myself.

No comments:

Post a Comment