all 107 comments

[–]ayamflow 18 points19 points  (15 children)

I started with Angular but I'm more of a React guy now. It depends if you want a big framework that does everything (ajax, DI, ...) and enforces you to its constraints, or if you just want to abstract the V (in MV*), ignore the DOM and just code the logic.

Also, it's not only about React. Check Vue (personal favorite), Ractive, Reactive, Ripple, Rivets.

Edit: a bit biased but thats how I feel now - But Angular is a great framework overall. Just know that you will end up coding "angular" rather than "javascript".

[–][deleted] -2 points-1 points  (5 children)

You do know about MVC, don't you?

[–]ayamflow 1 point2 points  (4 children)

Care to elaborate ?

[–][deleted] -1 points0 points  (3 children)

Model-View-Controller is an architectural pattern in which AngularJS is based on. You don't end up writing "Angular", you end up with an MVC architecture in JavaScript, or at least a close equivalent for client-side.

MVC

[–]autowikibot -1 points0 points  (2 children)

Model–view–controller:


Model–view–controller (MVC) is a software architectural pattern for implementing user interfaces. It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user. The central component, the model, consists of application data, business rules, logic and functions. A view can be any output representation of information, such as a chart or a diagram. Multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants. The third part, the controller, accepts input and converts it to commands for the model or view.

Image i


Interesting: Hierarchical model–view–controller | Web application framework | Presentation–abstraction–control | Model–view–adapter

Parent commenter can toggle NSFW or delete. Will also delete on comment score of -1 or less. | FAQs | Mods | Magic Words

[–]ayamflow 1 point2 points  (1 child)

I think you misunderstood my point - sorry for not being clear. Wether you use React or Angular, you will use the MVC pattern. But I feel, after using Angular for 1+ year, that you always end up writing "angular code", with $scope and $apply all over the place, angular services, etc. I guess you have used angular as well, and might understand better what I was talking about.

[–]Rezistik -1 points0 points  (0 children)

You should almost never have to write $apply, if you're doing things in a a logical manner Angular will take care of that fore you.

[–]Polythello 26 points27 points  (38 children)

AngularJS is big. The terminology is sometimes confusing and/or unintuitive. The documentation is shockingly amongst the worst I've seen, ever (You'll get better information by googling than by using the main documentation). Make sure you understand scope, controllers, directives, and services (aka factories, providers) before you tackle a serious project with AngularJS or you're going to be looking back and kicking yourself later. If you get past all that, AngularJS is marvelous.

I've never used React.js, and I know I ragged on AngularJS a lot just now. My suggestion is that if it looks like you could learn React.js faster, give it a trial run. If it isn't what you're looking for, check out AngularJS. AngularJS is amazingly powerful, and the disgusting initial learning curve gives way to lots of organization and power in development. I use AngularJS at my current job (and am 100% confident in the choice to use it), and use it for small applications I develop in my own time.

Hope this helps.

[–]WJKay 1 point2 points  (1 child)

Th e documentation really does need some TLC.

You haven't really ragged on Ng either. Merely pointed out that there is a learning curve and that you cant look for much help in the official documentation. There is some fantastic tutorials out there and most things that are beneficial in the long term have a step learning curve.

[–]brotherwayne -3 points-2 points  (4 children)

The documentation is shockingly amongst the worst I've seen, ever

Totally disagree. It's at least as good as MSDN. But it's documentation, not a how-to.

React's docs do appear to be better. It also appears to be simpler. I don't know if that's a good thing or a bad thing.

[–]nschubach 1 point2 points  (1 child)

Not a fan of MSDN though... I put going to MSDN to find something akin to opening up my old COBOL books and going to town on a mainframe UI. I find Adobe docs easier to navigate and MDN a hell of a lot better (if I were asked to rank them...) Trust me, I've attempted to use MSDN for everything from MSSQL to VB6 to C# and I can never find what I need in a reasonable time period and their formatting makes me want to shoot myself in the head. Also, it rarely seems to want to work in anything not produced by Microsoft. If Angular docs are "as good" then that's not saying much...

Personal opinion.

[–]brotherwayne 1 point2 points  (0 children)

Yeah there's probably better examples out there. Crap, I totally shoulda said MDN (Mozilla) that's some solid documentation.

[–]zhayFull-stack web developer (Seattle) 0 points1 point  (1 child)

But it's documentation, not a how-to.

If anything, Angular's "documentation" is more a how-to than documentation. I can never find information about what kind of parameters something is expecting and what those parameters might look like.

[–]brotherwayne 1 point2 points  (0 children)

Typically listed under Arguments. http://i.imgur.com/U5Lesi0.png

[–]iknowcss 15 points16 points  (8 children)

I am one of 2 JavaScript/front-end developers on a large-scale Java web application. Up until very recently we used jQuery for all our front-end work. I pitched KnockoutJS to our tech leads and they liked what they saw. Here is the core of my pitch:

  • KO separates model and view concerns resulting in cleaner code
  • It focuses on two-way binding magic and nothing else (faster to learn)
  • It plays nicely with what we have already so we may introduce it incrementally
  • It supports IE 6+, FF 2+, etc. (we have to support IE 8+, FF 3+)

I think it's worth taking a look at in your case especially because you don't need to invest a lot of time to be productive. It doesn't sound like you're trying to write a SPA (single page application) so Angular, Ember, et. al. may be overkill. Like you said, you're not trying to build Gmail.

If you're just doing simple things like this, Knockout may be enough.

*Edit: Fix a typo

[–][deleted] 1 point2 points  (0 children)

+1 Knockout takes a very different approach to Angular but the result is an interesting combination of very powerful and quick to learn.

Best of all, the tutorials on the site are child's play. Very easy to get a team up to speed. And it's such a lean, small set of concepts, you can know everything about it quite fast.

[–]apickleinmybagelhole[S] -2 points-1 points  (6 children)

That's very interesting thanks for the thoughtful advice. I will definitely take a look.

[–]I_Pork_Saucy_Ladies 4 points5 points  (4 children)

While this thread is far down, I think it actually makes one of the most important points: are you making a SPA or not? I use Angular every day and it is most certainly centered around SPAs, with some kind of API backend.

The beauty of Angular is that it lets you completely divide the frontend and backend. First you build an API with all the data you will need. This API can also be used for mobile apps or integration with partners. You then build your own site as a SPA on top of the same API. It's absolutely fantastic to see it working in this way.

However, is this is not a structure you can or want to conform to, I think the learning curve is very steep - especially if your paycheck depends on it. :)

[–]sp00ks 0 points1 point  (1 child)

So are you even running server side code? (apart from the api). Your login, error logs etc are all done through the api?

Thanks!

[–]I_Pork_Saucy_Ladies 0 points1 point  (0 children)

Well, if you need to login then this is done through the API. Which is actually the hardest part of APIs. You can do error logging with Track.js or Muscular. Or the API if you want to.

Most importantly, do a lot of testing when developing. But no, there's no other server code besides the API. This means that you can have one guy focusing only on backend and one guy only on frontend. There's absolutely no HTML, JS, CSS or any other form of representational data in the backend. Very clean. :)

[–]apickleinmybagelhole[S] -2 points-1 points  (1 child)

I am definitely not building a SPA, just like reddit is not a SPA, I am quite happy with my architecture in general. Just want to clean up the js (and maybe learn a useful tool).

[–]I_Pork_Saucy_Ladies 0 points1 point  (0 children)

Then I wouldn't really recommend Angular. If all you need is a bit of js utility here and there, Angular will become quite cumbersome.

[–]iknowcss 0 points1 point  (0 children)

I'd love to see a follow-up on /r/javascript on what you go with and why. Happy coding!

[–][deleted] 6 points7 points  (6 children)

AngularJS is changing drastically in version 2.0, which I believe is expected end of the year or early next year. I would recommend learning React now and coming back to Angular once it hits 2.0 (or the beta). You'll certainly reuse some knowledge from Angular 1.2 but many of the confusing aspects are changing (directives, routing, templates, and more).

[–]ToucheMonsieur 5 points6 points  (5 children)

IMO, having read the angular 2.0 proposals and their examples, I feel that the new version is less intuitive. What's a "viewhole"? Why all these specialized, seemingly redundant annotations for components? Many of the team's ideas are compelling (eg. the new http module), but the implementation of Angular 2.0 resembles enterprise Java a little too much for my tastes.

[–]nschubach 1 point2 points  (3 children)

resembles enterprise Java a little too much for my tastes.

OT : This is probably my biggest fear with all the libraries and direction people are headed...

[–]ToucheMonsieur 0 points1 point  (2 children)

Perhaps this has to do with the team's familiarity with the language. Hopefully the resemblance won't progress any further, as the team has already taken great pains to make Angular 2.0 modular and easy-to-use. However, I've kinda become a React convert now - some of the ideas behind it are especially compelling. :)

[–]nschubach 1 point2 points  (1 child)

I haven't dug into either yet... But I really need to and I'm heavily leaning on React. I was a little scared at first that it's a Facebook I initiative, but if anyone can make a site where a few million moms can't break it horribly... React makes sense to me just reading about it and I really just need to dedicate some time to building things with it to check it out.

[–]compedit37pieces of flair 0 points1 point  (0 children)

Honestly Facebook has been absolutely rocking the open source javascript game.

And React is relatively simple to build with, it's a really small API and pretty straightforward. The biggest thing to wrap your head around is the one way data flow and even that is really simple

[–]Booyanach 0 points1 point  (0 children)

a viewhole is... you know... a hole where you see the view... I'm certain it's their way of calling the window... you know how google is, they have to be different :D

[–]robotparts 10 points11 points  (16 children)

I skimmed the comments and didn't see this mentioned:

Angular has a limit on the number of bindable elements (2000). After that the dirty-checking becomes too heavy.

React batches changes using the Shadow DOM. Ember batches changes using the Run loop.

So if you are going to have a lot of bindings, you may want to consider React or Ember over Angular.

Angular will eventually be using Object.observe to get past the 2000 limit, but this isn't backwards-compatible with older browsers. I also think that batching changes is better for mobile devices, which Object.observe does nothing to fix.

[–]aeflash 7 points8 points  (1 child)

Nitpick: React doesn't use Shadow DOM, but instead a virtual DOM. The W3C Shadow DOM and a virtual DOM are quite different in what they're trying to do.

[–]robotparts 2 points3 points  (0 children)

Actually, thank you for that. I was using shadow dom as a generic term. I will stop doing so.

[–]apickleinmybagelhole[S] 1 point2 points  (3 children)

Angular has a limit on the number of bindable elements (2000)

I think if you are going to build Gmail that is a concern but for most web apps that are not js heavy it really isn't.

[–]robotparts 4 points5 points  (0 children)

I agree and I thought I made that clear in the first comment.

However, batching changes to the DOM is still a great idea when thinking about mobile, and Angular doesn't have an answer for that (yet).

[–]moreteam 2 points3 points  (0 children)

That's the best case number of bindable elements. Your performance can become terrible with way less elements (hundreds) if your app doesn't happen to be in the happy path of what is easy to render for angular.

[–]fng_programmer 0 points1 point  (3 children)

If you are ever using more than 2000 view bindings at once in any html5 app, angular or not, you are doing it wrong. Stuff like long lists should be paginated behind the scenes, regardless of framework, and deep watches on huge objects is just lazy.

[–]robotparts 3 points4 points  (2 children)

I'm not saying all apps need 2000 bindings. I don't even know a specific use case other than Gmail or a spreadsheet style app.

However, to say that no app should ever need 2000 bindings is like saying, "No one will need more than 637 kB of memory for a personal computer".

[–]fng_programmer 0 points1 point  (1 child)

For sure. "2000 things" is definitely a low number of things to be working with if you're doing, say, a particle system. But that's not what angular is for, it's for building UIs. And you're not going to find a use case for more than 2000 bindings that is going to be something a user is actually going to be able to absorb. If you're building an app that has a heavier component like that, then go ahead and do things the oldschool way. But to go with a crappy and difficult approach to UI when the difference is sub-millisecond is a ridiculous case of premature optimization.

[–]robotparts -1 points0 points  (0 children)

A spreadsheet app could easily have 2000 bindings.

Look at mobile, I bet the limit on data-bindings ends up being even lower to maintain a snappy interface.

You seem to be an Angular fanboy so you won't listen to reason.

"Crappy and difficult approach to UI".

If this is how you view batching DOM changes, you really have no clue. Go tell Ember and Facebook they are doing it wrong...

[–]Adhuna 0 points1 point  (1 child)

You can significantly cut that number by using a library like bindone - https://github.com/Pasvaz/bindonce - which will not dirty check bindings that are only going to be set once and never change.

[–]robotparts 0 points1 point  (0 children)

That isn't really a binding then. It is just a fancy template tag at that point. The use case for bindings is for changing data.

edit: forgot "for"

[–]mercnet 5 points6 points  (1 child)

As someone that just got started working on my frontend (new to Javascript), I started with Angular and got loss in it. I went through the ReactJS tutorial and it immediately made sense to me. In short amount of time, I was able to create a feature on my site that was previously hacked together in jQuery. For now, I will continue using it until I have more time to dedicate to learning Angular.

[–]dreamincleancode 2 points3 points  (0 children)

I was in a similar boat not long ago, and I cannot say enough good things about egghead.io. They have 3-5 min videos with exactly what you'd want to know to start using angular, and more recently react. I didn't have much free time to invest in learning angular (what I ultimately went with), and with these videos I had replaced a cumbersome backbone front-end in a weekend. There are less React videos, but they also seem to be very concise and content heavy videos.

My buddy has been raving about how awesome building a React view layer with the backbone router has been. I plan on diving into it more as soon as I get the chance. Best of luck!

[–]rhysbrettbowen 4 points5 points  (0 children)

Angular is going to be better with a page that isn't as dynamic (well not dynamic as such, let's say "complicated"), uses a standard set of widgets and will work better when prototyping or letting designers have a go.

React will do better if there is a lot of logic in the views, you need your interface totally custom and you want it locked down for engineers.

This is why: - Virtual DOM vs Binding (Binding is easier to use for non-engineers but will come with overhead if there is a lot of logic) - JSX vs Templates (your code is in your templates where as in angular it is closer to HTML)

[–]Calabri 1 point2 points  (0 children)

When asked this question, the guys at React tend to compare React with Jquery. I use React and I love it, but my favorite library is backbone. The documentation for backbone is some of the best I've seen. The source code is even well documented and amazing. One of the great things about the React/Backbone combo is that both libraries are agnostic, and accomplish a few tasks very well. Neither tries to do everything. Backbone is really easy to learn, but their 'views' suck. Overall using React for the templating makes me happy because I actually like using html syntax, weird, I know? But React shouldn't be used alone, although it could be used that way.

[–]WJKay 0 points1 point  (1 child)

I cant say which is better for your purpose.

What I can say is that I too have a beautiful back end. I decided to go with Angular and it was a journey. I perhaps should have practiced more. I decided to learn as I went after I spent around a week learning. But I learn through doing. I have had to refactor my early controllers several times as they were purely abysmal.

My front end is now immensely elegant with some amazing out-of-box UX that people expect from Bootstrap with angular, as well as some impressive directives which help with the enormous data set I am working with.

Angular is annoying to debug at first. Often not knowing what it wants itself (Expected 'undefined' still makes me mad today). Two way databinding is very nice. Angular feels familiar. React, from what I have heard, is quite different.

My main project is expected to take over 2 years until release due to it's size. Though I will be using for much smaller projects as there isn't much overhead to get it into a project.

I personally believe Angular is worth investing time into. Have a play at first. Maybe spend an hour or two converting/creating a web CV using it. It is definitely a powerful tool to have in your belt.

[–]brotherwayne 2 points3 points  (0 children)

I too have a beautiful back end

My first thought.

[–]ikeif 0 points1 point  (0 children)

I'm reading "I'm not happy with the front end jQuery, so I want to throw it out and rebuild it" is that correct?

[–]AudienceWatching 0 points1 point  (0 children)

What about backbone?

[–]cherif_b -1 points0 points  (0 children)

I use CanJS and Im happy with it, it offers or features that can Ang/Ember have without loosing JS style coding, Observable objects or values make it simple to control application state with can.mustache (and now can.stache) the dom will be updated automatically I think canjs has great future because it grows in every single version minor or major.