News for hackers. Stuff that matters.
Re:Removing User Interface Complexity, or Why React is Awesome by rdtsc on Tuesday May 13, 2014 @11:14AM (#7738514)
As mostly an outsider to the web front end development, React.js is probably the easiest one for me to understand among the typical "frameworks", especially Angular and Ember.

After all the excitement about Angular for example, I went to learn about it and just got lost with new concepts: DOM transclusion, scopes, services, directives, ng-apps, controllers, dependency inversion and so on. I can use it but need someone to hold my hand. It reminded me of Enterprise Java Beans.

But so far just learning how React is put together and looking at the tutorials it seems like less of a framework and easier to understand altogether. I suspect this might become the new way to build web applications.

Well anyway, don't take this too seriously, I as said, I am an outsider to this.

Re:Removing User Interface Complexity, or Why React is Awesome by camus2 on Tuesday May 13, 2014 @12:04PM (#7738817)
> After all the excitement about Angular for example, I went to learn about it and just got lost with new concept DOM transclusion, scopes, services, directives, ng-apps, controllers, dependency inversion and so on. I can use it but need someone to hold my hand. It reminded me of Enterprise Java Beans.

AngularJS has a serious "naming" problem.

Most these concept are easily understood when explained the right away,what AngularJS doc doesnt do. The only complicated thing to grasp is the digest cycle. But anything else is trivials.It's nowhere near the complexity of Java EE.

Scopes are easy,like any composite structure you have nodes with children and parents ,what make scopes special is that they can inherit properties from their parent scopes.

Directives are just custom html elements/attributes where you should do dom manipulation,all other angularjs components should be free from any DOM manipulation,Directives are the closest thing to react components.

Controllers represent the state of the view,when the data in a controller changes, a view that exposes that data changes and vice et versa.

Services are dumb objects that can be shared between controllers and dependency injection is the way one share these services. Controllers can references services ,and services can reference other services. Services are singletons

So there is nothing really complicated with all these concepts,just that the doc sucks for some reason.

Re:Removing User Interface Complexity, or Why React is Awesome by chc on Tuesday May 13, 2014 @06:40PM (#7741083)
As the famous quote goes, there are two hard things in computer science: cache invalidation and naming things. When I first heard it, I thought it was a joke; nowadays I feel like it's barely a simplification.
Re:Removing User Interface Complexity, or Why React is Awesome by possibilistic on Tuesday May 13, 2014 @11:44PM (#7742076)
"And off by one errors".
Re:Removing User Interface Complexity, or Why React is Awesome by JonnieCache on Wednesday May 14, 2014 @05:41AM (#7742920)
I think coming to see that "joke" as deadly serious is a coming-of-age moment for all programmers.
Re:Removing User Interface Complexity, or Why React is Awesome by bmillipede on Tuesday May 13, 2014 @06:39PM (#7741075)
I agree. It takes a while to get one's head wrap around AngularJS. But once you get it, it's awesome. Anyways, this is the tutorial that finally helped me get it:

http://www.thinkster.io/angularjs/GtaQ0oMGIl

Re:Removing User Interface Complexity, or Why React is Awesome by benatkin on Tuesday May 13, 2014 @03:55PM (#7740306)
Great explanation.

Angular attribute directives would map well to React Mixins. They take more work to set up, but with mixins code can at least be reused outside of the inheritance tree.

Re:Removing User Interface Complexity, or Why React is Awesome by beat on Tuesday May 13, 2014 @11:19AM (#7738546)
I feel your pain. I'm a backend guy who has to learn front end all of the sudden. To my mind, React just makes sense. I understand that other modern frameworks like Angular and Ember "make sense" as well, in that they're current best implementations of well-understood best practice, but from my outsider perspective, it looks as complicated and baroque as Catholic theology. Yes, it's all very beautiful and such, but I don't know if I'll ever be able to instinctively grok it.

React? I grok that.

Re:Removing User Interface Complexity, or Why React is Awesome by steveklabnik on Tuesday May 13, 2014 @05:49PM (#7740893)
If you're a backend person, thinking about Ember as being more of a Smalltalk MVC than a Rails MVC helps a lot.
Re:Removing User Interface Complexity, or Why React is Awesome by Joeri on Tuesday May 13, 2014 @03:22PM (#7740082)
Libraries like angular and ember are for programming in the large, with lots of code and lots of developers sharing that codebase. They trade simplicity for scalability. You should use them if you know you need them, and if you need them you'll know.

I went through this transition in late 2007, where the app my team was building gradually outgrew simple javascript libraries, and i ended up adopting extjs (the ember of its day) at great cost, but to great benefit. It is 600 kb of js code uncompressed just for the framework, and we not only ended up using all of it, but building a ton of code on top. We needed all that complexity to build the app we work on, but then it is over half a million lines of code by now. If you don't have those needs, the big js frameworks can be more trouble than they're worth, sort of like j2ee vs php.

Re:Removing User Interface Complexity, or Why React is Awesome by sytelus on Wednesday May 14, 2014 @01:31AM (#7742350)
Angular is huge bloat. Unfortunately Google's name is behind that mess so it will live for little bit longer before getting forgotten.

I myself prefer frameworks that are minimal, least invasive and plays nicely with pure JS/HTML instead of treating them as bug. So anything that requires me to call .createClass to create an instance is out. Personally I've used Knockout.js pretty successfully. I think any average js dev can understand that framework in 15 minute and be productive. Although it's not perfect if you you are looking for idealistic MVC implementation.

Re:Removing User Interface Complexity, or Why React is Awesome by Guillaume86 on Wednesday May 14, 2014 @10:50AM (#7744067)
KO is not a framework it's "just" a data binding library
Re:Removing User Interface Complexity, or Why React is Awesome by svachalek on Tuesday May 13, 2014 @11:33AM (#7738627)
I've been doing Angular for about a year now and am pretty comfortable with it, but I definitely remember going through that brick wall and see it every time I try to explain it to someone new. React looks much more straightforward to pick up but I am curious whether someone who has "mastered" both would find one or the other more powerful or maintainable.
Re:Removing User Interface Complexity, or Why React is Awesome by RussianCow on Tuesday May 13, 2014 @02:37PM (#7739822)
I haven't "mastered" React by any measure, but I've been using Angular for quite some time, and I find that apps written with it become really frustrating to maintain after a certain amount of complexity. I see Angular somewhat akin to C++ in that it's the most powerful and flexible (IMO) of the popular JS frameworks, but you're also going to spend a hell of a lot of time creating your own structure and conventions. This is a fine tradeoff if you need the flexibility, but for my use cases, React is much simpler and less headache-inducing to use. I just find that I can fit React's model into my head, whereas with Angular I'm constantly needing to figure out how to translate my mental model of my app into code that actually works, and dealing with weird, undocumented edge cases.
Re:Removing User Interface Complexity, or Why React is Awesome by modarts on Tuesday May 13, 2014 @03:11PM (#7740021)
There's really nothing to 'master' about react, that's the beauty of it really. You just learn about react's view of how data flows through an app with props and state; and that's pretty much it.
Re:Removing User Interface Complexity, or Why React is Awesome by coffeescripter on Tuesday May 13, 2014 @06:01PM (#7740939)
Exactly. React is a fairly simple library that can play well with other libraries, including on the server-side. Angular and Ember are complex frameworks.
Re:Removing User Interface Complexity, or Why React is Awesome by rdtsc on Tuesday May 13, 2014 @09:00PM (#7741620)
Yes that is, I guess, what I like about!