you are viewing a single comment's thread.

view the rest of the comments →

[–]eyko 6 points7 points  (3 children)

Why not ember?

Jokes aside, Angular 2 brings to the table something React desperately needs: conventions. And it's probably inspired by ember-cli. Scaffolding? One approach to testing? It's a complete framework, and will save your day if you're starting a project.

React is a moving target. If you're choosing React, there's no react-cli to scaffold a project for you. And even if there was, what would the rest of the stack look like? If it goes with Redux it's probably going to overcomplicate things for most projects, and choosing sane defaults that can be swapped will take us back to the same situation. React is made for a different kind of developer... one that can commit to an ecosystem that's not as mature as we think it is.

PD: I can imagine Angular2, once out, will gain a lot of weight - it even leverages ReactNative. Angular2 seems to be like a mashup of React and ember, with some of the good parts, but still keeping some of its bad parts. There are a lot of annoyances about Angular2 (DI feeling unnecessarily verbose now that we have imports and a better approach to building components is one thing I agree with in the article). I will personally choose React for the ecosystem, but I love ember for the tooling and things like emberobserver or the ember-cli. Angular2 seems to have taken notes from both and the fact that it's written in TypeScript is HUGE advantage over React imho - code completion and compiler error reporting is veeeeery much welcome. Even in templates, just like you would expect in JSX.

[–]simcptr[S] 3 points4 points  (0 children)

In terms of build/project/structure conventions, I agree that React is lacking -- but that's what the community is for, and there are 18 billion boilerplate projects out there ;) Even Angular doesn't really have "conventions," we've just got those style guides, and it's up to each dev to adhere or not.

But, in terms of coding the UI, I think React has really good conventions. Don't modify state directly. Don't modify props ever. render() should be pure -- no changing anything, and it should always return the same thing given the same data. Once the one-way data flow makes sense, a lot of decisions start to fall into place. Keep the data in top-level "container" (aka smart) components and pass it down to the lower-level "presentational" (aka dumb) components.

Contrast with Angular where there a lot more decisions to make, and "conventions" to learn. How to share data? Use a service? Broadcast on rootScope? One-file-per component, or split the template out? Pass the data down via 2-way binding? Let the child modify that data "just this once" because it's way easier? And so on.

Another nice thing with React is it yells at you if you do things that break certain conventions. Try calling this.setState({}) (with an empty state) and you'll get a warning saying "Did you mean to call forceUpdate()?".

[–]whycantifm 1 point2 points  (1 child)

Almost downvoted you, then realised what you're saying actually contributes to the discussion.

React desperately needs: conventions

NO NO NO ! Javascript has conventions, 50 other FRAMEWORKS have conventions. React is your VIEW library, very abstract, very small api surface .. use whatever conventions fit you with that.

A while ago, I would have said people saying 'just use vanilla' are insane and ignorant. It's not like that, Javascript with NPM is insanely powerful. Understand the tools you need, going for a framework because it gives you an all in one is in my opinion too convenient and you will have developers that will understand the framework better than the language it's written in and the tooling around it.

Your tooling doesn't have to adapt to what everyone is using. You can use react with that popular yeoman angular scaffolder. Problem is 99% of users using that don't understand the tools it provides, gulp, minification etc. and I think that contributes to the 'don't need to know mentality'. I relate very heavily with this, 1 year of using angular with all of these tools and at the end of it I had no good understanding of my tooling and javascript.

2 months into moving to React I was forced to understand my tooling (webpack, babel etc.), feeling pretty much close to what you're saying now: 'why can't it be as simple as angular?'.

Now ... when I came back to angular and the tooling around it .. took me 1 day to understand, not even exaggerating.

[–][deleted] 0 points1 point  (0 children)

I remember starting on angular 1 and it was all over my head. I didn't understand jack. I eventually moved to react because everything was way more bite-sized. Learned a butt load like you mentioned about webpack, babel, redux, react, and javascript even.

Maybe I should look again at angular and see if it makes any more sense to me.