5 ms·
So JSX is like pure php templates.
by arkh 8y ago
So JSX is like pure php templates.
- bryanrasmussen 8y agoI remember reading somewhere that React was first written because someone wanted something similar to PHP workflow, but I don't see it, probably because I've only had a 1 month experience with PHP one time.
- arkh 8y agoYou can mix php and html. A minimal php hello world would just be "Hello World" in a file. I expect a templating engine equivalent to php's twig becoming the standard way to separate the views from the behavior soon enough.
- krapp 8y agoThere is a javascript fork of Twig that I used to play around with[0] but it's far from "standard." [0]https://github.com/twigjs/twig.js https://github.com/twigjs/twig.js
- e1g 8y agoIndeed, JSX can be traced back to Facebook's idea of XML syntax on top of PHP called XHP [1][2]. It was never adopted by the community and did not break out of FB's custom PHP runtime called HHVM. [1] https://www.facebook.com/notes/facebook-engineering/xhp-a-new-way-to-write-php/294003943919/ [2] https://docs.hhvm.com/hack/XHP/introduction
- krapp 8y agoHack actually supported it directly with XHP, which was great. Native support for extensible XML and data escaping out of the box is something PHP should have done as soon as was feasible, but unfortunately the best PHP can still do is string concatenation. Even Twig, which is basically an entire DSL with its own lexer, parser and everything, eventually just mashes strings together. I really wish XHP had been on the list of features PHP7 had taken from Hack and that it was default. Of course you can compile it in as a plugin, but that doesn't help the majority of PHP users nor does it encourage developers.
- hiccuphippo 8y agoI think it is closer to .Net's WPF. The XML is treated as another way to write objects with attributes, children and bindings. It's more clear for writing tree-ish stuff than pure code.