Live data from Hacker News

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

facebook.com

41–50 of 72 posts

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

#41
post #19

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.

Strangely enough, I'm reading your PHP code just now :)

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

#42
post #19

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.

Strangely enough, I'm reading your PHP code just now :)

Heh, which code is that? If it's anything to do with a certain salesforce-like system at a certain log-searching company, I apologize. :)

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

#43
post #42

Earlier quoted context omitted.

Strangely enough, I'm reading your PHP code just now :)

Heh, which code is that? If it's anything to do with a certain salesforce-like system at a certain log-searching company, I apologize. :)

No, thank god that (salesforce-like system) is dead :) Something called 'spacecake'...

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

#44

Earlier quoted context omitted.

Couple questions: 1. How is this different from Django filters? Is it that the default is HTML escaping instead of having to specify the escaping with each template variable? 2. How does it handle different escaping contexts? For example, text in html attributes needs to be escaped differently from text in the body of the document. Text in URLs or JavaScript has to be escaped differently still, and often times you ha…

I'm also very interested in how it is able to escape properly... anybody?

I've skimmed through the docs. Each tag that you can use is a PHP class. It knows exactly which attributes it can take and it can do some validations on the attribute values. I'd assume that it knows when there's supposed to be JS in an attribute value and when there's supposed to be text.

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

#45
post #20

Earlier quoted context omitted.

Not really. You can still separate MVC style. Templates have always had some display logic, which is ok. What you don't want is intermixed application logic.

In my opinion this "fuzzy" separation is exactly what frameworks like Django (and many existing PHP MVC frameworks) tries to avoid - they specifically disallow things like arithmetic in their templating language for this reason. As soon as you get more than one person working on a site, you're going to have an overly ambiguous demarcation point between the presentation and the logic layers and it's going to wreak hav…

I definitely agree. I'm moving my Rails app to the mustache template language so that I'm forced to keep every single piece of logic (and I do mean that. Mustache allows only conditional statements, for each statements, and the outputting of variables) out of my HTML templates.

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

#46
post #26

BTW for those of you interested in installing on Linux, you'll need php5-dev (so on deb/ubuntu machines a quick apt-get install php5-dev solves it). Run phpize from the root, then the normal ./configure, make, make install etc...

has anyone gotten this to work on OSX? I get strange errors after I build and add the extension to php.ini LOG: http://pastie.org/817528

Working perfectly for me on OS X snow leopard. It compiled cleanly.

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

#47
post #31

Earlier quoted context omitted.

What is the fundamental problem it masks?

The separation of presentation and logic. Anyone who's spent the 1990s coding Perl CGI will tell you just how big of a step backward this is.

Lazy/bad developers will always find ways to put business logic and presentation in places they don't belong. I like systems that -- rather than enforcing arbitrary and inevitably leaky constraints -- aim for maximum productivity and power in the hands of capable developers.

Let's take a real case: Smarty. To my eye, XHP is going to take a huge slice of the PHP template system market away from Smarty. The reason is that XHP gives you the native constructs of PHP (sans mind-bending hacks -- try referencing a class constant in Smarty) while staying at the right level of abstraction for fast development: chunks of valid XHTML.

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

#48
post #42

Earlier quoted context omitted.

Heh, which code is that? If it's anything to do with a certain salesforce-like system at a certain log-searching company, I apologize. :)

No, thank god that (salesforce-like system) is dead :) Something called 'spacecake'...

I'm happy to have written code for a system I know nothing about. :)

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

#50
post #20

Earlier quoted context omitted.

Not really. You can still separate MVC style. Templates have always had some display logic, which is ok. What you don't want is intermixed application logic.

In my opinion this "fuzzy" separation is exactly what frameworks like Django (and many existing PHP MVC frameworks) tries to avoid - they specifically disallow things like arithmetic in their templating language for this reason. As soon as you get more than one person working on a site, you're going to have an overly ambiguous demarcation point between the presentation and the logic layers and it's going to wreak hav…

The article claims that it's stored in DOM and can manipulated as such. To me the big win though is that using this means things should get escaped properly by default.
Post reply on HN