News for hackers. Stuff that matters.
Re:AngularJS: Factory vs. Service vs. Provider by olalonde on Sunday May 04, 2014 @07:30PM (#7696270)
What I like about Angular: the scope system, two way binding, clever use of HTML markup for templating. I just wish it was more library like and less like a framework. I guess what I would really like to see is a hybrid of Backbone and Angular. Does such a thing exist?
Re:AngularJS: Factory vs. Service vs. Provider by hcarvalhoalves on Sunday May 04, 2014 @08:40PM (#7696481)
After successfully implementing a project with React.js + Backbone models and routers, I'm now sure Angular is both unnecessarily complex and limited.

One of the nicest things about React.js is not having to deal with such a layered architecture, you work at the right level of abstraction ("components"), and those components are composable. Some people freak out with JSX but it pays off to finally have a proper GUI pipeline for web apps instead of manipulating the DOM directly, or being limited to directives embedded in HTML.

Re:AngularJS: Factory vs. Service vs. Provider by nahname on Sunday May 04, 2014 @10:23PM (#7696718)
Do you have any open source projects for others to learn from?

Used backbone a few times, always turns into a train wreck.

Re:AngularJS: Factory vs. Service vs. Provider by hcarvalhoalves on Sunday May 04, 2014 @11:06PM (#7696802)
Unfortunately it's a commercial product so no source. Drop me a mail though (see profile), I can give some pointers.

I know what you mean by Backbone, and all I can say is that often wiring up the views is the culprit. Models and routers work nicely and that's all I used from Backbone in this project.

Re:AngularJS: Factory vs. Service vs. Provider by rich_harris on Sunday May 04, 2014 @08:29PM (#7696447)
Try http://ractivejs.org (disclaimer: I'm on the core team). It's a standalone system but works seamlessly with Backbone if necessary.
Re:AngularJS: Factory vs. Service vs. Provider by catshirt on Sunday May 04, 2014 @07:37PM (#7696291)
i think i'd call Angular's use of HTML markup unfortunate before i'd call it clever. it's a side effect of mapping a view represented by a markup language (HTML) to the same view represented by a programming language (JS).

i find React's implementation more clever, by giving you a single environment (JS) to declare your view's template and logic.

Re:AngularJS: Factory vs. Service vs. Provider by zoomerang on Sunday May 04, 2014 @08:29PM (#7696445)
I love Angular for exactly that reason. My HTML template should be a HTML file. I cannot stand codebases that mix code and markup together.
Re:AngularJS: Factory vs. Service vs. Provider by hcarvalhoalves on Sunday May 04, 2014 @08:56PM (#7696526)
If that's a stab at React.js, notice nothing stops you from having the JSX markup on a separate file. You can also convert from plain HTML to JSX. [1]

[1] http://facebook.github.io/react/html-jsx.html

Re:AngularJS: Factory vs. Service vs. Provider by zoomerang on Sunday May 04, 2014 @09:34PM (#7696600)
More a distaste with the design pattern of mixing HTML and Logic in one monolithic codebase. (i.e. lack of proper separation of concerns)

Forcing a clear separation leads Junior developers towards a better design, which is one of the reasons I like Angular - I can put a junior dev on a project and have them productive within about 10 minutes while feeling fairly confident they will do things the right way. It's a very easy framework to get started with, leads you towards a good overall architecture, and is deep/powerful enough that it doesn't fall over when things get hairy 85,000 lines of code later.

Obviously good React code will keep proper separation of concerns (whether using standalone templates or not), but I do worry a lot of developers will cheat and start emitting snippets of HTML in areas of the codebase that shouldn't be doing that.

Mind you React.js is a great framework, I just personally prefer Angular based on experience working with both.

Re:AngularJS: Factory vs. Service vs. Provider by hcarvalhoalves on Sunday May 04, 2014 @10:54PM (#7696775)
I don't see how Angular does not mix HTML and presentation logic, the point of directives is exactly that. Also, separation of concerns is not about this (it's about encapsulation, see Dijkstra).

> (...) but I do worry a lot of developers will cheat and start emitting snippets of HTML in areas of the codebase that shouldn't be doing that.

This does not make sense. React.js whole point is writing components that do emit HTML and re-render themselves (and children). Now the only thing the developer has to do is react to events (implement callbacks) and change state (setState), the pipeline takes care of the rest. Not only it's impossible to "cheat" by changing the DOM directly from outside the component (a re-render would remove the changes), it's also more work, so it's not cheating at all.

In reality, the clever thing about React is that you start treating data (markup) as code (React.DOM), instead of introducing crutches to work directly with HTML.

Re:AngularJS: Factory vs. Service vs. Provider by zoomerang on Monday May 05, 2014 @12:08AM (#7696894)
Angular does mix HTML and presentation logic. That's the point, and this is desirable.

Angular does not mix Presentation and Business logic. React doesn't inherently mix the two, but it doesn't dissuade it either.

> This does not make sense. React.js whole point is writing components that do emit HTML and re-render themselves (and children).

Yes, but it's writing code in Javascript that emits snippets of HTML or DOM. I'm generally not a fan of this approach. Even just just iteration requires jumping between the two, and often breaks up the page into multiple smaller segments in cases where it really doesn't need to me.

Re:AngularJS: Factory vs. Service vs. Provider by camus2 on Sunday May 04, 2014 @09:51PM (#7696651)
a lot of people put html strings into directives so it has nothing to do with angular. Furthermore , in angular the HTML looks like a template, not just html ,with expressions , ng- everywhere ...

I dont care about this but let's just not pretend Angular solves the HTML template in code issue . It's far from inobstrusive.

Re:AngularJS: Factory vs. Service vs. Provider by zoomerang on Sunday May 04, 2014 @10:17PM (#7696706)
You can cheat in any framework. The difference is that angular strongly encourages you towards one design, whereas React.js does not. (Directives are also not part of your normal daily workflow. Many projects wouldn't even use them).

Yes, angular templates are templates, not pure HTML. That's the idea. I'm not sure what your point is there.

Re:AngularJS: Factory vs. Service vs. Provider by mikewhy on Sunday May 04, 2014 @10:37PM (#7696747)
> I cannot stand codebases that mix code and markup together.

In Angular people can write

    app.directive('myDirective', function () {
      template: "<strong>oh no</strong>"
    });
which is what I think they were getting at.
Re:AngularJS: Factory vs. Service vs. Provider by zoomerang on Monday May 05, 2014 @12:11AM (#7696901)
Sure, but that's not idiomatic Angular. I'd wager the majority of Angular projects don't even use custom directives.
Re:AngularJS: Factory vs. Service vs. Provider by camus2 on Sunday May 04, 2014 @11:45PM (#7696857)
in React templates are not pure html either,I dont get your point.
Re:AngularJS: Factory vs. Service vs. Provider by robertsosinski on Sunday May 04, 2014 @08:09PM (#7696385)
Have you looked at Knockout.js <http://knockoutjs.com/>? I find it has just that mentality.
Re:AngularJS: Factory vs. Service vs. Provider by Shorel on Monday May 05, 2014 @02:51PM (#7700356)
Have you tried Ember.js ?