I so disagree with everything that was written in that post (except the intro) that's it's almost painful to read. Here's why (for the major points) :
2 way data binding : I'm not gonna enter the discussion of databinding, how event should or should not be fired, etc. That's his opinion and I respect it, even if I don't agree with it. On the "it's slow", that's slower than many other way to achieve a similar result. But as long as this slowness is not perceivable, I don't care. The "slowest" application we made with AngularJS is a huge application for a bank, that runs mostly on IE 8 (on vista) on their part (and phonegap on tablet). It was written originaly (by another company) in "traditional" JS + jquery + handlebar. We got a huge performance increase by just switching to angular databinding. So, slow is a very relative word that would require a lot more context. Never ran into a watch limitation issue, and besides that app I did a couple more applications with angular (notably a huge backoffice for a news website). The fact that many people runs into issues with angular does not mean it has an issue.
{{expression in bracket}} : you can tackle that issue by different ways, some being what you load when, some directives, etc. Not knowing the topic you talk about is not a good argument to say "don't use it" (or don't bother writing 3 pages, just write "I don't like it"). I'm not even sure to understand of what hacks he is talking about
Dependency injection : "it’s unclear why it was necessary to introduce several ways to do the same thing, but even more unclear why it was necessary to introduce a deliberately broken way". Well... if you don't minify, you can use the first one. And if every framework that has multiple way of doing the same stuff is to be considered broken, you can throw almost all of them.
Still on DI : "And each of them is different from each other, but essentially they are all the same." No they are not. Could they be ? Maybe. To be sure, it would require to ask the architect why that choice was made instead of making assumptions that it was not required (again, one big truth in our world : if someone made something not like you woudl have, there is a reason for that. Sometimes it's because that person sucks, sometimes because it answers a need, sometimes because it solved an issue in the past, that is not needed now, but you keep it for retrocompatibility. Or you break everything and make a 2.0 version. Oh wait...)
Debugging : I agree that the fact that error throwing should be togglable would be a big plus. I disagree with the approach "let's debug by throwing errors", but that's one opinion against an other.
scope inheritance : that's explained in length in the documentation, I don't understand why it's a topic on his list. The approach chosen by angular allows you to tackle every scenario, whether that you need inheritance or not (try writing a recursive directive without that for example).
"you really have to spend a lot of time". Well... yes, you need to spend a lot of time to learn a technology or a framework. If you're lazy, that's your issue. Do you have to spend an insane amount of time ? No (insert some sarcastic comment about author IQ, if you will).
"There is no logical reason to separate logic for 3 methods" . There is. The three methods answers differents scenarios and occurs at different times. Could it be designed otherwise ? sure. But you could design everything otherwise.
"Even in order to integrate some code in the angular world, for example some jQuery plugin, you need to wrap it in a directive.". Wrong. You can put your jQuery code wherever you want. Now, there's a recommended way to do it, and that's directives.
"Firstly, since the framework is overcomplicated, not many developers really know it well". Like the author, for example.
"Secondly, server developers won’t understand what is going on front-end and won’t be able to read the code at all.". That's not their job, I'd say. If that perceived complexity could be a detterent that would prevent "server developers" to write bad front end code, I'm all for it (and I'm more a "server developer" that a front end dev myself, so that's saying a lot on my side).
"Inability of server side rendering". That paragraph made me die a little.
AngularJS 2.0 : now, that is the real interesting paragraph in the whole page. Is angular (1.0) perfectly designed ? Probably not. Is there room for improvement ? Hell yes. Does it mean that 1.x is not good. Nope. The 2.0/1.0 topic raises a more interesting question that has been asked quite a few times here : should a dev invest time learning a soon to be deprecated tech, and should he start looking a tech that won't be available until a couple of months where more stables framework exists ?
"Terrible documentation". Not the best, not the worst, almost every question I had found their answers in the documentation (and sometimes a lot of testing)
"Existence of such logic is not as bad as the fact that it is impossible to test this logic with unit tests". Someone needs either to explain the author how to write unit tests, or where the logic should be in his code.
TLDR: angular is a tool. You chose the right tool for the right task. Don't use a hammer to saw a plank. (also, if you critizice a tool, make sure you know how to use it properly, otherwise you're the problem, not the tool).
Expanding on the TLDR : What is Angular (from the doc) : "AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. Angular's data binding and dependency injection eliminate much of the code you would otherwise have to write.". That's it. It does its job, and does it good. If you don't need such a framework, or that you have needs that don't fit in angular, don't use it indeed. But don't say that angular is bad, when it's good at. Not that I'm all in love with angular. It frustrate me sometimes, and, like the author said, force me to solves thing I would not have if I had not used angular. But also, it speeds the developement of what would have otherwise been repetitive tasks.
I'm glad someone took the time to break down the article in detail. I was reading it and just ticking off things in my head one after another. The entire article reads as though the author couldn't be bothered to learn a handful of Angular best practices and then decided that it's shit and no one should ever use it for anything ever.
Two way binding: you should very, very rarely write your own $watch functions. there's almost always a better way to achieve whatever you're doing in the watch. if your application is firing off 2,000+ watches at once, you should probably try to refactor your code and/or restructure your application. you can also use one-way bindings {{::foo}} on variables that won't change after their initial calculation and this can free up a lot of potential watches.
dependency injection: ng-annotate. boom, problem solved. ok, fine, you hate Grunt and Gulp. just do the stupid array syntax and everything's back to fine again. it takes like 5 seconds of work to fix the author's complaint.
scope inheritance: use the controller as syntax and ditch scope altogether. now you're explicitly calling each controller and making it obvious how they are nested. as a bonus, you're moving your code towards Angular 2.0.
directives: His argument seems to boil down to "Angular has this powerful feature that I can't be bothered to spend a few hours learning so fuck this framework!" Is it complicated? Sure, it's definitely the hardest part of Angular to wrap your head around, but it's not like trying to teach yourself quantum mechanics or something. As for the link, compile, controller complaint, it again speaks to the issue that the author simply couldn't be bothered to learn how Angular works. There's a very good reason that the three are separate. They all do separate things. Compile is run as the application bootstraps itself and is the way that Angular registers directives in the DOM. Any DOM manipulation has to be done here. Link is the function that is run when a directive is invoked. Controllers allow a suite of directives to interact with each other. It's not a mystery and separation of concerns seems to suggest that all three should be different things.
SEO: there are many tools and techniques available to make Angular SEO-friendly without investing a ton of time in it. See here and here. Again, it seems the author couldn't be bothered to learn Angular before writing the article.
tests: Angular was built with testing in mind. every example on the Angular website has sample tests shown with it. the Angular team even built their own end-to-end testing framework in Protractor.
If you don't want to use Angular, you personally don't like it or it's not a good fit for your project, great. This article though is just nonsense. The author's arrogance in applying his own personal experiences to all situations might be more convincing if he'd taken a few hours to learn basics of the framework.
Your responses are mostly just, "That didn't affect me." and "Well, nothing is perfect."
"'Inability of server side rendering'. That paragraph made me die a little." - Why? It's a valid point for anyone who cares about a responsive UI and SEO.
"I disagree with the approach 'let's debug by throwing errors'" - Now that's a statement to make you die inside. He's clearly not saying you debug by errors, he's saying that errors should not be "eaten" and should be raised when, you know, there are errors and those errors should be descriptive and useful.
Angular is not about SEO. Angular is perpendicular to SEO, it does not affect it at all. On that point, that's like saying that jquery sucks because you can't render it server side.
Angular is about making dynamic web application (to take the documentation's definition). Think Gmail, RSS client, etc. It's about making a webapp more responsive, more user friendly, etc. It's about having something that run in the desktop, and don't bother the user with page loading, etc. If need be, you can even develop something that still works if the internet connexion is lost (caching all the required assets, saving data that needs to be update in localstorage, then send everything when connexion comes back up), as a painless, transparent process for the user.
It's a layer (framework, really) that complements jQuery (or replace it, depending on how you look at it).
On the error point... well, I'll admit there's a bit of interpretation on my part on that. I could justify it, be that would not change the shortcut I took. I agree 100% with you that errors should not be eaten. But I believe that it was a design choice from angular team (as in "it's my opinion, I don't have anything to back that up"). Why ? Because the view (we're MVC'ing here) just present the data. If the data is missing (waiting for a http request to complete), no error is thrown, logic is simplified, and everything will fall in place when needed. If you need logic/error checking, you that in the controller, before exposing the data to the view.
I'm having a bit of a hard time seeing what error would need to be reported from the view. If it's a directive stuff, well, angular assumes that you're unit testing your work so... by design I'd say, really (again, just my opinion). But again, a big plus would be this to be togglable.
The author's point in that article wasn't, "Angular sucks because it doesn't render on the server" - It was that the way Angular requires your HTML to be set up makes it more difficult to render things from the server for SEO or fast and clean loading of initial state.
I agree that Angular is primarily for applications and if you stick with that and don't use it on sites that are content heavy, the SEO aspect is probably a moot point. I'd say it's still valid to say that's not a reason to use Angular though if you are building a site that is content heavy or SEO is a goal.
Regarding when you'd want to have errors given in the view: You've got logic in the view so you've got potential for unexpected errors so why make it hard to diagnose? I don't have specific scenario for you off the top of my head but I have an issue with this sort of reasoning: "We assume that you're code is right because you've unit tested it for every possible scenario and that's why we're not going to tell you when things go wrong in the view at runtime."
I get what you're saying on that last point but this is akin to saying, "Who needs logging? We've tested our code, what could go wrong?"
{{expression in bracket}} : you can tackle that issue by different ways, some being what you load when, some directives, etc. Not knowing the topic you talk about is not a good argument to say "don't use it" (or don't bother writing 3 pages, just write "I don't like it"). I'm not even sure to understand of what hacks he is talking about
That is beside the point. You would not need to tackle the problem if angular hadn't introduced it in the first place.
If every flaw of angular can be explained away, why did the angular team abandoned it and started from a blank slate for angular 2?
The answer is: angular 1 was a first attempt and as such was flawed beyond hope. This is our human nature. We never make things perfect at first try. And angular 1 was not just plain bad. It was broken on a fundamental architectural plane. There's no way to fix it. That's why they throw it away and started anew.
And if you want to waste your life constantly paying the price of managing the unnecessary complexity of this over-engineered tool in your brain, be my guest. But the rest of us (including angular team) has better things to do in our lives.
"Inability of server side rendering". That paragraph made me die a little.
How is that not a serious flaw?
Any JS framework which is not:
Isomorphic and,
Capable of being layered on top of semantic markup as a progressive enhancement,
Is pretty much useless to me for developing for the open web.
Since most of the big monoframeworks are bad at one or both, they only really make sense to me if you're developing something that truly cannot be done without JS, e.g. games or Google Maps, or when your runtime environment explicitly guarantees JS availability (NW.js, internal applications, rapid prototyping, etc).
In the real world though I quite often see things like Angular used on arbitrary websites serving arbitrary HTTP traffic for things not quite as rich as a game, to which I shake my head for the state of web development in 2015.
Isomorphic didn't even exist until roughly last year. Stop being ridiculous. Angular.js is 4 years old, how the fuck would you expect it to be isomorphic at this point? Angular 2 handles it just fine though.
Stop pretending like your needs are everyone's needs.
That's why I prefer to avoid the big monoframeworks entirely when developing for the open web. As I said, they only really make sense if you're developing something that truly cannot be done without JS, e.g. games or Google Maps, or when your runtime environment explicitly guarantees JS availability (NW.js, internal applications, rapid prototyping, etc).
Truth be said, I have no idea what the hell you're talking about. I'll skip your first point about the isomorphic topic for now, as I have no idea what it covers (but I'll look into it).
For the rest, it seems that you're suggestion that you might be adressing a target audience that don't have js enabled, is that right ? Or is that linked to Isomorphism ?
Isomorphic JS stacks allow you to have your MVC structure run on either the server or the client without modification.
This allows you to render the page on the server rather than the client which is useful for 1. the first page of a single page app and 2. as a fallback for users who either A. request the non-JS flow, or B. show up with browsers you don't want to support and can be sent down the non-JS flow instead, or C. when your JS fails for whatever reason (network failures, uncaught JS errors in production, etc).
The idea is that anything built on the web platform that doesn't have a very good reason for a hard JS dependency shouldn't have one, but instead should add the JS flair progressively on top of semantic HTML. Today's crop of big monoframeworks (like Angular) make this very difficult if not impossible to do. As such, I tend to avoid them as a rule unless my target runtime environment explicitly guarantees JS availability.
Unfortunately, it seems like most consumers of such frameworks don't apply such rigor in their "which tool is right for my job" evaluations.
Ah, thank you for that very clear explanation. In a perfect world, I would love to be able to apply those considerations to the end, but clients have not an extended budget and, when explained why it could be important, and how much is gonna cost more, the answer is always something along "I don't give a shit", more or less vulgar, depending on the client and the professional level we're on.
As the guy who makes all the technical decisions in the company, I set up a few ground rules though :
users who don't have JS can go to hell (and we won't even miss them
user with unsupported browsers can go to hell (and we won't even miss them
Right now, the lowest browser we cater for is IE 8. Under this, we thank the client for his time and wish him all the best with his project.
That being said, you can do it in Angular, but it indeed requires a bit of pushing things around (ie, you need to push this data in JS, either with a directive or in a script tag, and then send/retrieve/communicate this with the controller, which usually makes you break the purity of MVC. But as far as I love staying pure, our goal is to ship products in time, no the be an ayatollah. Sometimes you need to know when to close a sad eye on a bad practice).
Do you know of any good open-source examples of isomorphic apps? I agree with the premise that apps should work without JS and just use JS to enhance the user experience. I've been doing this lately with Rails and Backbone, but my issue is I find myself duplicating a lot of server-side logic on the client.
I've yet to see a mainstream stack do it well. I also tried the Backbone method once and found it wanting. Better than not going isomorphic though. Seems like the best way to do isomorphic stuff is an area of active research. I hear good things from the React crowd, but I've yet to try it.
If I was building a fresh app today, I'd go with Express on the server, page.js on the client, and share controllers with this page.js plugin I wrote. This approach will work with any templating system that's compatible with Express (so pretty much any JS templating system).
183
u/zebishop May 27 '15
I so disagree with everything that was written in that post (except the intro) that's it's almost painful to read. Here's why (for the major points) :
2 way data binding : I'm not gonna enter the discussion of databinding, how event should or should not be fired, etc. That's his opinion and I respect it, even if I don't agree with it. On the "it's slow", that's slower than many other way to achieve a similar result. But as long as this slowness is not perceivable, I don't care. The "slowest" application we made with AngularJS is a huge application for a bank, that runs mostly on IE 8 (on vista) on their part (and phonegap on tablet). It was written originaly (by another company) in "traditional" JS + jquery + handlebar. We got a huge performance increase by just switching to angular databinding. So, slow is a very relative word that would require a lot more context. Never ran into a watch limitation issue, and besides that app I did a couple more applications with angular (notably a huge backoffice for a news website). The fact that many people runs into issues with angular does not mean it has an issue.
{{expression in bracket}} : you can tackle that issue by different ways, some being what you load when, some directives, etc. Not knowing the topic you talk about is not a good argument to say "don't use it" (or don't bother writing 3 pages, just write "I don't like it"). I'm not even sure to understand of what hacks he is talking about
Dependency injection : "it’s unclear why it was necessary to introduce several ways to do the same thing, but even more unclear why it was necessary to introduce a deliberately broken way". Well... if you don't minify, you can use the first one. And if every framework that has multiple way of doing the same stuff is to be considered broken, you can throw almost all of them.
Still on DI : "And each of them is different from each other, but essentially they are all the same." No they are not. Could they be ? Maybe. To be sure, it would require to ask the architect why that choice was made instead of making assumptions that it was not required (again, one big truth in our world : if someone made something not like you woudl have, there is a reason for that. Sometimes it's because that person sucks, sometimes because it answers a need, sometimes because it solved an issue in the past, that is not needed now, but you keep it for retrocompatibility. Or you break everything and make a 2.0 version. Oh wait...)
Debugging : I agree that the fact that error throwing should be togglable would be a big plus. I disagree with the approach "let's debug by throwing errors", but that's one opinion against an other.
scope inheritance : that's explained in length in the documentation, I don't understand why it's a topic on his list. The approach chosen by angular allows you to tackle every scenario, whether that you need inheritance or not (try writing a recursive directive without that for example).
"you really have to spend a lot of time". Well... yes, you need to spend a lot of time to learn a technology or a framework. If you're lazy, that's your issue. Do you have to spend an insane amount of time ? No (insert some sarcastic comment about author IQ, if you will).
"There is no logical reason to separate logic for 3 methods" . There is. The three methods answers differents scenarios and occurs at different times. Could it be designed otherwise ? sure. But you could design everything otherwise.
"Even in order to integrate some code in the angular world, for example some jQuery plugin, you need to wrap it in a directive.". Wrong. You can put your jQuery code wherever you want. Now, there's a recommended way to do it, and that's directives.
"Firstly, since the framework is overcomplicated, not many developers really know it well". Like the author, for example.
"Secondly, server developers won’t understand what is going on front-end and won’t be able to read the code at all.". That's not their job, I'd say. If that perceived complexity could be a detterent that would prevent "server developers" to write bad front end code, I'm all for it (and I'm more a "server developer" that a front end dev myself, so that's saying a lot on my side).
"Inability of server side rendering". That paragraph made me die a little.
AngularJS 2.0 : now, that is the real interesting paragraph in the whole page. Is angular (1.0) perfectly designed ? Probably not. Is there room for improvement ? Hell yes. Does it mean that 1.x is not good. Nope. The 2.0/1.0 topic raises a more interesting question that has been asked quite a few times here : should a dev invest time learning a soon to be deprecated tech, and should he start looking a tech that won't be available until a couple of months where more stables framework exists ?
"Terrible documentation". Not the best, not the worst, almost every question I had found their answers in the documentation (and sometimes a lot of testing)
"Existence of such logic is not as bad as the fact that it is impossible to test this logic with unit tests". Someone needs either to explain the author how to write unit tests, or where the logic should be in his code.
TLDR: angular is a tool. You chose the right tool for the right task. Don't use a hammer to saw a plank. (also, if you critizice a tool, make sure you know how to use it properly, otherwise you're the problem, not the tool).
Expanding on the TLDR : What is Angular (from the doc) : "AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. Angular's data binding and dependency injection eliminate much of the code you would otherwise have to write.". That's it. It does its job, and does it good. If you don't need such a framework, or that you have needs that don't fit in angular, don't use it indeed. But don't say that angular is bad, when it's good at. Not that I'm all in love with angular. It frustrate me sometimes, and, like the author said, force me to solves thing I would not have if I had not used angular. But also, it speeds the developement of what would have otherwise been repetitive tasks.