5 ms·
It's interesting that this is a case where React does need to somewhat reinvent the wheel. The best aspect of JSX is that you can use native JS constructs. So i
by dguo 9y ago
It's interesting that this is a case where React does need to somewhat reinvent the wheel. The best aspect of JSX is that you can use native JS constructs. So instead of a custom HTML attribute (e.g. ng-if in Angular, v-if in Vue), you can just use a JS if statement.
It makes me wonder what a UI language/system would look like if it were designed from the ground up to be declarative. Would it end up just looking a lot like React?
Anyway, this looks useful. Error handling is one of the harder aspects of programming in my experience, so I'm glad this exists now.
- jordwest 9y ago> It makes me wonder what a UI language/system would look like if it were designed from the ground up to be declarative. Would it end up just looking a lot like React? You could find one answer to that question in Elm[1], and indeed it does look a lot like React. Although it generally handles exceptions by never letting them happen in the first place :) [1] http://elm-lang.org/ http://elm-lang.org/
- i6ruce 9y agoI would say, React looks like Elm but more imperative.
- peteretep 9y ago> It makes me wonder what a UI language/system > would look like if it were designed from the > ground up to be declarative XSLT? I think most people have seen XSLT only in trying to do simple transformations, without getting properly under its skin. Personally I've written a bunch of stuff in it -- a testing suite, graph traversal algorithms -- that make you appreciate it's absolutely a functional declarative language.
- danabramov 9y ago>It's interesting that this is a case where React does need to somewhat reinvent the wheel. Yep. React has to reinvent the wheel everywhere at the component boundaries. For example, one could see <Foo /> (which is really {type: Foo}) as a “reinvented” Foo() function call. Or see this.state as “reinvented” local variables, and this.props as arguments. I think it’s expected that, as React gets more expressive (there are other features in the pipeline), it will unfortunately have to provide its own way to express these because it goes more into the language territory. But of course we’ll try our best to make these things look familiar in JS.
- mbel 9y ago> It makes me wonder what a UI language/system would look like if it were designed from the ground up to be declarative. QML [0] was an attempt to do that. I would say it was a very successful attempt in terms of quality of the final product. It's probably the only UI toolkit that I enjoyed using so far. [0] https://en.wikipedia.org/wiki/QML#Syntax.2C_semantics https://en.wikipedia.org/wiki/QML#Syntax.2C_semantics
- yunyu 9y agoVue supports JSX: https://github.com/vuejs/babel-plugin-transform-vue-jsx https://github.com/vuejs/babel-plugin-transform-vue-jsx