4 ms·
Code and knowledge are two different things. Unless you're using highly well-established APIs (such as promises), then of course, you'll have to rewrite things
by lhorie 12y ago
Code and knowledge are two different things.
Unless you're using highly well-established APIs (such as promises), then of course, you'll have to rewrite things to match the new expected syntax.
Portability of knowledge is a different beast. For example, the vast majority of ng-repeat related concepts is completely non-portable (think `ng-repeat-start`, `track by`, `(x, y) in foo`, `$index`, etc). You learn that `ng-repeat="x in foo | filter: bar"` is equivalent to a for loop that displays only some items, but you can't really apply that knowledge anywhere outside of Angular.
You can't reuse your basic knowledge of for loops and if statements coming into Angular, and you can't use your knowledge about the pipe syntax anywhere else when you leave Angular.
In contrast, a framework that employs `.map` and `.filter` might teach you a bit about FP, and this is something you can use in Angular, Ember, React, and even vanilla js.
- jhall1468 12y agoYou are moving goal posts. You are arguing that syntax equals mobility which is incorrect. .map and .filter can have different syntax depending on the language, just as ng-repeat (the equivalent to a for loop) has a different syntax than a for loop in Perl. Knowledge and syntax are two different things as well.
- lhorie 12y ago> You are arguing that syntax equals mobility which is incorrect No, I'm saying that the knowledge of the concepts of map and filter (as an example) is easily transferable even if syntax isn't. Once you understand those concepts, you can go look up the Ruby/Haskell/whatever syntax and you can reuse your new knowledge of higher order functions, and maybe learn about transducers, or maybe you can go look into point-free style, and the testability benefits of pure functions vs procedural style, etc, etc, etc. Not to mention that by knowing `.map`, you already know a great deal about the template languages for React, Mithril and Mercury. In contrast, say I've learned about pipe operator precedence in ng-repeat expression clauses. Now I know I can write `x in (foo = (bar | filter: baz))` to memoize a filtered list for use later in that template. But only in Angular template expressions. But not in Javascript. Or Ruby. Or Haskell. And it's a terrible idiom to use in Angular anyways because [insert long rant about a bunch of unrelated topics]. Aside from the knowledge that operators can be recursively composed into god-awful expressions, what part of all that is useful if I migrate to Ember? Or, say I learn about directives, and transclusion and the ngModel attribute micro language, and $compile and priority and the ngModelController API and ... These are most certainly not syntax-related concepts. What does learning that get me?
- Bahamut 12y agoThat is a fairly edge/small point - using something like `.map` and `.filter` to generate the DOM itself is pretty ugly, and those functions quickly become useful in other contexts.
- deckiedan 12y agoCheck out Mithril: http://lhorie.github.io/mithril/ http://lhorie.github.io/mithril/ Using the regular syntax isn't actually that bad. It's unusual, certainly, but compared to HTML (when you actually think about it, rather than just say, "It's different and I don't like it"), it's alright. Also, as a framework, it's got a lot less magic than Angular, and lets you write javascript code that's much more like normal JS code than angular does. (IMHO). Also, the articles by the Mithril main author about JS & development philosophy are really good. I really like his style and approach to front-end development.