r/angularjs • u/thegraduate • Mar 08 '16
What I feel like when learning Angular after using basic jQuery for so long
18
u/tolley Mar 08 '16
Ha, yes! When I started learning angular I read that if you really want to learn angular, don't use jQuery (or anything else). I listened to that advice but as I wrote more angular code, I kept wanting to manipulate the DOM in my controller (which I kept seeing was a huge no no) and that I should use angular's templating logic. I finally just gave in and started learning more about the templating logic. Now that I'm used to it, I love it!
6
Mar 08 '16
yeah, i really had to rewire my brain for angular, but it's so much easier now! i remember the moment i finally removed the jquery dependency. i had been using it to make an ajax call and build a url, and i discovered that the ~20 lines of js around callbacks, validation, async handling and templating could be reduced to an ngBind and a single $http line in the controller. with a fucking loading gif to boot.
3
u/dethstrobe Mar 08 '16
There is some irony with Angular 1.X, using jQuery often has better performance than doing things the Angular way.
With that said dropping the jQuery mind set is going to be better for the novice who's just learning Angular in the long run.
13
Mar 08 '16
You'd be hard-pressed to actually prove that.
Angular does have some performance problems in some areas, but they're solvable these days, while also providing scalable (not performance, but organizational) and modular code.
I haven't come across a large jQuery application that I'd ever want to be a part of.
11
u/dethstrobe Mar 08 '16
I haven't come across a large jQuery application that I'd ever want to be a part of.
Agreed
4
3
u/neb636 Mar 09 '16
There are defiantly some areas when Angular falls down. I am working on a app that has a Webgl component. When rotating the model sometimes we need 50 html elements to follow around the rotating 3d model. When rotating we need to update the 50 elements position 60 times per second. We originally updated the position with idiomatic Angular but that tanked the FPS. Although we went with a raw Javascript solution using jQuery would still be much faster than triggering the digest cycle 60 times per second.
5
u/steezefries Mar 09 '16
Why would you even do that with angular in the first place though? Sounds like a job for some canvasing library or, like you went with, vanilla Javascript.
2
u/Xevantus Mar 09 '16
For control and UI components, I can see using angular. Rendering, on the other hand, yeah, no reason to render like that in angular.,
1
u/neb636 Mar 09 '16
The elements contain input boxes where the user annotations specific areas on the 3D model. Main reason I did not use the canvas for this.
1
Mar 09 '16
I have two angular + webgl project as well. One for work, and one private one for fun. I have over 30,000 objects in my scene and after optimizing the shit out of it, I never have any performance issues. If you're having trouble, it's likely not angulars fault.
1
u/superluminary Mar 10 '16
Yes, you can't run a digest cycle 60 times per second. That would be a job for some custom JavaScript.
9
u/nirgle Mar 08 '16
Wait until you get used to it and then have to work on your old jQuery code! It's like having to again walk the route you got accustomed to biking.
Ironically, huge jumps in efficiency can be demotivating. If letting Angular true up the DOM makes so much more sense than manipulating it yourself, what's the next step, and shouldn't I be spending my time looking for or developing that? Am I still wasting my time with Angular and just not understanding how? That sort of thing.
Edit: By the way, Interstellar is a great movie. Don't let me use jQuery, Murph!
9
3
Mar 09 '16
It gets easier. Then it gets harder. Then you want to say fuck it, I'm not using it. Then it gets easier again. Then the Angular codebase changes (Angular 2) and it gets harder.
Stick with it.
1
1
u/mattezell Mar 08 '16
Hahaha! Yup! It gets better... I'd spent years in jQuery before looking at AngularJS - for lack of a less cliche way to put it, it's a paradigm shift...
When initially reading up on AngularJS, I regularly found myself questioning everything... "WTF did I just read? Directive-huh? Transclusion-what?! You guys are just messing with me here, right?!"
To be honest, there was a lot that just didn't quite click until I learned a framework based on AngularJS - which is admittedly a bit bass ackwards...
For me, it was the Ionic Framework - using their directives, and at times being forced to learn more about why/how they were doing what they were doing, brought it all home via practice and repetition... Similarly, using Angular Material is tying a lot together for me currently...
2
u/Hakim_Bey Mar 09 '16
"WTF did I just read? Directive-huh? Transclusion-what?! You guys are just messing with me here, right?!"
Yeah, i hate Angular jargon with a passion. Reading a paragraph with these words just shut my brains off.
1
1
1
u/superluminary Mar 10 '16
When I was starting my jQuery to angular transition a few years back, I wrote a short book about all the things that initially confused me. If it helps you can read it here: http://nicholasjohnson.com/angular-book.
Angular is worth sticking with. Best of luck.
1
u/Suepahfly Mar 08 '16
Try react, redux and webpack in es6 on a new platform with docker images for each and every microservice on AWS with Macbook as workstation after working for years in the Microsoft landscape with visual Studio. Every feels like my head is going to explode.
2
u/compubomb Mar 09 '16
Why you gotta throw a macbook into the mix. Why not go straight up linux or windows w/ vmware + docker? Macbooks come w/ their own tax. vmware will better serve I think.
1
u/Suepahfly Mar 09 '16
It's company issued. It started two years ago when they announced building a new fully automated distribution center. It also seemed a good time to start building a new technology stack. But I've only switched a few months ago.
2
u/steezefries Mar 09 '16
I'm jealous. I wish my boss could see the benefit in a rewrite. Hopefully soon.
2
u/Suepahfly Mar 09 '16
The old code base was nearly ten years old. The company grows over time, the development team could simply not deliver requirements because of code rot and technical dept. So eventually the decision was made to go from a big monolithic application to a microservice architecture. I however remained on the team supporting the old stuff for quite sometime and just recently started working on the new stuff.
1
u/dethstrobe Mar 08 '16
But it's so much easier (and more logical) than Angular. But such a huge paradigm shift.
3
u/Suepahfly Mar 09 '16
I like React better but what little experience I have with Angular it seems easier then React.
2
u/dethstrobe Mar 09 '16
I'd very much disagree with that. The problem with Angular is that there are too many options that don't make sense. Like picking between services, providers, and factories. They all do kind of the same thing, which one do you pick for which situation?
Or why use $scope vs controllerAs, the truth is you should always use controllerAs, but a lot of examples on the web use $scope because it was around first.
There are 4 different ways to use Directives, attribute, element, class, and comment. But why would you ever want to use class or comment for directives?
And there are a lot of issues with scope conflicts when you put views inside of each other.
In comparison React/Redux/Flux is a god send. Functional components are kind of like directives but without all the nonsense. Immutable states and one way data flow and the use of props for sub components avoid all the nonsense of scoping issues. The only problem with the one way data flow is that it requires more boilerplate to do an action, but honestly small price to pay for more clarity in the mental model of data flow.
I haven't played with Angular 2 yet, so I don't know if that'll be the new hotness or if I'll still be advocating React/Redux. But right now I think React/Redux is the way to go for building webapps.
2
u/Suepahfly Mar 09 '16
Like I said I have only little experience in Angular. And most go off the code my coworkers already made. It's consistent enough that I can use it as an example for my work but I honestly don't always know what it exactly does. Good thing we have code reviews ;)
1
1
1
u/eyko Mar 09 '16
Try react, redux and webpack in es6 on a new platform with docker images for each and every microservice on AWS with...
I read that as sarcasm and I hope it was.
3
u/superluminary Mar 10 '16
When I was starting my jQuery to angular transition a few years back, I wrote a short book about all the things that initially confused me. If it helps you can read it here: http://nicholasjohnson.com/angular-book.
Angular is worth sticking with. Best of luck.