Slide 1

Slide 1 text

Angular vs React What is the difference? When to use them? Michał Michalczuk

Slide 2

Slide 2 text

Angular, React whaat? 2 vs framework library

Slide 3

Slide 3 text

Framework vs library – according to Martin Fowler Framework A framework embodies some abstract design, with more behavior built in. In order to use it you need to insert your behavior into various places in the framework either by subclassing or by plugging in your own classes. The framework's code then calls your code at these points. Library A library is essentially a set of functions that you can call, these days usually organized into classes. Each call does some work and returns control to the client. 3

Slide 4

Slide 4 text

Angular vs React (actually Angular 2 vs React) 4

Slide 5

Slide 5 text

Angular 1.x 5 Angular 1.x followed by the docs: • structural framework for dynamic web apps, • data binding and dependency injection eliminate much of the code you would otherwise have to write, • browsers compatibility abstract layer • a complete client-side solution (handles DOM, handes AJAX calls) • Everything you need to build a CRUD app in a cohesive set: Data-binding, basic templating directives, form validation, routing, deep-linking, reusable components and dependency injection. • Testability story: Unit-testing, end-to-end testing, mocks and test harnesses. • Seed application with directory layout and test scripts as a starting point.

Slide 6

Slide 6 text

Angular 1.x 6 Angular 1.x sweet spot (by the docs): • Angular simplifies application development by presenting a higher level of abstraction to the developer. • Like any abstraction, it comes at a cost of flexibility. In other words, not every app is a good fit for Angular. • Angular was built with the CRUD application in mind. • Games and GUI editors are examples of applications with intensive and tricky DOM manipulation ... are probably not a good fit for Angular.

Slide 7

Slide 7 text

Angular 2 7 Angular 2 by the docs: • Cross platform • Progressive web apps • Native • Desktop • Speed and performande • Code generation optimalized for JS vms • Server side rendering • SEO • Split loading modules/components because of new Component Router • Angular CLI • New standards • Web components friendly • Standarized from day 1 – style guides, TypeScript on all examples • Explicit components lifecycle • Runtime • HTML centric templates

Slide 8

Slide 8 text

React 8 React by the docs: • Simple • Only for creating interfaces • Cross platform (React Native) • Component-Based • Declarative • Fast • Light • Server side rendering • SEO • Explicit components lifecycle • Compilated • JavaScript centric templates

Slide 9

Slide 9 text

React 9 React sweet spot by the docs: We built React to solve one problem: building large applications with data that changes over time.

Slide 10

Slide 10 text

Comparison: Basics 10 Attribute AngularJS Angular 2 React Version 1.5.0 2.0.0 -rc5 15.3.1 Author Google Google Facebook Language JavaScript/HTML TypeScript JSX Size 143k 764k 151k

Slide 11

Slide 11 text

Comparison: Basics 11 Attribute AngularJS Angular 2 React Version 1.5.0 2.0.0 rc5 15.3.1 Author Google Google Facebook Language JavaScript/HTML TypeScript JSX Size 143k 764k 151k Core(566k) + RxJS React + Redux * Sizes after minification, no gzip

Slide 12

Slide 12 text

Size difference Angular • Framework • Lot of features out of the box So • Large size, but less external components to develop min app React • Library • Lot of features provided by external packages So • Choose components and code blocks by your own and handle/deal with it by your own 12

Slide 13

Slide 13 text

Comparison: Meta data 13 Attribute AngularJS Angular 2 React Churn Reduced Reduced High Tooling Low High High Code Design JS into HTML JS into HTML JavaScript Centric JavaScript “Fatigue” Less Less More Attribute AngularJS Angular 2 React Churn Reduced Reduced High Tooling Low High High Code Design JS into HTML JS into HTML JavaScript Centric JavaScript “Fatigue” Less Less More *by Reddit and HackerNews

Slide 14

Slide 14 text

Chorn and code design Angular • Reduced chorn • Developed by evolution • HTML centric for templating • (view) Fails at runtime React • High chorn • Developed by revolutions • JavaScript centric for templating • (view) Fails at compilation time 14

Slide 15

Slide 15 text

Comparison: Building, DOM manipulation, other 15 *by Reddit and HackerNews Attribute AngularJS Angular 2 React DOM Regular DOM Regular DOM Virtual DOM Learning Curve High Medium Low Packaging Weak Medium Strong Abstraction Weak Strong Strong Debugging General Good HTML / Bad JS Good JS/Good HTML Good JS / Bad HTML Fails When? Runtime Runtime Compile-Time Binding 2 Way 2 Way Uni-Directional Templating In HTML In TypeScript Files In JSX Files Component Model Weak Strong Medium Building Mobile? Ionic Framework Ionic Framework React Native MVC Yes Yes View Layer Only Rendering Client Side Server Side Server Side

Slide 16

Slide 16 text

Coding Session Code show session Show me the code

Slide 17

Slide 17 text

Angular 1.x summary 17 Use • Creating CRUD applications, unless your using components • When handling forms and not a lot of rich-communicative UI • When not handling large amount of data (digest loop is sensitive for large, nested objects) Not recommended • Games • All apps with complex DOM manipulations needed

Slide 18

Slide 18 text

Angular 2 summary 18 Use • Creating CRUD applications, unless your using components • When handling forms and not a lot of rich-communicative UI • When not handling large amount of data (digest loop is sensitive for large, nested objects) Not recommended • Games • All apps with complex DOM manipulations needed

Slide 19

Slide 19 text

React summary 19 Use • When performance and DOM rendering control matters • When handling complex models or creating a lot of DOM • Lot of client-side communication • "building large applications with data that changes over time." Not recommended /Not need for • CRUD data-bound REST apps • Static pages, pages that need templating • Form-driven apps

Slide 20

Slide 20 text

Languages / Frameworks philosophies and sweet spots 20 "There are only two kinds of languages: the ones people complain about and the ones nobody uses." Bjarne Stroustrup

Slide 21

Slide 21 text

Bonus: jQuery 21 Use • When need lot of DOM manipulations • Isolated forms validation • Isolated AJAX calls Not recommended • Building SPA • Logic based on DOM elements • Building dynamic forms *You might not need jQuery

Slide 22

Slide 22 text

Resources / Links Articles • http://tutorials.pluralsight.com/front-end-javascript/angular-vs- react-a-side-by-side-comparison • https://medium.freecodecamp.com/angular-2-versus-react-there- will-be-blood-66595faafd51#.8sw176xi2 • https://www.airpair.com/angularjs/posts/angular-vs-react-the-tie- breaker • https://www.codementor.io/reactjs/tutorial/react-vs-angularjs • https://medium.com/@zackargyle/stop-using-react-for- everything-c8297ac1a644#.4xaw7dyk1 • http://ricostacruz.com/cheatsheets/react.html • https://camjackson.net/post/9-things-every-reactjs-beginner- should-know • https://auth0.com/blog/bootstrapping-a-react- project/?utm_content=buffer64070&utm_medium=social&utm_so urce=twitter.com&utm_campaign=buffer • Angular 1, Angular 2 official documentations • React 15.x official documentation Code • https://github.com/coryhouse/react-tour-of- heroes • https://angular.io/docs/ts/latest/tutorial/ • http://youmightnotneedjquery.com/ 22

Slide 23

Slide 23 text

Thank you!