r/javascript • • Dec 15 '15

Angular 2 Beta is now available

http://angularjs.blogspot.com/2015/12/angular-2-beta.html
140 Upvotes

88 comments sorted by

View all comments

4

u/9thHokageHimawari Dec 15 '15

I've started wondering.. is it worth using Angular2 for small-scale apps? It feels like I would be better with something else :/

10

u/lingodayz Dec 15 '15

React is nice and simple. And is only concerned with the view. Use whatever you like elsewhere.

2

u/9thHokageHimawari Dec 15 '15

Never liked .jsx, but I guess I gotta check it out.

Flux is something like M/C, but its bound to V right?

6

u/jbarket Dec 16 '15

Once you actively use JSX, I think it becomes a lot less weird. I still wish conditionals in it were first class citizens, but it's never stopped me from getting stuff done.

Comparing React to MVC is always a bit weird. People say it's the V, but components can have any kind of logic in there you want. You can retrieve data when the component loads, bind it to the view, send AJAX events back out when you update data, et cetera.

There's just no strict pattern to it. You're doing all of that in plain old JS, and React is really just responsible for rendering what you do and providing some life cycle hooks.

The Flux pattern solves a lot of problems you end up with when you do this, like sharing information between components, and organizing code in a way that lets you make your components dumber (which makes them easier to reuse).

I highly recommend just playing with vanilla React for a bit. It's super fast to learn, enjoyable to use, and you will quickly figure out why patterns like Flux exist. I had no appreciation for all of the extra files and boilerplate of Redux until I started building something in React, and suddenly it all made sense.

6

u/AshamedOfYou Dec 16 '15

Agreed 100%. JSX is weird for about 5 minutes or so. Another advantage of it is that it demands a proper build system which will also pay dividends down the line.

4

u/Untit1ed Dec 16 '15

I still wish conditionals in it were first class citizens

Check out https://github.com/AlexGilleran/jsx-control-statements

(disclaimer: self-promotion)

1

u/brianvaughn Dec 16 '15

I still wish conditionals in it were first class citizens

IMO a decent enough solution is just to take advantage of short circuit behavior: {someBooleanCondition && <MyComponent/>}

Pardon the awful lack of markup. My phone makes such comments difficult to format.

2

u/_wsgeorge Dec 15 '15

I've started wondering.. is it worth using Angular2 for small-scale apps?

This is exactly what I'm doing: using ng2 for a small scale app. I don't see any problem with that.

3

u/9thHokageHimawari Dec 15 '15

My vanillaJS app is smaller than minified ng2+es6 shim+System.js :/

1

u/Mentis1 Dec 15 '15

They're going to have server-side pre-rendering available, so that should help reduce some of the initial load cost. I think its much more enjoyable developing in ng2 than vanilla, so if by small app you mean hobby project, it's definitely worth it!

1

u/_wsgeorge Dec 15 '15

Oh okay. I see what you mean. According to the post, one of the next few goals is to reduce the payload size, so that might help.

1

u/9thHokageHimawari Dec 15 '15

Should have said extra-small I guess.

1

u/tebriel Dec 16 '15

It's not even worth using angular1 for small-scale apps. :-D