News for hackers. Stuff that matters.
Re:Error Handling in React 16 by dguo on Wednesday July 26, 2017 @10:16PM (#14862164)
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.

Re:Error Handling in React 16 by jordwest on Wednesday July 26, 2017 @11:50PM (#14862564)
> 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/

Re:Error Handling in React 16 by i6ruce on Thursday July 27, 2017 @03:59AM (#14863450)
I would say, React looks like Elm but more imperative.
Re:Error Handling in React 16 by danabramov on Thursday July 27, 2017 @06:10AM (#14863946)
>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.

Re:Error Handling in React 16 by mbel on Thursday July 27, 2017 @06:45AM (#14864082)
> 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

Re:Error Handling in React 16 by peteretep on Thursday July 27, 2017 @04:53AM (#14863628)

    > 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.

Re:Error Handling in React 16 by yunyu on Thursday July 27, 2017 @07:25AM (#14864226)