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.

0

u/[deleted] Dec 15 '15

[deleted]

17

u/cheese_wizard Dec 15 '15

After using typescript for the last year... I can't see going back. It has caught so many typos for me, and code completion makes things go so much faster.

3

u/kenman Dec 16 '15

Typos that a decent IDE (Webstorm) and/or build system (JSCS/JSHint) wouldn't have caught?

5

u/cheese_wizard Dec 16 '15

Sorry, didn't mean like spelling typos, more like static checking errors like calling a string function on a number or something like that.

1

u/ivosaurus Dec 16 '15

Visual Studio / Visual Studio Code

→ More replies (1)
→ More replies (2)

1

u/urban_racoons_ Dec 16 '15

A little off topic, but what sort of IDE do you use for typescript that includes code completion?

3

u/[deleted] Dec 16 '15 edited Feb 11 '17

4#xML2xKT$G+F&qAXsf4zMTR!dGPI~)f6Jw6A&i-8m%W8.3[R.8[(#1FWx$4qTB)l833KV&(6>FBxoiEvG(3&6+ifGi

2

u/I-fuck-animals Dec 16 '15 edited Dec 16 '15

WebStorm has Typescript completion

It has "completion", period.

Quite a few bugs previously, I submitted many bug reports to Jetbrains, but as of the current version 11.0.2 it seems to work very reliably.

And by the way, WebStorm recognizes inline JSDoc type hints (in additon to all the normal JSDoc):

let /**string[]*/ a;

From now on this is an "array of strings" (I prefer the short notation over Array.<string>) - for the code inspections as well as for completion. If you want types, with WebStorm and an IDE and/or tools recognizing JSDoc type info you get them with regular Javascript.

2

u/x-skeww Dec 16 '15

WebStorm, VS Code, and Atom all provide a very similar experience when working with TS, because the plugins are all built on top of TS' services.

Dart's tooling works the same way. The heavy lifting is done by the SDK's analyzer which is used by all plugins.

New languages should definitely copy this concept. It's the most efficient way to get top-notch tooling into all kinds of editors and IDEs. It also makes it easier to keep those plugins in sync with language changes.

1

u/cheese_wizard Dec 16 '15

I use PHPStorm... WebStorm has it too.

11

u/wreckedadvent Yavascript Dec 15 '15

One of the nice things about typescript at least is you can "progressively type". That is, you can write vanilla ES2015 and then add in types at whatever rate you're comfortable. It's even somewhat common to write pure ES6 and then add types after the fact, so you can take advantage of the dynamic nature of javascript while developing, and then solidify the API after you're good with it.

4

u/[deleted] Dec 15 '15

Typescript is not a requirement to use Angular 2.0, you can still use ES2015.

0

u/[deleted] Dec 15 '15

[deleted]

4

u/newmanoz Dec 15 '15

no, not harder. Just remove types (you don't need to use them in TS) and you'll get (almost) vanilla es6. Initial code conversion is as easy as changing file extension from js to ts.

2

u/[deleted] Dec 16 '15

Javascript taking a back-seat to Typescript? You're joking, right? Typescript is overkill in many cases.

5

u/MonsieurBanana Dec 16 '15

I read that as javascript taking a back-seat to typescript on angular 2.

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.

→ More replies (1)