Angular 2 Release Candidate
github.com
github.com
1. Companies currently implementing it not wanting it to change or for there to be a quick and painless migration from 1.x to 2.x. So, less change, more hand-holding. The web changed a lot though, so its change is understandable.
2. Trendsetters and upcoming companies looking for something new fresh and solid: Framework competition from React and the like. Maybe that second group is a lot louder in certain circles, startup-y hackernews being one, but it sounds like Angular will eventually reside in the shadow of React if it stays that way for long. Google pulling the plug on things fairly commonly doesn't help with the uncertainty.
Just seems like anytime Angular comes up in conversation, React isn't far behind. This post is no exception I guess, I just can't see Google maintaining Angular if it becomes Dojo in the eyes of developers.
If it's more than copy-pasta then I doubt it will be received well.
And #2 is spot on -- React is eating Angular's lunch. I'd love to use it at work but I can't, and I don't think I'm the only one.
The Animated library (originally from React Native) gives you some pretty basic but powerful primitives to build whatever animation you need.
Recommending React to somebody who's considering Angular is like recommending tyres to somebody who's shopping for a car.
Part of the problem with Angular that no one seems to care about is that Angular 2 was such a big change from Angular 1 it forced companies that depended on Angular 1 to do a complete re-write.
I was an Angular 1 dev and Angular 2 caused me to abandon Angular altogether.
Angular also adds more abstractions on top of JS which is unnecessary and can cause unexpected behavior when transpiled.
Most companies are doing the responsible thing and holding off on worrying about migration until Angular 2 stabilizes more. Even if one wanted to do a complete rewrite due to poor Angular 1 app code, one can then evaluate all options from scratch and choose the best option for their app.
Every library adds abstractions on top of JS - React is no different with your complaint of unexpected behavior.
This reads as an overly emotional post without applying engineering - "this sounds too hard so I'll just run away to another solution" is the vibe I get.
I mean, seriously, that's the main difference conceptually. You just modify some data structure and both frameworks will update some view.
I will also point out that Angular essentially re-implements JavaScript in the form of extensions to html. EG, if you want to iterate over something in React, you use map while Angular makes use of ng-repeat.
One could mitigate this by calling $scope.$apply() after every change. But if you have to apply() all changes, then what's the point of having angular handle synchronization?
Yes, shockingly, we don't save those keystrokes, but we also don't have the elaborate dirty checking. The developer of a component is extremely likely to make sure during development that the update to a state has updated the view. Of course, you could just hook up React or VDOM or mirthril and it's totally complementary to what we do.
React runs its dirty check only after a state change obligates it to. As your model gets larger and larger, dirty-checking the model on every digest loop starts to have performance problems.
Oversimplification can be incredibly misleading.
Good reading material by a team member - http://victorsavkin.com/post/110170125256/change-detection-i... and http://victorsavkin.com/post/114168430846/two-phases-of-angu...
An early beta comparo - http://www.roblog.io/js-repaint-perfs/angular2/opt.html vs http://www.roblog.io/js-repaint-perfs/react/opt.html - should probably update these with the latest RC.
Explanation: In js land, Long term Support means "6 months". so your best bet is to have a framework which makes migrations easy and does not introduce changes.
With angular being backed by google, there is no guarantee if angular will be maintained 4 years down the line.
PS: feel free to keep your million dollar.
> no guarantee if angular will be maintained 4 years
> down the line.
It's interesting to see that the reason why many companies choose Angular (Google backs it) now seems one of it's biggest disadvantages.
Even the earliest pre 1.0 releases of Angular weren't until late 2010.
Don't we all? I wonder if it's really worth it most of the time... That's assuming that new can be solid to begin with.
As of TypeScript 1.8(?) you can set an "allowJs: true" flag in tsconfig.json, which tells TypeScript to include JS files in your build.
Then you can just manually add type annotations and ES2015/2016 goodness to your code and change the suffix to '.ts' on a file-by-file approach.
I'm doing this at the moment with a fairly large AngularJS 1.5 project, using Webpack with awesome-typescript-loader as the build system, and it's working perfectly so far.
Using Angular 2 with TypeScript is almost like using WPF and C# on the desktop - it has that enterprise framework feeling - hierarchical DI everywhere, everything out of the box (DI, routing, events, forms, etc.), classes and OO are the foundation, decorators, even "functional" parts adopts RX from .NET. Using Dart gets you even more stuff working "out of the box" with a functional package manager and build system but it seems like that language might be a dead end so TS is a safer bet. Tooling provided powered by TS is top notch.
React is much more of a JS approach - sure the core library is smaller but in the end you throw in a bunch of libraries to compose your own framework and you're stuck with good old JS decision hell (should I use redux, which routing lib, etc.) - this may be an advantage if you you have a bunch of front end devs that like to sink time in to exploring the ecosystem and chasing the latest fads to keep up to date with what's being supported - but if you need a library to give to your corporate C#/Java devs angular would be my go-to. Coding styles are classic JS mix-and-match pseudo functional + pseudo OO.
Angular 2 feels slightly over-engineered but at the same time I'm more comfortable with this approach - even after using clojure full-time for 2 years - react feels too messy both from a functional/OO and ecosystem standpoint.
Thats the reason i decided against React. After so many years of programming i really like opinionated its so time consuming to figure out which major library component (*flux) will be maintained down the road and have enough momentum behind it.
And the combination of Angular2 with Typescript it really nice
They're both good at what they do, but they have different sweetspots in terms of the problems they're good at solving.
React is a mishmash of various approaches and tools - functional, OO, embeded markup, etc. You can get type definitions for it but it's not really "natural", for eg. support libraries just have terrible type definitions because they don't map to typescript type system nicely at all - which is what I was getting at.
Since virtually ALL available React tutorials, courses, quick starts, etc are written in JS, there is very little support out there for TS.
With Angular2, it's all TS all of the time. And, to me, that's incredibly important.
There are lots and lots of shops that - for one reason or another - don't care about React. And frankly for someone who works with Angular 1.x, React might just not be that interesting.
I think angular2 is a lot more interesting than angular 1.x and has a lot of merit, especially for a company wanting a "batteries included" framework, opinionated syntax or Typescript throughout. A lot of developers seem to hear angular and still think inefficient 2-way binding or 'enterprise-y' when that's not the case. The roll-out took awhile, bad timing happened, and there was initial confusion over migration. In the meantime 'some' developers found the next shiny thing without considering angular2 anymore.
They're obviously very different approaches and ecosystems so an AB comparison doesn't do it justice and the comment section of HN isn't a good place for that. I'm just commenting on the developer smell around the framework as I smell it today. Sorry if I came off as 'that guy'.
<html>
<body>
Hello world<br>
<blink>hello child</blink>
(yes, I know it's not the same under the covers - take it as a comment on the ecosystem, not on the implementation (although it can be a comment on dead code detection too))Yeah, Hello World might be expensive in size, but when you've got a substantially complex and fast app for not much more size, you start to feel the real benefits.
Granted, React is pretty big too, but other frameworks, like Riot.js, have shown that they can be much smaller. Then there's Polymer which gets smaller as web components roll out.
In the competition again native apps, web apps have to load really, really fast. Their ability to run without installation is an advantage that needs to be maximized, an on potentially slow and high-latency mobile networks.
https://github.com/rollup/rollup/issues/280
Do you rollup angular or is it still an external dependency?
Honestly, there is so little continuity that you have the option of just switching to React.
Or perhaps, just maintaining your Angular 1 app - and then assuming the 1.x fork will be carried on for a long time.
That's what I did :)
I spent a whole bunch of time learning Angular1, was in a coma for close to a year after a bad accident, wake up and find my projects are all outdated and I have to basically learn a new framework. Decided if I was going to learn a new framework it was going to be something not made by google. React was simple to learn, unlike Angular. Everything you do in angular requires you to learn the "angular way", once you can create components and understand flux react is fairly straight forward and doesn't require you to re-learn web development.
Yes - you also make a great point about React, and switching to React.
We are talking about JavaScript frameworks, the keyword being JavaScript.
It is not as much of a sunk cost to switch to React because it is very JavaScript compared to Angular. Given that your team already knows JavaScript (probably, maybe, hehe) - they can pick up React fast.
And now looking at Angular 2, where people are suggesting writing Dart or TypeScript over ES6 - this seems like yet another unique Angular learning curve.
app.AppComponent =
ng.core.Component({
})
.Class({
});
from angular.component('name', {});
I will go a totally other route than upgrading. I mean wtf. the JavaScript Part of Angular 2 is horrible.
Since I'm on a Scala Server I possible try to look at Scala JS and rewrite something.
It's too bad that our "application" fit's the SPA scheme so good, but these frameworks changes so much over the years that it's nearly not maintainable will a small group.Not the OP, but having to write four lines of code instead of one does not look that good. Less is more. Code bloat should be called out.
It sounds like the person is awfully resistant to TypeScript as well, as the syntax for a component in TS is just
@Component({
})
class Foo {
}That are the most reasonable. Actually there are some others which has more something todo with our internal things and that ScalaJS < = > Scala is so good at the current stage.
the other is providing a single entry point to each of those packages, which makes it easy to configure for rollup/webpack2 etc when you want to use the ES6 source over the CJS.
I personally will never use react. but i want to know, in which situations, it would be better to use angular and in which situations it would be better to use aurelia or vue.
With web components finally going native (surprisingly, led by Safari!), will Angular 2 see any big speedups, and will the size of the hello world app come down (200k is kind of huge)?
Also, I've seen a few tutorials on using Angular 2 with Polymer, but it seems complex. Is Google working on making these work together better? Will I be able to create Angular 2 web components and use them with Polymer web components?
[1] 9:02 mark in https://www.youtube.com/watch?v=gdlpE9vPQFs&t=9m2s
When I looked at the Angular 2 beta a couple of months ago, you needed to add es6 shim, angular 2 polyfills, systemjs and rxjs as well as Angular 2, just to get up and running and have a basic Hello World.
Contrast this to Angular 1, where the library on it's own with no dependencies will suffice.
Is this still the case? Are there plans to package Angular2 as a single minified GZipped library?
Thanks
Ember: interesting framework, but all too often, you would hear a team mate say "wait, why is that working, it shouldn't be?" Mixed with equal parts "logically, that SHOULD work, what am I missing?"
React: I love the component focus, and redux is pretty slick. However, the insistence on using JavaScript in lieu of helpful abstractions that clean up the code for easier maintainability, is frustrating. The whole point of JSX is syntactical sugar, but the team went with half measures. You also end up with a lot more plumbing code than the other two. Sure, I can reuse some of these components, but in truth, most of your components will be single use.
Angular 1: by far the easiest and most intuitive. Enough magic to make setup and a basic app easy, but not so much magic that you can't figure out why something is working. However, the more complex an app, the less Angular 1 serves. And you really need to use directives as a component, and follow a more react pattern, or you're going to have a bad time. Also, the dependency injection is a nice thought for simple directives, but when you're done, you'll very likely have so many dependencies being injected that unit testing becomes burdensome. And if it's burdensome, it won't be done as much as needed.
All that being said, if your app is primarily collecting data through forms, you can't beat angular. If it's highly dynamic, and you want a more native feel to your app, react is the clear winner. Ember is a neat, but I won't be using it again.
Angular 2 doesn't fix all of my complaints, but it's getting closer.
I appreciate this. The javascript world already has too many abstractions.
>Angular 1: by far the easiest and most intuitive.
How on earth do you find Angular more intuitive than React?
Angular is a behemoth compared to React. This is like saying Rust is easier and more intuitive than Go.
Angular 2 forced me to switch to React because it made me weary of Angular 3 and the new abstractions that that will bring.
It seems also that a lot more big sites are choosing react over angular and I see a lot more job postings for react devs.
That's not really true.
The problem is that all three frameworks are supposed* to require the same discipline when it comes to managing state, but only React forces that discipline onto the developer.
I'm not saying React is better, but learning from React is important to be able to write maintainable applications in any framework. You don't want to have 30 services, each services managing there own little state in AngularJS for instance. Unfortunately that's usually what happens when an app grows with time.
Angular2 does seem to get rid of the dirty checking, allowing better performances. It also has a good router. But does it really bring something new in terms of view layer and state management, considering the cost ?
I like Angular1, it's one js file you drop in an HTML page, no need for nodejs, NPM, a third party language and what not. And it's mature. It's absolutely unfortunate that Angular2 basically forces developers to use Typescript. That's a huge mistake IMHO.
edited
I guess the first thing on my mind is: can I make Angular 2 work just like React does? Is there any way to use it without making/(being allowed to make) separate HTML templates and CSS files? If not, this is a serious disadvantage. Having the view layer scattered across 3X the files (vs React) would make it very hard to follow the code in a large project.
Also, are there any real advantages over React that would be big enough for someone to consider pushing for a switch? If so, what are they?
Angular 2 has some serious perf advantages over anything else out there, reportedly up to 2x React in some scenarios (i.e. repaint perf). It also is set up for incremental rendering, as opposed to React's blocking rendering loop, which can allow for more flexible UX. With the new bundling system for Angular 2, I believe it is currently a fraction of the size of React (I think the Angular team achieved < 10 KB app framework size, although I haven't checked out the new npm packages to be sure).
React wins out on simplicity though, including how simple it is to communicate between components. React is also currently a lot more mature, with a much more mature third party ecosystem.
Edit: I stand corrected on the size, but the 10 KB minified & gzipped is the Angular team's goal I remember reading.
The two advantages are speed (it's supposed to be faster) and its closer to the web component standard than react, so if/when web components become mainstream it could be a lot easier migrating from angular2. However, both of those wouldn't be my prime reasons for choosing a framework though.
Angular gives a lot of flexibility in code style and structure. You can componetize everything and have all your component files in one folder. You can inline it. Or you can go more MVC style folder structure like I do.
I personally like my html being approachable to junior devs and not being so chopped up and abstracted away from static HTML markup like it might be with React. Not sold on the new tag styles of A2 but I suppose it will just take some adjustment.
Not even remotely the same thing. HTML has a hierarchical structure which isn't a particularly good structure for a web application. Javascript syntax allows far more control over the hierarchy.
Your example is akin to saying putting a tank in an airplane is the same thing as putting an airplane in a tank.
> You can inline it.
Pretty thin separation between inline templates and JSX. But then, I've never understood why people think putting their template in a different file is somehow separation of concerns.
> I personally like my html being approachable to junior devs and not being so chopped up and abstracted away from static HTML markup like it might be with React.
Oh it's abstracted, with completely invalid HTML syntax and template variables. That's not to say that it's bad, I quite like the simplicity of the event/binding syntax of Angular 2. But JSX and Angular Templates are just two sides of the same coin.
Is there a "good" structure for a web application that jumps to your mind?
Throwing on click tags or jquery selectors on a huge HTML document is not a good structure.
I agree with you on the control but my point was that a lot of people that dislike Angular don't like the idea of putting tags on HTML elements which is very reminiscent to inline onclicks and the hackish approach to apps from yesteryear.
onclick="doSomething()" versus ng-click="controller.doSomething()"
Sure, there's a lot more under the hood with Angular but it looks and feels similarly and it scares some people away toward other approaches.
JS used to have a lot of inline code back in the day. Then jQuery came along and devs moved their JS into separate files but everything was still tied to elements and very frail. It was terrible for apps of any complexity. Now we have a ton of options and there is no consensus. However, maintainability is easier and building robust front-ends that don't break when someone moves a div or renames a class is not difficult anymore.
Angular is my favorite but I'm also liking what I'm seeing from Vue for a lot of applications.
We can point our UX designer at this separate file and he can understand it, which would not be the case if it's buried in JS?
A component model is great though. Wicket is the library that gets it. Whenever I write Angular (or Django, or anything) I wish I was writing Wicket.
And React doesn't use HTML either. It uses function calls that can be made to look kinda like XML by using a transpiler.
Neither puts HTML in JS or JS in HTML because neither actually uses HTML. Both build a virtual DOM: React does it explicitly with nested function calls, Angular does it implicitly using flat pseudo-HTML templates as strings.
React is really just a DSL for components that looks kinda like XML but if you consider React Native it is apparent that being able to render those components to HTML (on the server) or to the DOM is just an implementation detail of the renderer (i.e. ReactDOM, React Native, React Windows, WebGL, etc).
One thing I think will be a great push for Angular2 is Ionic2 which alone is reason enough but to be honest I prefer the `Aurelia way` when it comes to writing web apps which sounds more natural, Sad to see Aurelia hype haven't took much so far (understandable that it's getting harder to get people on board a new `revolutionary` JS framework).
"This is the first release candidate that contains repackaging of Angular into individual packages one per each feature area. ... This changes how Angular is installed via npm and how you import the code"
This seems like a pretty big change to include as part of the first RC??
I am honestly intrigued as to what Angular2 offers, that other JS frameworks wont?
In my point of view react is easier to use while angular is better for testing.
My personal choice is angular. I'm really excited for v2. But both are super powerful.
I don't really think angular and React are direct competitors.
If your Angular 1 code is working well, doing any of the above would be stupid.
As far as I'm concerned, new JS frameworks are options for new projects, not existing ones.
So what is the concrete difference between an API + a node-js server to serve assets and render templates server-side (so with a lot of business logic) + an angular2 client written in typescript , all this VS something like Rich Faces or Prime Faces in a servlet container ? We just rebuild the exact same thing that is hated by most "modern developers", with worse tooling on top of it. Both solutions need a third party language that is not Javascript, both solutions need a compilation step, and command line tools(or an IDE in the case of Java).
Some will say "Well, now the client and server are independent, and if the server changes, one can keep the fat client". But in practice, which side gets rewritten ? the server or the client with the "framework du jour" ?
I admit I've been a bit nervous about angular-cli calling itself still in alpha - probably a good time to take a look at it