Live data from Hacker News

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

facebook.com

21–30 of 72 posts

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

#21
post #17

Earlier quoted context omitted.

Wasn't there just a thread complaining about how the end tags make HTML so much more verbose and difficult to read, and that's why people are writing preprocessors like HAML and XHP? I've found that the code is much clearer when you omit your end tags. As for semantic correctness - it's in the HTML spec, and every major modern browser handles it correctly. Sometimes I wonder if Google's the only folks who actually re…

If you don't close your tags, foo bar baz box how can you tell the difference between, foo bar baz box and foo bar baz box

The HTML tag closing rules specify they only get closed when they have to be. So neither of your solutions is correct. It is:

foobarbaz box

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

#23
post #5

Earlier quoted context omitted.

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.

Wasn't there just a thread complaining about how the end tags make HTML so much more verbose and difficult to read, and that's why people are writing preprocessors like HAML and XHP? I've found that the code is much clearer when you omit your end tags. As for semantic correctness - it's in the HTML spec, and every major modern browser handles it correctly. Sometimes I wonder if Google's the only folks who actually re…

Actually, I once visited a website that didn't close its tags where that practice hindered my use of it. That page used backticks instead of curly quotes, so I wanted to use a bookmarklet to fix that. The bookmarklet cycles through every DOM text node and replaces the text. When I tried to run it on that page, nothing happened – probably because there were no text-only nodes, because the page was treated as one big tag. So browsers don't handle missing closing tags completely correctly, and therefore one should include closing tags.

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

#24
I'm using PHPTal right now to achieve more or less same effects, but it's not the easiest solution - it becomes a bit cumbersome for long fragments.

XHP looks very promising because it solves one of my problems with PHPTal - generating complex content in the loop (in PHPTal having multiple conditions in loop is possible, but not exactly elegant)

For example:

  ;
    foreach ($items as $item) {
      if ($item->bold) {
        $list->appendChild({$item});
      } else if ($item->foobar) {
        $list->appendChild({$item});
      } else {
        $list->appendChild({$item});
      }
    }
  ?>

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

#25
post #17

Earlier quoted context omitted.

Wasn't there just a thread complaining about how the end tags make HTML so much more verbose and difficult to read, and that's why people are writing preprocessors like HAML and XHP? I've found that the code is much clearer when you omit your end tags. As for semantic correctness - it's in the HTML spec, and every major modern browser handles it correctly. Sometimes I wonder if Google's the only folks who actually re…

If you don't close your tags, foo bar baz box how can you tell the difference between, foo bar baz box and foo bar baz box

Rendered html that will be sent has an http response should have ending tags. That doesn't mean the programmer/designer has to write them: #a dumb ruby example: def p(content) "

"+content+"

" end

p "hello" #=> "

hello

"

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

#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

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

#27
post #21
post #17

Earlier quoted context omitted.

If you don't close your tags, foo bar baz box how can you tell the difference between, foo bar baz box and foo bar baz box

The HTML tag closing rules specify they only get closed when they have to be. So neither of your solutions is correct. It is: foo bar baz box

my solution was to merely demonstrate the difference between what a programmer writes and what gets sent as an http response.

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

#28
post #17

Earlier quoted context omitted.

Wasn't there just a thread complaining about how the end tags make HTML so much more verbose and difficult to read, and that's why people are writing preprocessors like HAML and XHP? I've found that the code is much clearer when you omit your end tags. As for semantic correctness - it's in the HTML spec, and every major modern browser handles it correctly. Sometimes I wonder if Google's the only folks who actually re…

If you don't close your tags, foo bar baz box how can you tell the difference between, foo bar baz box and foo bar baz box

By "don't close your tags", I mean "don't close your tags when the HTML spec does not require you to." You still need to close your , , and tags. You don't need to close your , , , , , , and several other tags. You don't even need to open your and tags, if you're not doing funky stuff like putting comments in them.

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

#30
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;

While I understand where you're coming from, I feel like that would result in incredibly confusing markup and only lead to increased headaches down the road. I'm glad they left that out.

[deleted]
Post reply on HN