Game of JS-Frameworks


Introduction
Andrii Zhukov
- Senior Software Engineer at GlobalLogic
- Trusted Interviewer
- Mentor


Agenda
- The main framework leader in Frontend development. Big three frameworks.
- Basic information about each of the technology.
- What are the differences and similarities?
- What framework is worth to be chosen by you :)
- What's under the hood?
- What reactivity each framework is based on?
- Make a summary




Big three frameworks
Basic information
Angular is a framework led by the Angular Team at Google and by a community
- Typescript, OOP
- RXJS, Observer
- EventEmitter
- NgZone, ChangeDetection
- Ivy, DI, Ahead-of-Time, Interceptors etc.


Basic information
Angular is a framework led by the Angular Team at Google and by a community
- Decorator
- MVC
- Two way binding
- HTML, directives


Basic information
Who uses the framework?
Google, PayPal, Upwork, Microsoft, Youtube, AWS
Autodesk, MacDonald's, UPS, Cisco, Udemy, Nike, Telegram
AT&T, Apple, Adobe, GoPro, ProtonMail, Clarity Design System
Freelancer, Weather, iStockphoto, Crunchbase


Angular code
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { HttpClientModule } from '@angular/common/http';
import { ReactiveFormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { TopBarComponent } from './top-bar/top-bar.component';
import { ProductListComponent } from './product-list/product-list.component';
import { ProductAlertsComponent } from './product-alerts/product-alerts.component';
import { ProductDetailsComponent } from './product-details/product-details.component';
import { CartComponent } from './cart/cart.component';
import { ShippingComponent } from './shipping/shipping.component';
@NgModule({
imports: [
BrowserModule,
HttpClientModule,
ReactiveFormsModule,
RouterModule.forRoot([
{ path: '', component: ProductListComponent },
{ path: 'products/:productId', component: ProductDetailsComponent },
{ path: 'cart', component: CartComponent },
{ path: 'shipping', component: ShippingComponent },
])
],
declarations: [
AppComponent,
TopBarComponent,
ProductListComponent,
ProductAlertsComponent,
ProductDetailsComponent,
CartComponent,
ShippingComponent
],
bootstrap: [
AppComponent
]
})
export class AppModule { }
/*
Copyright Google LLC. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at https://angular.io/license
*/

Angular code
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent { }
/*
Copyright Google LLC. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at https://angular.io/license
*/

Angular code
app.component.html
<app-top-bar></app-top-bar>
<div class="container">
<router-outlet></router-outlet>
</div>
<!--
Copyright Google LLC. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at https://angular.io/license
-->

Angular code
product-list.component.ts
import { Component } from '@angular/core';
import { products } from '../products';
@Component({
selector: 'app-product-list',
templateUrl: './product-list.component.html',
styleUrls: ['./product-list.component.css']
})
export class ProductListComponent {
products = [...products];
share() {
window.alert('The product has been shared!');
}
onNotify() {
window.alert('You will be notified when the product goes on sale');
}
}
/*
Copyright Google LLC. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at https://angular.io/license
*/

Angular code
product-list.component.html
<h2>Products</h2>
<div *ngFor="let product of products">
<h3>
<a
[title]="product.name + ' details'"
[routerLink]="['/products', product.id]">
{{ product.name }}
</a>
</h3>
<p *ngIf="product.description">
Description: {{ product.description }}
</p>
<button type="button" (click)="share()">
Share
</button>
<app-product-alerts
[product]="product"
(notify)="onNotify()">
</app-product-alerts>
</div>
<!--
Copyright Google LLC. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at https://angular.io/license
-->

Angular code


Basic information
React is a library which is maintained by Meta and a community
- Fiber
- Virtual DOM
- JSX
- HOC, hooks
- State Management - Redux, Mobx, etc.


Basic information


Who uses the framework?
Facebook, Instagram, Netflix, Microsoft, Slack
New York Times, Yahoo, Pinterest, Atlassian
Airbnb, Dropbox, Asana, Storybook
Whatsapp, Khan Academy, Codecademy, Intercom
React code
app.js
import { useState } from 'react';
export default function Form() {
const [firstName, setFirstName] = useState('');
const [lastName, setLastName] = useState('');
const fullName = firstName + ' ' + lastName;
function handleFirstNameChange(e) {
setFirstName(e.target.value);
}
function handleLastNameChange(e) {
setLastName(e.target.value);
}
return (
<>
<h2>Let’s check you in</h2>
<label>
First name:{' '}
<input
value={firstName}
onChange={handleFirstNameChange}
/>
</label>
<label>
Last name:{' '}
<input
value={lastName}
onChange={handleLastNameChange}
/>
</label>
<p>
Your ticket will be issued to: <b>{fullName}</b>
</p>
</>
);
}

React code
app.js
import { useState } from 'react';
function Panel({ title, children }) {
const [isActive, setIsActive] = useState(false);
return (
<section className="panel">
<h3>{title}</h3>
{isActive ? (
<p>{children}</p>
) : (
<button onClick={() => setIsActive(true)}>
Show
</button>
)}
</section>
);
}
export default function Accordion() {
return (
<>
<h2>Almaty, Kazakhstan</h2>
<Panel title="About">
With a population of about 2 million, Almaty is Kazakhstan's largest city. From 1929 to 1997, it was its capital city.
</Panel>
<Panel title="Etymology">
The name comes from <span lang="kk-KZ">алма</span>, the Kazakh word for "apple" and is often translated as "full of apples". In fact, the region surrounding Almaty is thought to be the ancestral home of the apple, and the wild <i lang="la">Malus sieversii</i> is considered a likely candidate for the ancestor of the modern domestic apple.
</Panel>
</>
);
}

React code


Basic information
Vue is a framework which is maintained by Core Team Members (Evan You, etc.)
- Virtual DOM
- HTML, directives
- EventEmitter
- Vuex State Management
- MVVM


Basic information
Vue is a framework which is maintained by Core Team Members (Evan You, etc.)
- Two way binding
- Reactivity data
- Plugins, etc.


Basic information


Who uses the framework?
Alibaba, Xiaomi, Gitlab, Laravel, Laracasts
Euro News, Adobe, Reuters, Codeship
Modus Create, Range, StoreKit, DevExpress, WizzAir, Behance
Vehikl, HeroDevs, etc.
Vue code
app.js
<!--
This example demonstrates handling user input with the v-on directive.
-->
<script setup>
import { ref } from 'vue'
const message = ref('Hello World!')
function reverseMessage() {
// Access/mutate the value of a ref via
// its .value property.
message.value = message.value.split('').reverse().join('')
}
function notify() {
alert('navigation was prevented.')
}
</script>
<template>
<!--
Note we don't need .value inside templates because
refs are automatically "unwrapped" in templates.
-->
<h1>{{ message }}</h1>
<!--
Bind to a method/function.
The @click syntax is short for v-on:click.
-->
<button @click="reverseMessage">Reverse Message</button>
<!-- Can also be an inline expression statement -->
<button @click="message += '!'">Append "!"</button>
<!--
Vue also provides modifiers for common tasks
such as e.preventDefault() and e.stopPropagation()
-->
<a href="https://vuejs.org" @click.prevent="notify">
A link with e.preventDefault()
</a>
</template>
<style>
button, a {
display: block;
margin-bottom: 1em;
}
</style>

Vue code


What are the differences and similarities?


- Difficulty of learning
- Support in further development?
- Framework, Library?
- MVC, MVVM, V?
- State management: Vuex, NGRX, Redux, Mobx, etc.
- Virtual DOM, incremental DOM?
- HTML, JSX?
What framework is worth to be chosen by you :)


- Team work experience
- Time to study
- Project size
- Community, support
- Popularity, availability of developers
- Technology stack. Framework has one, the library has a different set of packages
What framework is worth to be chosen by you :)


- Do you like to write in JavaScript?
- Do you like TypeScript, OOP, GRASP principles?
- Do you want to learn the framework quickly?
- Do you like to separate HTML and JavaScript?
- Don't like to deal with forms, set up validation, error output?
What framework is worth to be chosen by you :)


- Do you want to get a good ready-made architectural solution?
- Do you want to get easy convenient reactivity with a bunch of boxed solutions with computed properties and watchers?
- Do you want and do you know how to optimize such reactivity solutions?
- Do you like Facebook, Google, Evan You?
What's under the hood?


Angular uses a ready-made set of good solutions
- MVC, DI, OOP
- TypeScript
- NGRX
- Zone.js
- Observable (RXJS)
- Signals
What's under the hood?


React builds user interfaces based on components
- Local state: setState, useState
- Props
- State management: Redux, Mobx, etc.
- Context
- PureComponent, shouldComponentUpdate, useMemo, useCallback
What's under the hood?


Vue combines a good solution from Angular and React
- Reactivity data using getters and setters
- Object.defineProperty, Proxy
- Computed properties, watchers, etc.
- React things: props, Virtual DOM, etc.
- Angular things: HTML, directives, etc.
- Composition API, Vuex, etc.
What reactivity each framework is based on?


Type of reactivity: push and pull
- Angular: RXJS, NGRX, Signals
- Vue: Reactivity data, Object.defineProperty, Proxy, Vuex
- React: Detects changes props, states, contexts each component and starts re-rendering the component and gives tools for perform this
re-render
Recommendation
Core JavaScript, algorithms



That's all


Questions


Copy of Game of JS frameworks
By andreyvalerievich
Copy of Game of JS frameworks
- 123