r/javascript • • Sep 15 '16

Angular 2 Final Released

http://angularjs.blogspot.com/2016/09/angular2-final.html
358 Upvotes

190 comments sorted by

View all comments

31

u/mdboop Sep 15 '16 edited Sep 15 '16

And nobody cares. I doubt adoption rates will be significant, but who knows, I guess. It just seems like there are so many things going against it that will outweigh its merits. Embracing rxjs, awesome. Typescript, fantastic if you're into it. But people are sick of Angular 1.x for the most part, Angular2 took forever to be released (feels like the opportunity went stale a while ago), and it's still pretty damn complicated compared to React or Vue.

People talk about how JS frameworks change all the time and say React will likely not be around forever (I hear this from co-workers when I bring up why we should switch from Angular 1.x to React), but someone on my team brought up an excellent point: React is used to build FB's flagship product. It's literally everywhere in the site. But Angular? Nowhere to be seen in any Google product of note. To me, that speaks volumes (on top of it's other merits).

edit: and, of course, React will not be around forever. But I'd put my money on it over Angular2 any day. edit2: forgot a word

21

u/Shaper_pmp Sep 15 '16 edited Sep 15 '16

You also left out the most important point - Angular is a framework, and with any framework almost everything is done "their way or the highway" (or at least, their way or you're off in the weeds of unsupported/second-class-citizen workflows with limited support and documentation).

React is a library, and - like any other library - if necessary you can swap it in and out for alternatives without completely reengineering your entire application.

Frameworks are convenient but fundamentally limiting because they dictate the structure of your application, so you're always trying to express both the problem and the solution in terms of one specific tool. With a full toolbox you can hammer nails, screw in screws and spread glue as appropriate. With exactly one tool in your toolbox you either severely limit the kinds of projects you can undertake or you inevitably end up banging in screws sooner or later because that's all you can do.

Composing libraries together takes more effort, but gives you more flexibility, allows you to avoid lockin more easily, and allows you to express your solution in terms of the problem-space instead of coercing you into a "one size fits all" approach that never really quite does.

8

u/rk06 Sep 15 '16

In those cases, one can chose aurelia.

2

u/Channel6 Sep 15 '16

Shame this comment will be lost in the usual flood of react vs Ng, there really is an alternative...

0

u/[deleted] Sep 15 '16

[deleted]

1

u/FrozenOx Sep 15 '16

I find a lot of language/framework subs are dead on Reddit. Everyone serious about some dev language/framework/tool is on its Slack or Gitter channel now.

18

u/pegbiter Sep 15 '16

React is beautiful.. in principle, but to actually do useful things with it you need so many additional libraries that the slickness is lost. You want ajax? You need an additional library. You want promises? You need an additional library. You want routing? You need an additional library. And god forbid something goes wrong and you have to trace through the documentation of each of these libraries and how they work with react proper.

In theory, sure I could pull out react and replace it with some other view engine, but in reality I'd be pulling out react and all the other react-based libraries and replacing/adjusting all of those.

Angular 1.x sure isn't perfect, but at least all the most basic tools you need for a web application are right there and I never have to worry about how $http works with $scope or whether $q is a compatible version.

8

u/theonlylawislove Sep 15 '16

in principle, but to actually do useful things with it you need so many additional

This is actually a benefit. You are looking for an opinionated Swiss army knife. With React, you do things what makes sense to you, not what the framework forces you to do.

6

u/g0liadkin Sep 15 '16 edited Sep 15 '16

Please define what you mean with "forces".

Angular does not recommend many vanilla js aspects, but does not "force" you not to apply them, it's still javascript and you're able to do whatever you want to do within the language's bounds, even if that means (for example) accessing and handling DOM inside a controller.

3

u/fenduru Sep 15 '16

This is actually a benefit. You are looking for an opinionated Swiss army knife. With React, you do things what makes sense to you, not what the framework forces you to do.

In Angular 2 most features are implemented deep in the compiler. For instance, I wanted to compose their @Input decorator to create an @ObservableInput decorator that would create a stream for me, but you can't because their decorators just add metadata that is specifically for the internals of the compiler. Not extensible, so good luck if you hit a point where they haven't thought of your use case.

3

u/theonlylawislove Sep 15 '16

Let's just say it's an opinionated ecosystem.

→ More replies (2)

5

u/pegbiter Sep 15 '16

I don't really see how it's a benefit, because React on its own is utterly useless to me. Sure, if I want to quickly mock up the standard 'to do list' test app and just demonstrate data-binding, yeah that's great. But I've worked on dozens of web apps, some tiny and some huge, and every single one has needed ajax, promises and routing, to some degree. Those aren't optional 'nice to haves', they're absolutely core tools.

React forces me to rely on a load of other libraries just for core functionality.

If you like that, then Angular comes with those benefits too. Sure, Angular has a router, but there are other Angular routers you can use too. Sure, Angular can do datetime formatting, but there are other directives (moment.js is absolutely brilliant) that extend that.

0

u/[deleted] Sep 15 '16

[deleted]

5

u/pegbiter Sep 15 '16

I just think comparing React to Angular isn't really a fair comparison. We should really be comparing React + Redux + Flux + React-Promise + React-Router to Angular, that's the actual real-world use-case. And at this point, I don't really see the benefit because I'm relying on all these libraries to do really basic things, and all those libraries rely on react, so I'm as tied down to React as I would be with Angular.

8

u/[deleted] Sep 15 '16

Why would you be using Flux with Redux? Why would you be using React-Promise in a toolchain that already transpiles JSX and can therefore shim ES6 and its promise objects? It's a disingenuous example and it weakens your argument.

1

u/theonlylawislove Sep 15 '16

The state part of React doesn't depend on React. The only thing built with React that depends on React is anything having to do with the views.

1

u/[deleted] Sep 15 '16 edited Sep 15 '16

Btw, this is from the Angular quickstart: https://angular.io/docs/ts/latest/quickstart.html

Building a simple "hello world" without anything fancy resolves to this:

"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.27",
"zone.js": "^0.6.23",
"angular2-in-memory-web-api": "0.0.20",
"concurrently": "^2.2.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.2",
"typings":"^1.3.2"

<!-- 1. Load libraries -->
 <!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
  System.import('app').catch(function(err){ console.error(err); });
</script>

Even if you can pick and choose, it's still a myriad of moving parts.

2

u/TinyZoro Sep 15 '16

I don't really get this. We are talking about crud applications on the internet for the most part. What are the situations where an opinionated framework gets in the way?

3

u/[deleted] Sep 15 '16 edited Sep 15 '16

No? Are you saying you still write ES5 code (!) with things like Grunt or Gulp, handling polyfills ...manually? If yes you only have yourself to blame.

All this stuff is automatic today with things like Webpack and Babel. React means making two npm installs. Babels transformer fetches all the polyfills it needs from core-js as you go. Even if you use additional components like Router and Redux, these are simple npm installs away.

3

u/[deleted] Sep 15 '16

He's not talking about polyfills, he's talking about actual features and additional libraries. Like routing and managing data and stuff you require if you build a heavy app. Things that can easily be done with Angular1.

Grunt/Gulp also is fine, there is enough to say why one wouldn't use webpack. And why cant you use gulp with babel? Gulp is task running, doesn't matter if the project is ES6 or not.

And knowing Router and Redux is fine but what if you need more than that? Especially if you aren't really into it, you need to do a lot of research for even getting the same as you get out of the box with Angular

0

u/[deleted] Sep 15 '16

It is the same in Angular, you pick and choose what you need. The only difference is that a whole bunch comes preinstalled in node_modules. Getting up and running even with a simple app needs more dependencies than React - and everything else for that matter.

Grunt/Gulp do not know your project, they don't fetch and manage your dependencies. Each dependency meant concats, html injects, minding order of inclusion, etc. It is no wonder he thinks people are worrying about polyfills and dependencies.

What do you mean with needing "more" ? It's pretty vague. What exactly can you do in Angular that can't easily be done in React. What did you have to research, can you go into specifics?

→ More replies (3)

1

u/Conradfr Sep 15 '16

In actual companies making money not every projects are rewrite each time there is a new build tool or whatever 0.x fancy library.

1

u/[deleted] Sep 15 '16

If you want to swap out a component you will need to rewrite everything that used that previous component. React doesn't change that.

1

u/Shaper_pmp Sep 15 '16

Of course. Bus your business logic should be as isolated from your presentation/view/persistence/etc logic as possible, so you shouldn't have to rewrite everything.

If you want to swap from using Angular to something else, you don't really get that choice. Either you'll basically have to rewrite/port your entire application into the new framework, or you actively avoided using Angular's tools and workflows and did something like built your business logic into CommonJS modules and shimmed them into Angular, making them second-class citizens in the way I previously mentioned.