r/programming • • Sep 15 '16

Angular 2.0.0 officially released

https://www.npmjs.com/~angular
1.3k Upvotes

535 comments sorted by

View all comments

Show parent comments

17

u/yogthos Sep 15 '16

As I went further, it got more "magic" for me, meaning there was a lot of code sugar that works behind the scene. I had to learn Angular specifically, not Javascript per se.

I think this is an extremely important point. I'd rather be learning general patterns and core concepts instead of learning a framework.

A lot of the complexity in frameworks isn't inherent to the problem they solve, it's an artifact of how it was designed and the thought process of the people who made it. You're basically learning to think about the problem the way the authors did.

In many cases though, the authors didn't really know what they were doing either, and once the framework gets into wide use a lot of problems become evident. To address these problems the framework often needs to have some serious rework done on it. So, frameworks change very quickly as seen with Angular 1 and 2. A lot of the effort you spend learning a framework ends up being of only intermittent value in the end.

1

u/Xevantus Sep 15 '16

I keep hearing this, but I had to learn way more react/redux/JSX specific ways of doing things for React than I ever had to learn for either angular 1 or 2. I find it's more of a subjective thing than an absolute. I usually see it come down to if you were already familiar with the patterns of one or the other, that one will be easier, and the other will be unnatural. I.e. ASP.net -> angular, process routing -> react.

3

u/yogthos Sep 15 '16

I don't use React directly, because I work with Reagent myself. However, there aren't a lot of concepts at all behind it.

Redux is just a pattern people like to use with React, it's not inherent to React and not necessary to use with it. JSX is just a syntax extension for writing HTML elements, and again not necessary to know or use.

How React works at its core is very clear, as is the problem it solves. For example, reading this one page explains exactly why React approach is so powerful:

Reading through the source, it may look like the entire clock component is recreated from scratch whenever the time changes.

That is an illusion: Reagent and React together makes sure that only the parts of the DOM that actually need to change are updated. For example, the column-pair function corresponding to hours only runs once every hour. And that’s what makes Reagent and React fast. Try clicking on the clock to toggle the display of 1/100th seconds. Most browsers should have no trouble at all keeping up (even if they won’t actually show every 1/100th second: they are typically limited to roughly 60 fps).

But it is a very handy illusion. Almost the entire UI is made up of pure functions, transforming immutable data into other immutable data structures. That makes them easy to reason about, and trivial to test. You don’t have to care about ”model objects”, or about how to update the DOM efficiently.

Just pass arguments to component functions, return a UI description that corresponds to those arguments, and leave it to React to actually display that UI.

1

u/Xevantus Sep 15 '16

The concept of react is simple, yes. The implementation is not by a long shot. That is, excepting the very simple applications. The thing is, react operates in the exact same way almost every other renderer does now, so purely describing what react does doesn't do anything to set it apart. Also, drawing a distinction between react and it's supporting libraries is kinda interesting to me, considering that react is pretty much useless without them. Sure there's a lot of different ones to choose from, but more choices doesn't mean better.

Also, saying JSX is not required is like saying ASPX is not required for ASP.Net (you can write it all in C#), or a compiler is not required to write a program. All of these statements are true, but I don't see many people lining up to write assembly...

→ More replies (3)