r/javascript • • Dec 15 '15

Angular 2 Beta is now available

http://angularjs.blogspot.com/2015/12/angular-2-beta.html
140 Upvotes

88 comments sorted by

View all comments

26

u/wreckedadvent Yavascript Dec 15 '15

Well, I'm glad they bothered to keep upgrade paths in mind. That was one of my biggest concerns from the 2.0 announcement.

ngForward looks especially interesting, particularly for those who are still stuck with IE8 support.

However, I don't think I'll see myself using angular 2.0 personally. After react, mithril, riot, etc. I just don't find the boilerplate you have to use with 2.0 very attractive.

1

u/meenie Dec 15 '15

Do you mean the decorators (@Component(), @RouteConfig(), etc)? I find it really easy to see the configuration of a component right at the top like that. Also the new DI stuff is pretty amazing.

7

u/wreckedadvent Yavascript Dec 15 '15

I mean in general. I commented on an angular 2.0 example not too long ago here in another comment about it if you'd like to know more about why I think it's boilerplate-y.

1

u/meenie Dec 15 '15

I understand where you are coming from. And writing code like that is not for everyone. To contrast your example with Mithril, I feel a lot more comfortable writing explicit code like Angular2, rather than trying to grok everything going on in that feature packed Mithril example. The thing with making something so explicit is that you can later add some more sugar to it and create even more conventions that you don't need all the boilerplate. You could easily write your own decorator which extends the @Component decorator to make all of that less boilerplate-y.

I was listening to a live video chat with the Angular2 team saying that one of their team members, Viktor, is working on something like that already. Making a "shorthand" version to write components where you'll need the implicit knowledge of what's going on.

As of alpha.43ish they automatically include the core directives now, so no need to provide them.

7

u/wreckedadvent Yavascript Dec 15 '15

That "feature packed" mithril example is just three function calls, one of which is Array#map. There's also nothing implicit about it; I am explicitly making the element and then calling the child component directly. I guess you could say the default export is implicit if you really wanted to, but it's standard ES6 modules to me.

However, I'm glad to hear they're taking steps to reduce the boiler plate. CORE_DIRECTIVES was such a huge code smell to me, I have no idea how they didn't catch that sooner.

4

u/joshmanders Full Snack Developer Dec 15 '15

I agree completely, and I've been watching things. To be honest, I'm leaning harder at going to React over Angular 2.

1

u/meenie Dec 15 '15

I was under the impression that your mithril example was analogues to the Angular2 example. The @Input and @Ouput setup the interaction for the component that is being created. So assumed that what you wrote did the same thing, which is why I thought it was more implicit than what it is. We both obviously prefer different things, which is cool :).

1

u/wreckedadvent Yavascript Dec 15 '15 edited Dec 15 '15

I should be more clear then. It is analogous; they would do the same thing, just in the ways that each framework prefers. The angular example happens to set up a lot more because that's what angular requires, but they would render HTML that achieves the same thing.

The angular example uses @Input and @Output to mark how the data binding occurs. However, Mithril doesn't do databinding - the second parameter I pass into m.component is all of the arguments that component takes (it becomes the second argument in that component's view function). That takes care of @Input, and @Output is handled simply by referencing javascript variables in scope.

This is no less explicit than the angular one, just I am consuming my component directly instead of through HTML templates. I can definitely see how it wouldn't be for everyone, as there are still people who don't want templates with the javascript - and of those who do, even less who are willing to drop JSX (or MSX in this case) and just use pure function calls.