4 ms·
I agree with just about everything in the post, but: > I think the fact that the Angular community has made real progress towards divorcing themselves from jQu
by lerouxb 13y ago
I agree with just about everything in the post, but:
> I think the fact that the Angular community has made real progress towards divorcing themselves from jQuery is one of the most encouraging signs for their future. The design of Angular is just different enough, and it is just compelling enough, that it has convinced a whole range of developers to build a new generation of libraries that I suspect are more likely to be suited to whatever the next iteration of the web as a platform will look like.
This part bothered me a bit. The article doesn't make the case for why jQuery needs replacing or why all that duplicate effort is a good thing. Don't get me wrong: I'm not married to jQuery and I'm open to the idea of there being a better way.
I just don't find the idea that we have to move away from jQuery that self-evident.
- Bahamut 13y agoPerformance is a big one for many. There are also some patterns that developers using jQuery tend to adopt that has performance ramifications, such as use of global DOM selectors like $('.foo').
- camus2 13y ago> Performance is a big one for many. Given how poor Angularjs performs that's not really the point of Angular. > such as use of global DOM selectors like $('.foo'). Which is perfectly valid especially when doing event delegation. The point of Angular is not to replace jQuery,the point of Angular is to have a clean way to integrate DOM manipulation into pages that have a complex application logic. Something devs should do with or without AngularJS,just that Angular forces (some) S.O.C.* But one still does DOM manipulation in directives. with jQLite BUNDLED with Angular. AngularJS is no magics ,AngularJS has its own limited jQuery. Makes sense because the unique point of jQuery is DOM manipulation,not building applications with complex logic. So people saying "I replaced this fairly large jQuery app with AngularJS" are lying, You cant write a "fairly large app" just with jQuery,You need to roll your own framework on top of it, at least. * : My advice to anyone jumping in the next framework bandwagon is never couple your application logic to any framework. But that's what we see with AngularJS, everything in controllers or services tied to AngularJS apis... so much for separation of concerns...
- singingfish 13y ago> But that's what we see with AngularJS, everything in controllers or services tied to AngularJS apis... so much for separation of concerns... The web is a complex beast. Front ends doubly so. The idea here is to keep your web based interactions as thin as possible and keep all of the logic in the business logic models. Combine with dumb templates and you have stuff that will scale out or up fine, given the availability of appropriate processing power on the client end.
- Bahamut 13y agoNot sure about what you mean about how poor Angular performs - Angular performs pretty well, unless you're naively doing inefficient things. I've written some medium sized Angular apps that are pretty performant.
- lerouxb 13y ago> unless you're naively doing inefficient things This counts for anything including your original jquery example.
- batoure 13y ago>I just don't find the idea that we have to move away from jQuery that self-evident. I think that there are always arguments made like this with any language/framework and the endgame comes down to where there is a use case there is a will. I recently participated in do a full webapp conversion from jquery to angular. One driver was a realization that jquery and related tools filled quite a bit of bulk in the platform(cutting them out the minified js ended up being 1/5th the original size). Another was a conscious decision to rebuild API first and angular provided a unique ability to very cleanly abstract a View/Service/Server type of architecture that has just never worked for us in Jquery. Plenty of people will continue to use JQuery just as plenty of people continue to develop in Perl despite other communities feelings that it does't fit their use case.
- lerouxb 13y agoHold on. I'm not talking in a "Angular vs jQuery" way. I meant "Angular vs something like Backbone that just happens to use jQuery". I wouldn't build a large app straight on top of jQuery ;)
- batoure 13y agoSee how quickly careless words can brand you as a sadistic maniac :) !!
- batoure 13y agoBut seriously not to answer a question with a question, though I am going to... but maybe the better question is "why do frameworks like Backbone need to use jQuery?" Base angular is incredibly compact and I have yet to really run into a wall with it compared to projects we have tried to do in Backbone (that sounds like we have had problems in backbone we haven't I am just saying the experience is comparable). It seems to me like the best reason to keep jQuery in something like Backbone is to make it easier to integrate existing jQuery libraries... which is maybe worth reconsidering anyway.... see argument #1
- delluminatus 13y ago
- farnsworth 13y agoIt's about imperative vs declarative styles in DOM modification, animations, etc. I've been learning Angular the past few weekends, and I've come across tons of SO questions that boil down to "how do I use my familiar jQuery patterns inside Angular?" where the answers are usually "you don't, here's a better way" usually with some Angular directive which fits that pattern naturally. Also, lots of blog posts contrasting the two styles. As I've gotten comfortable with it, I've come around to seeing it their way. I'll never write jQuery-selector spaghetti code again if I can avoid it. Here's my favorite SO question on the topic: http://stackoverflow.com/questions/14994391/how-do-i-think-in-angularjs-if-i-have-a-jquery-background http://stackoverflow.com/questions/14994391/how-do-i-think-i...
- lerouxb 13y agoI hear you and I don't disagree with you. I just freak out when I open a console and $ doesn't exist :)
- pablobaz 13y agoFirebug has a $ built in just for debugging.
- ssmoot 13y ago> It's about imperative vs declarative styles in DOM modification, animations, etc. I don't understand. I mean, Angular doesn't seem any more "declarative" than the Behavior.js you could write 7 or 8 years ago. And jQuery made setup a bit different, but you could easily still keep doing the same thing with declarative decoration. When talking about directives (specifically) Angular doesn't appear (to me) to really offer anything new outside of some questionable conventions for structure.
- bmm6o 13y agoAngular is an MVC framework, which means that your code should be updating the model and letting Angular push that to the view. A lot of the stuff you would do with jQuery is directly updating the view. So instead of writing something like: $('#whatever').addClass('selected'); // say this is in an event handler you should write: $scope.isSelected = true; // this is your ng event handler and the html is like this <div ng-class="{selected: isSelected}"> That is, you think a lot more about the model and how it's represented in the view (declarative) and less about what to do to the view to make it look the way you want (imperative). That's not to say that there's no place for jQuery in an angular app, but it does replace a lot of the typical uses. And fighting it just leads to frustration.
- jf22 13y agoI felt the same way the latest SPA projects I did jquery didn't even need to be included.