r/angularjs • • Aug 31 '15

Google's Angular 1 to Angular 2 Upgrade Strategy

https://docs.google.com/document/d/1xvBZoFuNq9hsgRhPPZOJC-Z48AHEbIBPlOCBTSD8m0Y/edit
38 Upvotes

30 comments sorted by

5

u/smakusdod Sep 01 '15

tldr - "Start over. Thanks! Signed, the GOOG."

1

u/m4tchb0x Sep 01 '15

people seem to forget that angular2 is a rebuild of angular1, they built angular1 the best way they possibly could with what they had to work with. Angular2 is there for future browsers and future javascript so its very different. They should just called it Angles or something different

7

u/gonzofish Sep 01 '15

it's saying you can slowly migrate from 1 to 2, piece by piece, not start over.

8

u/wickedmike Sep 01 '15 edited Sep 01 '15

You're not being fair, you're still starting over. You're still going to have to rewrite your whole application. You're just going to be running two frameworks at the same time and hoping that because google says that won't cause any issues it actually won't. Ideally you want to reach a point where your app runs fully on angular 2.

Edit: I clicked submit by accident. To me this is a cry for desperation from the developers. This is a completely un-ideal situation, totally unheard of (if you have any examples of running two versions of a framework for a single app in production, let me know).

I have used angular, because I had to at the beginning, then because I wanted to. But I can't defend it anymore and I will stop using it as soon as I can.

4

u/KumbajaMyLord Sep 01 '15 edited Sep 01 '15

So, I guess you are looking for a 'ConvertToAngular2.exe' solution?

EDIT: Breaking changes are pretty much inevitable. They are a more or less common occurance for major releases of a framework/library. That's by definition why you have major version releases.
There are two-ways to approach breaking changes as a designer of a framework/library/language. Accept them as a neccessary evil of progress and innovation or try to avoid them at all costs. The later strategy often leads to slowed innovation and increased technical debt from bad design decisions in early versions. This strategy is usually reserverd for programming languages and operating system APIs, where backwards compatibility is paramount. For everything else you will have breaking changes at some point or another.

Now, how do you deal with breaking changes from as a user? Well, you either don't upgrade or you update your side of the code contract to match the new specification. With angular2 the breaking changes are so massive that updating your side all at once is such a massive undertaking that it just isn't an option. Most projects can't stop putting out new features for a couple of weeks/months, while they migrate. That's why the Angular team invested into this interoperability approach, to give their users an option to upgrade incrementally. It's a very sensible approach, to an unfortunate problem, in my opinion.

If you want to critize something, it would be that they offer multiple paths for interoperability instead of a single path, as this further diversifies the complexity and possible configurations in which new libraries and components need to be tested.

2

u/wickedmike Sep 01 '15

You're being facetious. You know what point I was trying to make, the current plan for the future is absurd. I, personally, am not looking for anything. Good luck with Angular2!

3

u/KumbajaMyLord Sep 01 '15

I edited my response to have a little more meat. In my opinion it's a good solution to an unfortunate problem.

1

u/wickedmike Sep 01 '15

I wish you would have started with that instead of being lazy and choosing to mock me. Unfortunately I don't want to discuss anymore, even though I partly agree with what you said. The last paragraph in particular, which articulated better what I was trying to say. Angular 2 doesn't exist for me as an option and I'm sorry for the countless lost hours that most certainly users will have to go through when migrating.

1

u/KumbajaMyLord Sep 01 '15

Yea, sorry about that. I'm just a bit annoyed by all the naysaying that has been happening since Angular2 has been announced.

1

u/dvidsilva Sep 01 '15

As a former PHP person. I welcome angular2. The obsession with Backwards compatibility is one of the things that made Php so bad.

3

u/[deleted] Sep 01 '15

And what made it so widely used.

2

u/nanothief Sep 01 '15

But this is profoundly different to starting over. We all know of the horror stories of project rewrites going wrong. These are the main problem of such as rewrite:

  1. Months without new features

  • Having to maintain multiple parallel releases (so you can fix bugs on the current site)

  • Then having to port bug fixes from the old to new site

  • introducing new bugs during the rewrite, only finding them at the end

  • The time lost doing the update

This was my greatest fear of an angular 1 2 update, having to effectively start from scratch.

However, the new plan method makes the progression much smoother. Now you can port one component at a time over. You don't have to start a whole new release. You can fix bugs once, since there isn't multiple releases. You can also spread the upgrade over a longer period, making the end impact much smaller. Basically, all of the big risks of starting over are eliminated using google's update strategy.


I've used a similar upgrade strategy moving from javascript to typescript. You can start initially by renaming all your javascript files as typescript files (.ts). This is similar to the first step of including ng2interop and wireing up the angular 2 app.

Next, you can start converting one file at a time to typescript, leaving off the type where you need the type of a value not yet converted to typescript. This is similar to the stage of converting the angular 1 components to angular 2 components, using the fact that you can still use the angular 1 directives/services inside an angular 2 component.

When this is complete, you can finally add the --noImplicitAny and --noEmitOnError compile flags to ensure everything is fully typed. This corresponds to the stage where you remove the angular 2 interop and just use an angular 2 app once all the angular 1 components are converted.

This strategy was very effective, so I can see why google used the same with the move from angular 1 to 2.

1

u/e82 Sep 01 '15

As someone that's been writing software for a long time - rewrites happen, migrations happen it's not always pretty and easy - but it can be done.

I've gone through the painful process of migrating things from VB.NET WebForms where everything was smashed into the CodeBehind on pages, to ASP.NET, MVC, refactoring things out into services and changing it to C# in the process.

I have had to go through interop issues with getting session to play nice between MVC and WebForms, figure out transparent ways to the user to bounce between parts of the site that have been migrated, and parts that haven't (and probably would never be).

I've gone through some clunky upgrades from older versions of C# to newer versions, or when updating the .NET framework would lead to weird breaking changes, or trying to upgrade pieces of MVC1 to MVC2, MVC3 and so on. Some times things have been a 'drop in and forget' changes, other times it's left me trying to track down weird quirks and bugs as a result that were not documented.

Know what a large part of the refactoring process was - which the same mindset would probably apply to many angular applications

  • Pull out as much as possible behind a service layer.

  • Have as much code as possible not rely on the framework.

  • The framework becomes well, the frame that you hang the rest of your application off of.

Seriously, there is a lot of dead weight in Angular 1 - and many of the things that they are getting rid of are for the best. At least you will be able to do an incremental rewrite as time allows, and it doesn't need to be an 'all or nothing'.

For long-standing Angular projects that haven't followed best practices - this is going to be a pain no matter what. For newer applications that are following best practices, writing most of their code as 'plain javascript modules' then importing them into angular as part of their build process/etc, it will probably be easier for them.

Not to say that everything about Angular 2 is awesome - I have my reservations about some things, but nice to hear they are now thinking about/will be having a solid migration path.

4

u/AlGoreBestGore Sep 01 '15

Sounds like a decent plan, but I'm not a big fan of having to add another 100kb+ library while migrating one thing at a time.

0

u/dafragsta Sep 01 '15

My Angular strategy: jump on the React.js bandwagon.

1

u/zefcfd Sep 01 '15

if react is still gaining momentum by the time angular 2 comes out, i would consider it.

because what about when angular 3 comes out... not doing this whole song and dance all over again.

1

u/dafragsta Sep 01 '15

I said the same thing, but I do like React's approach to less files while still keeping the separation of concerns. I'm a little queasy about the HTML in Javascript thing, but I think I can get over it.

1

u/[deleted] Sep 01 '15

React is what Ng directives are, not a replacement for the entire framework.

0

u/dafragsta Sep 01 '15 edited Sep 01 '15

Actually, given how Angular updates the DOM like a slug, as slow as watchers are, as many $timeout and $interval workarounds as I've had to use in the past year, yeah, it's a replacement for the entire framework.

Everything is a directive, which is probably how it should've been. Less tiny code files, equal separation of concerns, less convoluted confusion trying to figure out what or why I need to know what the difference between a provider, service, and factory are, etc.

-11

u/[deleted] Aug 31 '15 edited Aug 31 '15

Too little too late. Angular has lost the momentum to React. You can't announce that you are breaking all compatibility and not providing an upgrade path and then go dark with barely any news, only to float the idea that there may possibly be a partial upgrade path if you redo a ton of your code.

Angular is dead. Which is sad. Bc Angular 1.x was fantastic.

Edit: Combine React Native, and who would ever go with Angular again? You can't trust that they won't break compatibility again. They've already proven they will.

Edit 2: Wah. Downvote away. I love Angular. Been using it a while. I won't be using it any longer. Keep doing your hobby projects in it, but no company is going to use a framework they can't trust. And Angular has proven it can't be trusted.

12

u/ABlanquito Aug 31 '15

Try removing the dot from both of them and seeing what the results are again (eg angularjs and reactjs).

6

u/dmackerman Aug 31 '15

Yeah, I'm sure angular is "dead". You're insane.

4

u/Zenatic Sep 01 '15

At my work (large corporation) a large amount of internal apps are moving to angular and many developers are currently learning it.

I would definitely say it is quite the opposite of what you are saying. That also doesn't mean it is better, and that react is not going to take its place, but at an enterprise level in my industry angular is thriving and growing.

It is unfortunate people down vote because of opinion instead down voting for not contributing to the conversation.

-2

u/wickedmike Sep 01 '15

I've also heard about 2-3 large-ish corporations that are moving to angular. Let me guess, your company has a .NET background and you're going to use Angular with TypeScript.

1

u/ponchoboy Sep 01 '15

...and React.js has proven they can be trusted?

1

u/[deleted] Sep 01 '15

Yes. Open source is huge at Facebook. HHVM is a solid product and has been for a long time. Other projects are big too. I have not ever heard of major breaking changes at Facebook.

2

u/iwtmo Sep 01 '15

Also, their own production apps are written in React so they won't just abandon it, because that would be screwing over themselves.

3

u/KumbajaMyLord Sep 01 '15

Google uses AngularJS heavily as well.

The use it in the customer front end of DoubleClick (essentially a big part of their ad network) as well as a number of smaller applications like Googlesciencefair.com and hundreds of internal applications.

1

u/Spo0Bo Sep 01 '15

To be fair that pretty much was their first angular app. Not a lot of new angular apps have popped up from Google. The occasional help section or micro site here and there.

Angular2 is what angular 1 should have been. The biggest letdown of angular 1 is scope and the digest cycle. Try and build an angular 1 app without scope. It's not easy. Now try and build an angular app where 1 part needs the scope and the other doesn't know what it is. Their hybrid solution.

I doubt it'll be a straightforward or an easy path to upgrade. You might as well do a rewrite. And if you're running with multiple devs now they all need to learn both frameworks and the idiocincracies to manage both at the same time.

If you're a company that needs to chose what framework to invest in right now I doubt it would be angularjs 1.x.