Live data from Hacker News

Facebook’s New React JavaScript Library Tutorial Rewritten in AngularJS

medium.com

11–20 of 56 posts

Re: Facebook’s New React JavaScript Library Tutorial Rewritten in AngularJS

#11
Glad to see people implementing similar projects in both frameworks so everyone can evaluate their needs.

Though, comparing code snippets to a lengthy tutorial kind of misrepresents the verbosity of React. I think we forgot to put the completed tutorial on GitHub, so here it is for an easier comparison:

https://github.com/petehunt/react-tutorial/blob/master/scrip...

Outside of standard HTML boilerplate our entire application is pretty small I think.

Re: Facebook’s New React JavaScript Library Tutorial Rewritten in AngularJS

#12

Earlier quoted context omitted.

The controller is in fact separated. The "ngController" you see referenced in the markup is the link between the view and the separate controller. Any MVC framework you could hold up as an example of proper "separation of concerns" will necessarily have the same link, even if it's implicit. Sometimes it's defined in the controller, sometimes the link is defined in the view, and sometimes you don't see it defined, but…

Right, but doing it this way means both the view and the controller know too much. Why should a view know about how it is going to be used? Also, I'm guessing if you give this to a designer his/her eyes are going to glaze over.

You don't actually ever need to explicitly specify the controller in Angular views. Usually in angular apps, the controller is specified by the routing provider (in JS), along with the view (template path).

In small examples (ie when not using angular routes) it is easier to explicitly specify the controller.

Re: Facebook’s New React JavaScript Library Tutorial Rewritten in AngularJS

#13
post #9

I'm struggling to find an advantage that React has over AngularJS. +1 for AngularJS

I agree, within the first few days of using AngularJS I immediately felt the benefits more than I did trying any of the other more popular JS MVC frameworks. I've gone as far as going back into other parts of apps I'm making and rewriting them using AngularJS from it originally just being some jQuery functions.

Re: Facebook’s New React JavaScript Library Tutorial Rewritten in AngularJS

#14
Angular is much much more than React, so no apples to apples, it is a complete kick ass awesome framework. I have used it in banking applications, mobile app and working on a startup which employs angular. I looked at backbone and angular is pure productivity, nothing else. I am not trying to learn the javascript nitty gritty and angular gets a whole lot more done in a lot less time and effort. React seems similar to EXT-JS widget toolkit and though seems similar to angular is more verbose. I admire the work Misko and team has done on angular and I am hoping it cleanly rolls and provides a abstraction or path forward when web components go mainstream. All in all i am not going to try any other lib unless Angular is not solving my problem. To hell with the purists.

Re: Facebook’s New React JavaScript Library Tutorial Rewritten in AngularJS

#16
I've been using Angular recently and love it. But this example is not matched evenly with the modular component demonstration of the React tutorial.

The equivalent in Angular would be to use directives (http://docs.angularjs.org/guide/directive) for the comment list, each comment, and each part of a comment.

Passing data between parent and child components (via scope) becomes a little tricky.

Re: Facebook’s New React JavaScript Library Tutorial Rewritten in AngularJS

#17
React's model is a bit interesting- it inverts the relationship between markup and code with the code containing the markup (without odd escaping). Not quite sure how well it really works without using it in a large app, but it is intriguing.

I do think that components which consist entirely of JS are convenient (self-contained w/ no ancillary HTML assets). Not sure it's enough to justify the framework, but has some potential.

Re: Facebook’s New React JavaScript Library Tutorial Rewritten in AngularJS

#18

Glad to see people implementing similar projects in both frameworks so everyone can evaluate their needs. Though, comparing code snippets to a lengthy tutorial kind of misrepresents the verbosity of React. I think we forgot to put the completed tutorial on GitHub, so here it is for an easier comparison: https://github.com/petehunt/react-tutorial/blob/master/scrip... Outside of standard HTML boilerplate our entire app…

This is the entire point of TodoMVC[1], which is to create a standard project across multiple languages/frameworks.

[1] http://todomvc.com/

Re: Facebook’s New React JavaScript Library Tutorial Rewritten in AngularJS

#19

Earlier quoted context omitted.

The controller is in fact separated. The "ngController" you see referenced in the markup is the link between the view and the separate controller. Any MVC framework you could hold up as an example of proper "separation of concerns" will necessarily have the same link, even if it's implicit. Sometimes it's defined in the controller, sometimes the link is defined in the view, and sometimes you don't see it defined, but…

Right, but doing it this way means both the view and the controller know too much. Why should a view know about how it is going to be used? Also, I'm guessing if you give this to a designer his/her eyes are going to glaze over.

No, the link here is only in the view. The controller doesn't "know" about the view. This is opposite but functionally equivalent to have traditional server-side MVC frameworks handle this, which is to declare the view in the controller or the routing (which you can also do in AngularJS, you actually typically declare both the view and controller in the routing). But the point is, you have to declare the link somewhere. Declaring it in the view is no less proper than declaring it in the controller.

Having said all that, I'm really impressed with React and look forward to checking it out and using it in combination with Backbone. AngularJS definitely has its share of pain points. It's just that where the controller is linked to the view is not one of them.

(By the way, I'm upvoting you since I don't see anything particularly offensive or improper about your comment. We're just disagreeing. Not sure why you're being downvoted. )

Re: Facebook’s New React JavaScript Library Tutorial Rewritten in AngularJS

#20
post #18

Glad to see people implementing similar projects in both frameworks so everyone can evaluate their needs. Though, comparing code snippets to a lengthy tutorial kind of misrepresents the verbosity of React. I think we forgot to put the completed tutorial on GitHub, so here it is for an easier comparison: https://github.com/petehunt/react-tutorial/blob/master/scrip... Outside of standard HTML boilerplate our entire app…

This is the entire point of TodoMVC[1], which is to create a standard project across multiple languages/frameworks. [1] http://todomvc.com/

Here ya go: https://github.com/facebook/react/tree/master/examples/todom...

We also have a demo of Backbone integration, too:

https://github.com/facebook/react/tree/master/examples/todom...

Post reply on HN