Live data from Hacker News

React vs. Angular 2

docs.google.com

31–40 of 87 posts

Re: React vs. Angular 2

#31

Earlier quoted context omitted.

> because anyone who really wants to hop on the FRP bandwagon will pick up something like http://elm-lang.org Elm is awesome, but also look into Cycle[1]. [1] http://cycle.js.org

When evaluating techs to make our frontend evolve, I looked at cycle. It seems genuinely interesting, and much more FRP than React+Flux, but it doesn't seem to have a lot of traction.

Sadly you are right. I think it got sandwiched under React/Redux.

That said, it does raise very interesting ideas about writing web apps so it's worth a look at least just for fun.

Re: React vs. Angular 2

#32
post #19

Earlier quoted context omitted.

> React will stick around because it's backed by Facebook and if Facebook says this is the way to go with front-end development then that is all the convincing most folks need. Not just that. Facebook uses it for their flagship website (and as React Native for their mobile apps). So does Instagram. So does Netflix. If you have the React developer tools installed you can literally go to facebook.com or netflix.com and…

> Google (who is backing Angular) doesn't have nearly as much skin in the game as Facebook (who is backing React). Excellent point. Here's another "smell" with angular: http://angularjs.org versus https://angular.io/ . The former is AngularJS 2.0 and the latter is AngularJS 1.0... they maintain two websites for two versions of the same framework. It boggles my mind. Who thought it would be a good idea to separate ver…

The reason is because Angular 2 merges Angular Dart and AngularJS into one framework.

Can't say I have first hand knowledge, but I have heard that Angular dominates internally at Google.

UI Bootstrap is also separate from Angular (if that is what is meant by quick-and-dirty bootstrap site) - I am currently the lead developer of the project, and not once in my tenure have I deleted any comments, and I know of no instance since I joined in March this year of anyone doing so. The documentation certainly can use work, but we are unfortunately strapped for resources with not much quality work coming from outside the team. File issues if you have problems, but otherwise, I can only say that usually the team responds correctly, and it is usually immaturity on the reporters' side that is the issue we have observed.

Re: React vs. Angular 2

#33
post #20
post #5

Earlier quoted context omitted.

Honestly? I would start with React. The way Angular 2 has been going, they are adopting a lot of new ideas from React.

The team I'm apart of started a project 2 months ago. We chose React and Redux over Ember, Angular, et al. A main decision factor was that we needed the server to render our initial HTML, neither Angular nor Ember can achieve this easily, we'd most likely have to lean on a third-party service. Angular looked particularly unattractive with Angular 1 being as good as dead and we didn't feel confident starting with Angu…

The problem is that the surface of Angular is incredibly complex.

With React, you have components, which are just things (classes or functions) that convert a set of properties to a subtree of more components (ideally mostly ones that directly represent DOM elements) and do so deterministically and reproducibly.

With Redux you just have objects ("actions") representing changes to your application state and functions ("reducers") that convert an action and the current state into the future state. There are also functions ("action creators") that help you create the former and functions ("middleware") that affect how Redux processes them.

With Angular1 you have templates and directives and components and models and scopes and controllers and filters and injectors and services. And services can be constructors or factories or providers or values or constants or decorators. And scopes can be isolate or nested and there is the digest cycle and there are watch functions and if you do anything async outside of Angular you need to make sure to trigger the digest cycle (but not if you're already in the digest cycle) and I haven't even talked about interpolation yet.

Angular2 is slightly better but the docs are pretty sparse and many people's brains will still shut off as soon as they hear "dependency injection" and have you fucking seen what they have done to HTML to maintain their false illusion of "it's just HTML and JavaScript, designers can understand this"?

React doesn't need you to think. Initially the API made you define components by using a magical function, then they extended it to allow just using ES2015 classes, now you can even define simple components as plain old functions. The surface has shifted from minimal to nearly non-existent.

Redux has more conceptual overhead than React ("Wait, reducers can't have side-effects? Where does my AJAX go?") but most of the learning time is spent un-learning concepts you take for granted (e.g. you shouldn't mutate state, your components should ideally not have any state at all and it's perfectly fine to normalize your state because you only need to derive it when it actually changes). The number of actual concepts Redux brings to the table is fairly low.

Angular is a battleship. React+Redux is an attack submarine.

Re: React vs. Angular 2

#34

What is this FRP thing JS developers talking about? What I should read to learn more about it?

A small part of it is that your events are basically constant streams of data (think arrays) you can map, reduce, and filter (among other functions) and then present. Here is a short article on it:

https://medium.com/@andrestaltz/2-minute-introduction-to-rx-...

This is a discussion over the controversy of calling stuff FRP in academia vs. real world:

https://medium.com/@andrestaltz/why-i-cannot-say-frp-but-i-j...

Re: React vs. Angular 2

#35
Two corrections:

1. You can use types with React, either via Flow or in TypeScript with TSX. Unlike with Angular, with React you can also get type checking even in the JSX template (checking for valid component property types included, even with TypeScript)

2. You can "externalise" your render method if you really want to by simply writing

  import MyComponentTemplate from './external-template.tsx'


  let MyComponent = React.createClass({
    ..
    render: MyComponentTemplate
    ..
  })
then in external-template.tsx

  export default function render() {
    return ....
  }
Most React users think its unnecessary, but it doesn't mean its not possible.

Re: React vs. Angular 2

#36
post #5

Earlier quoted context omitted.

Honestly? I would start with React. The way Angular 2 has been going, they are adopting a lot of new ideas from React.

But what about angular being a framework and react being a library? Ido hate to invest time in react only to find out that when working on some project it doesn't provide all I need. By project I mean some backend api and front end SPA

That's fallacious reasoning.

React is less full-featured than Angular is less full-featured than ExtJS and so on.

You're not going to use a single tool to build your project. You're almost guaranteed to using different tools to build your frontend and backend (even if some of the tools may be the same or some of the code may be shared). You're extremely likely to use more than one tool for either of them.

Nothing will "provide all [you] need". If it did, it wouldn't be a library or framework, it would already be the finished product you're trying to build.

React does one specific thing and it does it incredibly well. If that thing is what you need: great, you can use React as one of the tools to build your product. If it's not what you need: don't use it. You shouldn't worry about whether something provides everything you need, you should worry about whether what it provides is actually what you need or not.

Angular does a lot more things than React does. Logically that means it's less likely to be a perfect fit for your project. You're more likely to find out that it does something in a way that doesn't work for you, simply because there are more things it does. But it may also do enough things in just the way you need them to be done to be worth the few places where it doesn't fit your project perfectly.

It's always a compromise. Unless you have unlimited time and can develop the perfect tools yourself, you're going to have to make a few sacrifices along the way.

Re: React vs. Angular 2

#37
post #12

Earlier quoted context omitted.

I, myself, tried to learn it by generating a sample project with Yeoman. Only to find myself in a project where so many things were already done for me that I couldn't make sense of all the pieces that allowed it to work correctly. I would make a couple of changes and if one of them broke something, I was not able to quickly identify what I had done that was a problem. I'd recommend that you go step by step a build a…

I've had exactly the same experience. I tried bootstrap generators like yeoman, cloned "starter kit" repositories, etc... And they would all have ~1 kilolines of code and a bunch of dependencies. If I tried to do anything (like, say, add react-bootstrap), everything would stop working. The best way is to follow a tutorial and build a small project from the ground up. Stay away from prefabricated solutions until you u…

IMO, if you need to generate a lot of boilerplate code for your React app, the app is likely incredibly boring and generic, or your code is unnecessarily bloated, or both.

Re: React vs. Angular 2

#38

For someone who hasn't had to do much work on the front end JS technologies like Ember, Angular, React, etc. What is a good resource to start learning Angular 2 (even though its not out yet)? I came across ng-book2 [0] but I've heard mixed reviews about their first book. [0] https://www.ng-book.com/2/

You can learn some meteor and angular 2 at the same time:

http://www.angular-meteor.com/tutorials/socially/angular2/bo...

I enjoyed the meteor angular 1 version and plan on doing the angular 2 version soon.

Re: React vs. Angular 2

#39
post #5

Earlier quoted context omitted.

Honestly? I would start with React. The way Angular 2 has been going, they are adopting a lot of new ideas from React.

But what about angular being a framework and react being a library? Ido hate to invest time in react only to find out that when working on some project it doesn't provide all I need. By project I mean some backend api and front end SPA

If it doesn't provide all you need then it's easy to involve other non-React code to make it all work. That's what's so great about it being a library - you're free to implement whatever pattern you'd like around it. For me, that's Flux/Redux (I use actions to call to well defined services) but it really doesn't matter.

I think there's a list somewhere of patterns that are difficult / non-ideal for React but I don't have it in front of me. For 99% of use cases React really isn't going to be a detrimental choice as long as you choose a good pattern to surround it with.

Re: React vs. Angular 2

#40
post #37
post #12

Earlier quoted context omitted.

I've had exactly the same experience. I tried bootstrap generators like yeoman, cloned "starter kit" repositories, etc... And they would all have ~1 kilolines of code and a bunch of dependencies. If I tried to do anything (like, say, add react-bootstrap), everything would stop working. The best way is to follow a tutorial and build a small project from the ground up. Stay away from prefabricated solutions until you u…

IMO, if you need to generate a lot of boilerplate code for your React app, the app is likely incredibly boring and generic, or your code is unnecessarily bloated, or both.

It's not just boilerplate code. It's choosing your build system, your hot-reload plugin, whether you want to use jsx or something else, whether you want isomorphic rendering (so that the server will render the initial state of the page, instead of delivering a blank page with a tag), etc.
Post reply on HN