It's less "cool" than this, certainly, but making the default reasonably safe and forcing you to ask for the dangerous level of output rather than defaulting to dangerous and having to ask for safe is a lot easier to implement.
XHP: A New Way to Write PHP (from Facebook)
51–60 of 72 posts
Re: XHP: A New Way to Write PHP (from Facebook)
#52Earlier quoted context omitted.
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.
Re: XHP: A New Way to Write PHP (from Facebook)
#53Earlier quoted context omitted.
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.
Re: XHP: A New Way to Write PHP (from Facebook)
#54"...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. Of course, this also means that if you are unable to run HipHop you probably want to think a bit and run some tests before adopting this."
Re: XHP: A New Way to Write PHP (from Facebook)
#55http://www.scala-lang.org/node/131
...although I doubt it does escaping by default. Should be simple enough to add while you're converting the scala.xml.NodeSeq (iirc) to text.
For an API that required both XML and JSON output, Scala's built-in XML support had us wishing the JSON version of the API was as easy as the XML version.
Re: XHP: A New Way to Write PHP (from Facebook)
#56BTW 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...
Fatal error: Class 'xhp_a' not found in /home/me/public_html/test.php on line 3
Here's the code I tested with: Facebook;
I tried running the code through the xhpize tool, and got the following output: $href,), array('Facebook',), __FILE__, 3);
Which produces the same "class not found" error.Re: XHP: A New Way to Write PHP (from Facebook)
#57XHP 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 reall…
I really liked what you had to say! Please let me know if you want me to remove the quotation or change the links around it. I'm jolie@readwriteweb.com.
Re: XHP: A New Way to Write PHP (from Facebook)
#58For 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.
If you want me to remove the quotation or change the links, just let me know. I'm jolie@readwriteweb.com.
Re: XHP: A New Way to Write PHP (from Facebook)
#59BTW 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...
I just installed this on a fresh Linode with a basic Ubuntu 9.10 LAMP stack. It built ok, and the module shows up in phpinfo(), but when I try to run any of the example code, I get an error: Fatal error: Class 'xhp_a' not found in /home/me/public_html/test.php on line 3 Here's the code I tested with: Facebook ; I tried running the code through the xhpize tool, and got the following output: $href,), array('Facebook',)…
Fatal error: Class 'xhp_span' not found in ...
Any ideas on how to fix would be appreciated. Google and Bing have nothing so far and the module configuration info on the GitHub page is limited: http://wiki.github.com/facebook/xhp/Re: XHP: A New Way to Write PHP (from Facebook)
#60Earlier quoted context omitted.
What is the fundamental problem it masks?
Presumably he means allowing users to thoughtlessly work with unsafe values. One way that XHP could mask this problem is clear by looking at: echo {$_POST['name']} ; Now someone comes along and decides the span is unnecessary, turning the code into the (erroneous): echo $_POST['name']; However, I don't think this is a problem with XHP's approach, except in the sense that XHP doesn't go far enough in fixing PHP's faul…
// This works
write({$_POST['name']});
// Where as this wouldn't work
write($_POST['name']);
I think perhaps the use of echo in these examples is just a simplification. More than likely, in Facebook, these XML classes are outputted by another function.