Wednesday, January 7, 2015

How I learned to stop worrying and love the ng-bomb

Angular is not Javascript.

If you start with that assertion, to accept that it looks like JS but is, in fact just a half-compiling DSL for writing web apps*, then suddenly the nitpicks that many people (including me) have against it start to sound ridiculous. 

We don't deride Clojure or Rust because they're opinionated (we don't even use that vocabulary when talking about language design, we just accept that the language is designed in the way it's designed and use it for what it's good for). We don't kvetch about how complicated Java is compared to something like Python - okay maybe we do - but there's an underlying understanding that picking a language to use on a project is always a matter of weighing a set of trade-offs.

The rage that some people feel (that I felt) about Angular, I think, comes from a set of unfulfilled expectations. If you think of Angular as a Javascript framework, then you implicitly expect to be able to write Javascript in the way you're accustomed to, but if instead you understand that Angular is just a different (but cosmetically similar) language, then that expectation goes away. When we write in a new language, we understand that it will take a shift in thinking, and that's okay.

*if you don't think it's a different language, then try explaining why it's important that $scope be named $scope specifically in the arguments list of all those controllers (it's because that function isn't itself being evaluated - but stringified and used to generate a new, more sophisticated JS construct from the Angular code you wrote, and if that isn't the definition of what makes two pieces of code different languages - compiling one string of characters to a different set of characters before they can be evaluated - I'm not sure what is)

No comments: