r/webdev • u/chotn • Jan 05 '16
Angular 2 versus React
https://medium.com/@housecor/angular-2-versus-react-there-will-be-blood-66595faafd5132
u/yird Jan 05 '16
angular is the java of JS frameworks.
51
u/x-skeww Jan 05 '16
I know this is meant to be criticism, but "being the Java of something" would be actually seriously awesome. It provided large productivity improvements (over C++). It has been a very popular language for 2 decades. It had a language specification and things like official code conventions, excellent documentation, and a doc generator. There are still many languages which can't offer that stuff. There are even free top-notch IDEs. The JVM is an excellent platform. Java is a unicorn which shits gold nuggets.
Sure, now it looks a bit long-winded and clunky, but things would be very different if it weren't for Java.
16
u/dweezil22 Jan 05 '16
"Java of something" : Noun, circa 2010 describes a workable language which pays the bills and feeds the kids but seems (and may actually be) less fun and/or efficient than something else new. See "COBOL of something", now archaic (well maybe...)
3
u/CuriousCursor Jan 05 '16
Yeah, I think only people who used java in very limited capacity have this mindset. Development tools available to work with java are so vast that they alone make it fun to work with.
1
u/3058248 Jan 05 '16
What is replacing Java?
-2
10
u/legendaris Jan 05 '16
angular is the java of JS frameworks
Can you explain how so?
6
u/felipeccastro Jan 05 '16 edited Jan 05 '16
Just like Java, Angular became somewhat known for overusing design patterns, over-engineering and making everything too "enterprise-y".
My favorite rant about this topic is you have ruined javascript (linked cached version because the article seems to be offline now)
0
u/hahaNodeJS Jan 05 '16
"Overusing design patterns" is a nonsensical statement. Literally every piece of software is a pattern of some kind. Using common and well understood architectural patterns lends itself to consistency and ease of maintenance and understanding.
The opposite of "overusing design patterns" would be to not use any patterns, which would mean having many ways to do exactly the same thing (this is not the same as Angular's providers, factories, and services, which is a problem, but they do serve different purposes). Imagine a codebase wherein each structural decision is completely different from file to file.
I'm not certain where you see over-engineering in Angular. It's quite simple to make an application without being an architecture astronaut, and with a solid understanding of how Angular works, little to no work needs to be done to get Angular to behave the way you intend.
"Too enterprise-y" is a wishy-washy statement without a real definition.
1
u/felipeccastro Jan 05 '16
Do you know the FizzBuzzEnterpriseEdition? This is an exageratted version of what I mean by "enterprise-y" (or "overusing design patterns"), basically adding complexity for no good reason besides looking professional.
I'm not claiming that's the case with Angular, my point was to explain what it usually means when someone compares X with Java. If you prefer this more structured approach, then it's not even a bad thing.
1
u/hahaNodeJS Jan 05 '16
I have seen that git repo and, while I think it's a fantastic example of what an architecture astronaut would build, I'm not so sure I agree that it's representative of anything enterprise. There is a massive difference between the colloquial understanding of enterprise software and the actual definition.
0
10
-2
0
3
u/dsjoerg Jan 05 '16
I won't use Angular 2 because I got burned so badly by Angular 1.
I won't use React because "Javascript fatigue" sounds miserable.
I just want to be productive and deliver reasonably modern features. So what should I use instead? Meteor? Ember?
6
1
u/Spo0Bo Jan 05 '16 edited Jan 05 '16
So you are going to exclude React all because of one person who wrote an article about too many choices. That is amazing. React which is quite possibly the simplest one out of the bunch.
Here is what you are missing. Learning one big framework or ecosystem gives you knowledge about how those ecosystems work. About their best practices and their way of structuring things. You'll learn to use their plugins, models, services and their complete API. You'll learn the internals to get it performant and you'' end up putting in a lot of time to get something good. However when they decide to change you will have to follow. Angular 1 vs Angular 2. Or alternatively Ember's restructurings after a major release. This will no doubt be the same with Meteor as they have a shit product with a bonkers foundation that can simply never work well for specific usecases. While this is not bad as you'll pick up some actual good practices here and there it is not ideal as most of these practices are very specific to the framework and will only work there. Like what to do with $scope or how to structure your angular 1.x modules.
Now, compare this to your own little playground where you pick components as you see fit. You might use react for the viewlayer. You could use an http library like axion or perhaps even a native library like fetch for data requests assisted by a polyfill. You might want to use falkor or something to automate querying etc. You could use redux to store your data and propagate statechanges in your app. Whenever one of these small pieces change it will never have a massive impact on your app. If a piece changes too much you can replace it with a library that is more conform to your other way of doing things. In the mean while you'll become a better JS user, you might become more active in development of open source packages. You might publish your own glue code as an open source project etc. Believe me you'll become a better (JS) developer for it. Don't buy into the framework dream. No community will last forever. If anything will survive it'll be JS itself and small modules that do one thing and they do it well.
1
0
Jan 05 '16
I won't use Angular 2 because I got burned so badly by Angular 1
You probably should avoid Javascript in general if you somehow feel slighted by a framework.
The rest of us will just continue working and not pretend there's some magical library/framework that makes everything perfect.
2
u/dsjoerg Jan 05 '16
Not all libraries are the same. Some care more about developer productivity than others. Angular 1 fell down hard on documentation. And then by end-of-lifing it they effectively invalidated all the work that people put into learning it.
It would be silly to ignore those things when considering Angular 2.
2
u/ubercode5 Jan 05 '16
The thing that put me down the angular path is the integration with ionic, giving me an easy way to make hybrid apps. Is there anything like ionic for react?
9
Jan 05 '16
ReactNative is way faster than Ionic, because former is native, while the other is hybrid.
2
u/ubercode5 Jan 05 '16
Oh duh! I had looked at that a while back, but it was still pretty alpha at the time.
0
Jan 05 '16
[deleted]
-8
u/DBBX JS 💛 Jan 05 '16
Important to mention, it's OSx only
1
u/acewolk Jan 05 '16
i thought that was only if you want to target iOS?
1
u/DBBX JS 💛 Jan 05 '16
Nope, for now I'm sticking with Ionic (only downside due to android segmentation it don't work as smooth as native apps on android devices).
And as FundieInAChainWax says ReactNative is build with Native components not with Hybrid components.
1
u/Spo0Bo Jan 05 '16
It's not on OS X yet. It's on iOS and Android. Windows Phone will probably follow as it is fully capable of running a JS context inside their native environment. There will even be OS X bindings (aka desktop class apps).
1
u/DBBX JS 💛 Jan 06 '16
I ment you need to run OS X to create an application using React Native. Not that you can run a React Native app on OS X
1
u/Spo0Bo Jan 06 '16
https://facebook.github.io/react-native/docs/linux-windows-support.html it should work with some tweaks on windows & linux. Not iOS development obviously. You'll always need OS X for iOS but that is an Apple requirement.
0
Jan 05 '16
[deleted]
3
Jan 05 '16
No official support for developing on linux or windows desktop. Only Mac desktop/laptop is officially supported .
2
u/cc81 Jan 05 '16
I've developed some on Windows and it works well. However React Native is pretty new and that is noticeable. A lot of lacking components and the ecosystem around it is pretty unorganized.
1
u/bradkirby Jan 05 '16
A nice comparison that's more balanced than most I've seen.
I have a question: does React have something comparable to Angular's custom directives? How does React componentize it's code?
I haven't used React, and most of my experience is with Angular 1, but I can't help but feel like React seems best for small projects while Angular 2 is best for larger ones.
3
u/misc_ent Jan 05 '16
Its componentized by using its components. Having used both I prefer React's components to extending html with directives. It becomes even better when you remove all state from components and into something like Redux. Then components simply react/update to the incoming props on the component.
React is also perfectly valid for large projects in production. Like any library/framework it comes down to devs using best practices in their code. Hell Facebook.com and Instagram both use React in production.
4
u/CptAmerica85 Jan 05 '16
If React was created by Facebook (one of the largest sites in the world), I wouldn't say it's for small projects....
1
u/digitallimit Jan 05 '16
Facebook is certainly not a small project; I'm not quite sure why you're being downvoted.
2
u/CptAmerica85 Jan 05 '16
Eh, it happens. Oh well haha.
1
u/CaptainIncredible Jan 05 '16
I made a crack about my slight disappointment with the new Star Wars... -14 was the last count. :(
1
u/digitallimit Jan 05 '16
React nearly can't be discussed without bringing up Flux, and Flux is almost exclusively useful for large projects.
-12
u/-Alias- node Jan 05 '16
This should be no "this vs that". They're two different tools, both do a good job. Choose what's best for your project.
16
4
u/rhianos Jan 05 '16
I don't think React and Angular solve different problems, so a comparison is definitely warranted.
0
Jan 05 '16
[deleted]
33
u/Shaper_pmp Jan 05 '16
What does it mean to just use JS?
The author means that if you know how to iterate over an array in Javascript then you also already know how to do it in React (in this case, using
Array.map()).In Angular you have to remember the Angular syntax for iterating over an array, which is additional cognitive overhead.
FWIW I'm neither an Angular nor React developer so I have no dog in this fight, but it does seem that this specific point is a valid one - leveraging your existing javascript knowledge for conditionals/iterations/etc should lead to lower cognitive overhead than having to learn/memorise/recall a completely different syntax.
0
Jan 05 '16
[deleted]
6
u/Shaper_pmp Jan 05 '16
However, for Ember the list of "propriety" syntax isn't that long: http://emberjs.com/api/classes/Ember.Templates.helpers.html
True - I'm not saying it's necessarily a massively significant drawback (especially if you pick one framework and dedicate your career to it), but I can see how it's an additional mental stumbling-block for newbies, and anyone who jumps from framework to framework and always has to stop for a second and remember (or even look up) the right helper name and syntax each time they want to use it.
1
u/eyko Jan 05 '16
In ember templates you can only use whatever ember templating syntax support, or you need to write your own helpers.
In React, you basically just write JavaScript so the learning curve is non-existent (if you already know JavaScript) and the ramifications of that are plenty.
For one, it's easier to hire developers: no more "do you have experience in Ember or Angular?" since now all you need is a developer that can write JavaScript (so angular and ember developers can already write good enough React code, and the best practices are usually JavaScript best practices after all).
8
u/1xltP3mgkiF9 Jan 05 '16
In React you can use plain javascript if you choose not to use JSX. That way you use only JS, no need for template languages, no need to even look at the HTML. You can use a powerful language, extract common patterns to functions, do refactorings, etc. And in addition to this - if you choose to use JSX - the code becomes very readable IN ADDITION to the features I have enumerated.
4
u/aCSiain Jan 05 '16
Just what I was going to add, why do people seem to forget that JSX is completely optional whilst using react!?!
4
4
u/yasth Jan 05 '16
Because in all honesty if you are using React and doing something that would normally be done in JSX without it, your code would and should be rejected by code review. It is a bit like saying that if you don't like syntax of the C's switch statement you should just use ifs. I mean sure you could (and I've seen that actually specified in a coding standard document), but honestly most of the time you should use it despite your aversion to it for ease of collaboration.
1
u/1xltP3mgkiF9 Jan 05 '16
That's not the point. The point is that JSX is a minor enhancement to the language (thus full power of js + small syntactic sugar) which doesn't reduce it's full power in any way. In opposite - templating languages are known (and some even brag about it) to have limited power.
3
u/yasth Jan 05 '16
??? The point is it isn't generally truly optional in a collaborative environment.
I like JSX, it is nice, but calling it optional is a bit of a stretch if you plan on having several people working on it (especially people hired outside of your non JSX react bubble).
1
u/1xltP3mgkiF9 Jan 05 '16
The point of calling is optional is not giving a choice to the user - but making the user realize that it is only a syntax sugar .. that it in fact doesn't restrict a language, but simplifies some constructs.
2
u/yasth Jan 05 '16 edited Jan 05 '16
Then call it syntactic sugar and not optional. Though honestly it is beyond the limits of what most people would call syntactic sugar. It isn't a simple transformation at all. I know several React sources call it syntactic sugar, and it kind of is, but it is probably outside the usage for the broader programmer community.
*Keep in mind I was originally replying to a comment (not yours, but a subcomment of it) that called it "completely optional"
6
u/ogrechoker Jan 05 '16 edited Jan 05 '16
Nice writeup. I think React is a great tool, but it's hilarious that anyone could call JSX "beautiful, natural Javascript". The allure of React over Angular is the way it approaches functional programming and managing state (which is a great paradigm, one Ember uses now ("data down, actions up"), and which later style guides for angular 1.x recommend. Angular 2 uses this style for components / state as well.
Praising one over the other for it's "natural, flow from your fingertips DSL" is like picking a hooker for her ability to hold conversation.
0
Jan 05 '16
[deleted]
1
u/ohmyashleyy Jan 05 '16
React can manage state - we had a React application without flux/redux and lots of objects getting passed around. It was a mess so now we're rewriting it with Redux, but it can be done.
4
0
12
u/felipeccastro Jan 05 '16
At this point, my main concern is performance and UX, pretty much above anything else. Whether HTML in JS or JS in HTML is the best way to go, it's secondary. It doesn't matter if the final product is sluggish, something we usually only discover too late in the process. I'm not crazy about React's development style, but I do like the responsiveness of anything developed with it. It's arguably the fastest among the mainstream JS frameworks. IMO it doesn't matter if Angular is using Typescript or COBOL in their HTML; if the final product is heavy and slow, it's not worth using it. I hope in v2 they have seriously addressed this issue.