Hacker News new | ask | show | jobs
by thurn 5412 days ago
Facebook's XHP is a magnificent tool that you need to use to appreciate. It lets Facebook build a website out of reusable components that know how to load their own data. It's very different from the MVC paradigm, but very light-weight. The XML components are full PHP classes, including allowing for methods, subclassing, etc.

The emphasis on components instead of pages is not strong enough in many other web frameworks like Rails.

2 comments

I had the same experience -- I didn't fully grasp how useful XHP was until I had to use it. Not only are they reusable components, but the type system they create and can enforce is a powerful aid to helping me suss out how they were meant to be used. (Now if only XHP::render could detect when it's already been called, to avoid weird validation bugs from the side-effects!)

And when I had to include some multi-line javascript in my code, I found myself feeling a huge loss. First, heredocs seemed to be the only way to make it readable. Second, I'd have to actually run the code and interact with the page to find out if I got the syntax right. It would be awesome if there was a way to make JS into an object in PHP, the way that XHP is done, and have it support some simple sanity checks and easily import JS components (which I suppose Javelin tries to do).

Couldn't agree more. Its been the use of XHP and looking at the ... contraption HPHP is that started me thinking about this in the first place.