Live data from Hacker News

XHP: A New Way to Write PHP (from Facebook)

facebook.com

1–10 of 72 posts

Re: XHP: A New Way to Write PHP (from Facebook)

#2
XHP rocks so fucking 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. You could argue that the markup syntax is cruft, but it really helps code readability to have two types of syntax, for code and for markup.

  $b = quotes and variables;
  $a = omg, I can't "believe" how easy these {$b} are;

Re: XHP: A New Way to Write PHP (from Facebook)

#3

  That is, it is impossible to generate malformed webpages while using XHP.
While the purist in me thinks this is great if everyone else uses it, the immense amount of productivity lost when I first started using kid templating (e.g. http://turbogears.org/about/kid.html ) really burned me on this whole concept.

Sometimes I really do want to make a quick test page without crossing all my i's and dotting all the t's. Importing non-perfect markup from a designer is a big pain, too, in this kind of templating system.

And, though it's unfair to say so, some companies do well enough without 100% valid XML markup: http://blog.errorhelp.com/2009/06/27/the-highest-traffic-sit...

Re: XHP: A New Way to Write PHP (from Facebook)

#5
post #3

That is, it is impossible to generate malformed webpages while using XHP. While the purist in me thinks this is great if everyone else uses it, the immense amount of productivity lost when I first started using kid templating (e.g. http://turbogears.org/about/kid.html ) really burned me on this whole concept. Sometimes I really do want to make a quick test page without crossing all my i's and dotting all the t's. Imp…

Saving 14 bytes per request is something only a very few sites need to think about...

For the rest of us, clarity and semantically correct code are much more useful.

Re: XHP: A New Way to Write PHP (from Facebook)

#6
post #4

very, very cool. i can't wait to dig into this more... it looks like even the basic examples are cool, but there's lots of stuff under the hood waiting to be discovered.

it is indeed one of the coolest things i have used. the fact that you have all the HTML stored as objects and available for manipulation makes all kinds of crazy post-processing (just before rendering) possible.

Re: XHP: A New Way to Write PHP (from Facebook)

#8
seems to me that if they went to the trouble to make it understand xml syntax and error out on invalid code, they should have just made it auto-close tags. on pages where there are heavily nested divs and other things, auto-closing the tags would make the code smaller while still generating valid xhtml and not bothering the developer with such trivial things.

     echo blah;

Re: XHP: A New Way to Write PHP (from Facebook)

#9
post #8

seems to me that if they went to the trouble to make it understand xml syntax and error out on invalid code, they should have just made it auto-close tags. on pages where there are heavily nested divs and other things, auto-closing the tags would make the code smaller while still generating valid xhtml and not bothering the developer with such trivial things. echo blah;

One last feature of XHP, which has been invaluable to us at Facebook, is that you can define your own elements which can condense a complex component into a simple XHP tag. XHP has a rich collection of declarations which let you define new elements, configure their expected attributes, as well as describe their content model.
Post reply on HN