SlideShare una empresa de Scribd logo
1 de 60
NodeJS future
NodeJS 8.9
NodeJS 9.2
NodeJS VNext
ES6
ES7
ES8
And Michael Jackson…
@sebastienpertus (from Microsoft  )
ES6 / ES7 / ES2015 / ES2016
" ES7 is ES2016"
" ES6 is ES2015 "
" Too long for twitter … "
" How many people here are going to say ES2016 "
" Nobody, good ! "
Ecmascript from past to future
ES 8
ES 7
(ES 2016)
ES 6
(ES 2015)
ES 5
ES 3 Core features
1997 ~~ 1999
new functions
strict mode, json
2009
class, promises, generators,
arrow functions, new syntax
and concepts …
2015
Exponential (**),
array.includes,
2016
Where we are today
ES6 : Where we are today
• > 94%
• > 96% in nighty builds
http://kangax.github.io/compat-table/es6/
ES7 : Where we are today
Chakra
SpiderMonkey
V8
JavaScript Core
Nighty builds
TypeScript 2.6
Transpiler vs Compiler
Transpiler
is a specific term for taking source
code written in one language and
transforming into another
language that has a similar level of
abstraction
Compiler
is the general term for taking
source code written in one
language and transforming into
another.
"CoffeeScript is to Ruby as TypeScript is to Java/C#/C++." - Luke Hoban
The feature gap
And what about Node ?
Node version
Node.js 9.2.0 14/11/2017
Node.js 8.9.1 07/11/2017
Node.js 7.10.1 11/07/2017
Node.js 6.11.4 03/10/2017
ES support : http://node.green/
• > 98% from node 7.5 +
Enhancement Proposals : node-eps
• https://github.com/nodejs/node-eps
• Stream
• ES modules
• Url
• Asynchronous API
NodeJS CTC
• Node.js Core Technical Committee & Collaborators
• https://github.com/nodejs/CTC
From Node 7.5 (with love)
Not the future anymore… but maybe we should talk about …
ES5 : Async Programming
/* Callback Hell */
myFirstOperation(function(err, firstResult){
mySecondOperation(firstResult, function(err, secondResult){
myThirdOperation(secondResult, function(err, thirdResult){
/*
HELL !!!
*/
});
});
});
ES6 : Async Programming
/* Promises */
var myFirstPromise = new Promise(function (resolve, reject) {
// Do something
var everyhtingIsOk = true;
var result = { a: 12, b: "ok" };
if (everyhtingIsOk) {
resolve(result);
} else {
reject(Error('Something went wrong'));
}
});
ES6 : Async Programming
/* Promises */
myFirstPromise()
.then(firstResult => mySecondPromise(firstResult))
.then(secondResult => myThirdPromise(secondResult))
.then(thirdResult => {
/*
Code utilisant le 3ème résultat
*/
}).catch(err => {
/*
Gestion de l’erreur, quelque soit l’étape où elle a eu lieu
*/
});
ES7 : Async Programming
/* async await */
async function myOperations(){
const firstResult = await myFirstOperation();
const secondResult = await mySecondOperation(firstResult);
const thirdResult = await myThirdOperation(secondResult);
/*
Code
*/
};
try {
myOperations();
} catch (err) {
/*
Gestion de l’erreur, quelque soit l’étape où elle a eu lieu
*/
}
async / await
Node 8 / NPM 5
NPM 5.0.0
• --save by default
• Autmaticaly create a package-
lock.json
• npm cache rewrited
• You will have to ree-download all
your package cache
• npm fallback automaticaly to cache
if no network
• -- prefer-offline
• -- prefer-online
• -- offline
• Large package download issue
resolved
http://www.standardista.com/six-
best-new-features-in-npm-5/
Nouveautés Node 8
• Say hello to V8 5.8
• Forward compatibility with V8 5.9 and V8 6.0
Node.js API (N-API)
• Platform for building native addons.
• Independant from the underlying JavaScript Runtime
• API is Application Binary Interface (ABI) stable accross Node.JS
• Every native addons will be compatible with
• Chrome V8
• ChakraCore (https://github.com/nodejs/node-chakracore/ )
Node 8 : async_hooks
async_hooks : nodejs async tracing
“tracking the lifetime of asynchronous resources created inside a
Node.js application”
const async_hooks = require('async_hooks');
const cid = async_hooks.currentId();
const tid = async_hooks.triggerId();
const asyncHook = async_hooks.createHook({ init, before, after, destroy });
asyncHook.enable();
function init(asyncId, type, triggerId, resource) {}
function before(asyncId) {}
function after(asyncId) {}
function destroy(asyncId) {}
Node 8 : WHATWG URL Standard
• URL Standard : https://url.spec.whatwg.org/
• The URL Standard defines URLs, domains, IP addresses, the
application/x-www-form-urlencoded format, and their API.
• The URL standard takes the following approach towards making URLs
fully interoperable
import * as urlUtility from 'url';
const myUrl = new urlUtility.URL('/a/path', 'https://example.org/');
console.log(myUrl.toString());
Node 8 : util.promisify()
• util.promisify() API that allows standard Node.js callback style APIs to
be wrapped in a function that returns a Promise
• Callback Style : (err, value) => {}
function breeze(a: number, callback: (err: any, value?: number) => void) {
if (a > 10) {
callback(undefined, a * a);
} else {
callback("a must be greater than 10");
}
}
const awaitableBreeze = util.promisify(breeze);
NodeJS Future (9, 10)
Les Modules
CommonJS / AMD / ESM ?
Modules in Browser
• Safari 10.1
• Chrome canary 60
• Firefox 54
• Edge 15
With FLAGS
https://jakearchibald.com/2017/es-modules-in-browsers/
NodeJS modules : CommonJS
• Synchronous
• Evaluated during runtime
ESM vs CJS
export class person {
getFullName() { return `${this.lastName} ${this.firstName}`; }
}
import * as people from './person';
var p = new people.person();
class person {
getFullName() { return `${this.lastName} ${this.firstName}`; }
}
exports.person = person;
const people = require("./person");
var p = new people.person();
ESM modules in NodeJS
• https://github.com/nodejs/node-eps/blob/master/002-es-
modules.md
• Implement interoperability for EcmaScript 6 modules (ESM) and
Node’s existing module system (CJS)
• Allow a common module syntax for Browser (ES6 spec) and Server
side
EF modules vs NodeJS modules
• CommonJS is a dynamic loader modules system
• Synchronous
• Evaluated during runtime
• ES is a static loader modules system
• Asynchronous
• Evaluated during parse time
Example
console.log('entry eval');
require('middle');
console.log('entry done);
export {};
console.log('middle eval');
require('right');
console.log('middle done');
entry eval
middle eval
right eval
right done
middle done
entry done
export {};
console.log('right eval');
console.log('right done');
entry eval
entry done
middle eval
middle done
right eval
right done
sync async
What Node wants to :
Node wants to be able to :
• Import a CJS module from ES (import from 'commonjs-module’ )
• Import a ESM module from CJS (require('es6-module’))
ESM vs CJS. Solutions evaluated ?
• Does Node.js want to ship a synchronous or asynchronous module
loader?
• Returning a promise (async)
• Returning an object (sync)
• Both ?
• Multiple Solutions investigated:
• Use CJS (require) for actuals .js files / Use ESM (import) with a newly file .mjs
• Use a double parsing time
• Config file
• Obiwan Kenobi
Detectiong CJS / ES Modules
• https://github.com/nodejs/node/wiki/ES6-Module-Detection-in-Node
• https://github.com/dherman/defense-of-dot-js/blob/master/proposal.md
References
• http://codeheroics.github.io/talks/nodemjs/
• https://medium.com/the-node-js-collection/an-update-on-es6-modules-in-
node-js-42c958b890c
• https://hackernoon.com/node-js-tc-39-and-modules-a1118aecf95e
• https://medium.com/webpack/the-state-of-javascript-modules-
4636d1774358
• https://github.com/nodejs/node-eps/blob/master/002-es6-modules.md
• https://github.com/nodejs/node-eps/issues/57 (mjs tradeoff)
• http://2ality.com/2017/01/babel-esm-spec-mode.html
• http://2ality.com/2017/05/es-module-specifiers.html
Michael Jackson Script
• Code compiler must know if it’s a CJS or ES module
• In certain circumstance an import * from ‘foo’ could be a
CJS module or an ES module (same syntax !)
• Node.js will need to have some kind of mechanism for
identifying in advance what kind of file is being loaded
• foo.js will treat foo.js as CommonJS
• bar.mjs will treat bar.mjs as an ESM Module.
console.log(`Module load ${Date()}`)
Or ..
Changing ES Modules spec in ECMASCRIPT :
• A module allways requires an import or an export
• All modules are parsed. If it doesn't contain any of these statements,
it is not an ES Module.
Or …
Would be recognized as a CommonJS module, while
Would be an ES module.
console.log(`Module load ${Date()}`)
console.log(`Module load ${Date()}`)
export{}
But…
•It works within Babel / Typescript !!
•Under the hood, it’s just a
transpilation to CJS Modules 
Timeline
• At the current point in time, there are still a number of specification
and implementation issues that need to happen on the ES6 and
Virtual Machine side of things before Node.js can even begin working
up a supportable implementation of ES6 modules. Work is in progress
but it is going to take some time —
We’re currently looking at around a year at least.
• Node V10 « around October 2018 »
https://github.com/nodejs/Release
ES6 : Modules (ESM)
• TypeScript : Transpiling ESM Syntax in CommonJS modules
• Node.js 9+ : Implementation with flags
import {Person} from "./People";
import {Person, Material as M} from "./People";
import * as People from "./People";
import guy from './People';
https://medium.com/web-on-the-edge/es-modules-in-node-today-32cff914e4b
ES Modules in Node Today
with polyfil @std/esm
@std/esm
Works from Node.js 4
Use *.mjs modules file extension
Questions ?
@sebastienpertus

Más contenido relacionado

La actualidad más candente

Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node jsAkshay Mathur
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejsAmit Thakkar
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginnerManinder Singh
 
Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST APIFabien Vauchelles
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsMarcus Frödin
 
Getting started with developing Nodejs
Getting started with developing NodejsGetting started with developing Nodejs
Getting started with developing NodejsPhil Hawksworth
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Edureka!
 
All aboard the NodeJS Express
All aboard the NodeJS ExpressAll aboard the NodeJS Express
All aboard the NodeJS ExpressDavid Boyer
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJSHüseyin BABAL
 
Nodejs Event Driven Concurrency for Web Applications
Nodejs Event Driven Concurrency for Web ApplicationsNodejs Event Driven Concurrency for Web Applications
Nodejs Event Driven Concurrency for Web ApplicationsGanesh Iyer
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaNurul Ferdous
 
Server Side Event Driven Programming
Server Side Event Driven ProgrammingServer Side Event Driven Programming
Server Side Event Driven ProgrammingKamal Hussain
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialTom Croucher
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming  Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming Tom Croucher
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developerscacois
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)Chris Cowan
 

La actualidad más candente (20)

Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginner
 
NodeJS
NodeJSNodeJS
NodeJS
 
Node ppt
Node pptNode ppt
Node ppt
 
Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST API
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
 
Getting started with developing Nodejs
Getting started with developing NodejsGetting started with developing Nodejs
Getting started with developing Nodejs
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
 
All aboard the NodeJS Express
All aboard the NodeJS ExpressAll aboard the NodeJS Express
All aboard the NodeJS Express
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJS
 
Nodejs Event Driven Concurrency for Web Applications
Nodejs Event Driven Concurrency for Web ApplicationsNodejs Event Driven Concurrency for Web Applications
Nodejs Event Driven Concurrency for Web Applications
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
 
Server Side Event Driven Programming
Server Side Event Driven ProgrammingServer Side Event Driven Programming
Server Side Event Driven Programming
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming  Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
 
Nodejs intro
Nodejs introNodejs intro
Nodejs intro
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 

Similar a Future of NodeJS

(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of usStefan Adolf
 
Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usStefan Adolf
 
EcamScript (ESM) It's about time !
EcamScript (ESM) It's about time !EcamScript (ESM) It's about time !
EcamScript (ESM) It's about time !Sébastien Pertus
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.jsChris Cowan
 
Helma / RingoJS – Vienna.js Minitalk
Helma / RingoJS – Vienna.js MinitalkHelma / RingoJS – Vienna.js Minitalk
Helma / RingoJS – Vienna.js MinitalkPhilipp Naderer
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express Jeetendra singh
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
Web (dis)assembly
Web (dis)assemblyWeb (dis)assembly
Web (dis)assemblyShakacon
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.jsYoann Gotthilf
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.Mike Brevoort
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsOhad Kravchick
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevFelix Geisendörfer
 
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016Susan Potter
 

Similar a Future of NodeJS (20)

(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us
 
Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of us
 
EcamScript (ESM) It's about time !
EcamScript (ESM) It's about time !EcamScript (ESM) It's about time !
EcamScript (ESM) It's about time !
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
Helma / RingoJS – Vienna.js Minitalk
Helma / RingoJS – Vienna.js MinitalkHelma / RingoJS – Vienna.js Minitalk
Helma / RingoJS – Vienna.js Minitalk
 
OUTDATED (Encore)
OUTDATED (Encore)OUTDATED (Encore)
OUTDATED (Encore)
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Node intro
Node introNode intro
Node intro
 
Web (dis)assembly
Web (dis)assemblyWeb (dis)assembly
Web (dis)assembly
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Jaap : node, npm & grunt
Jaap : node, npm & gruntJaap : node, npm & grunt
Jaap : node, npm & grunt
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.js
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
 
ES6 - JavaCro 2016
ES6 - JavaCro 2016ES6 - JavaCro 2016
ES6 - JavaCro 2016
 
Discovering OpenBSD on AWS
Discovering OpenBSD on AWSDiscovering OpenBSD on AWS
Discovering OpenBSD on AWS
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
 
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
 

Último

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 

Último (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 

Future of NodeJS

  • 1. NodeJS future NodeJS 8.9 NodeJS 9.2 NodeJS VNext ES6 ES7 ES8 And Michael Jackson… @sebastienpertus (from Microsoft  )
  • 2. ES6 / ES7 / ES2015 / ES2016 " ES7 is ES2016" " ES6 is ES2015 " " Too long for twitter … " " How many people here are going to say ES2016 " " Nobody, good ! "
  • 3. Ecmascript from past to future ES 8 ES 7 (ES 2016) ES 6 (ES 2015) ES 5 ES 3 Core features 1997 ~~ 1999 new functions strict mode, json 2009 class, promises, generators, arrow functions, new syntax and concepts … 2015 Exponential (**), array.includes, 2016
  • 4. Where we are today
  • 5. ES6 : Where we are today • > 94% • > 96% in nighty builds http://kangax.github.io/compat-table/es6/
  • 6. ES7 : Where we are today Chakra SpiderMonkey V8 JavaScript Core Nighty builds
  • 8. Transpiler vs Compiler Transpiler is a specific term for taking source code written in one language and transforming into another language that has a similar level of abstraction Compiler is the general term for taking source code written in one language and transforming into another. "CoffeeScript is to Ruby as TypeScript is to Java/C#/C++." - Luke Hoban
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 15.
  • 16. And what about Node ?
  • 17. Node version Node.js 9.2.0 14/11/2017 Node.js 8.9.1 07/11/2017 Node.js 7.10.1 11/07/2017 Node.js 6.11.4 03/10/2017
  • 18. ES support : http://node.green/ • > 98% from node 7.5 +
  • 19. Enhancement Proposals : node-eps • https://github.com/nodejs/node-eps • Stream • ES modules • Url • Asynchronous API
  • 20. NodeJS CTC • Node.js Core Technical Committee & Collaborators • https://github.com/nodejs/CTC
  • 21. From Node 7.5 (with love) Not the future anymore… but maybe we should talk about …
  • 22. ES5 : Async Programming /* Callback Hell */ myFirstOperation(function(err, firstResult){ mySecondOperation(firstResult, function(err, secondResult){ myThirdOperation(secondResult, function(err, thirdResult){ /* HELL !!! */ }); }); });
  • 23. ES6 : Async Programming /* Promises */ var myFirstPromise = new Promise(function (resolve, reject) { // Do something var everyhtingIsOk = true; var result = { a: 12, b: "ok" }; if (everyhtingIsOk) { resolve(result); } else { reject(Error('Something went wrong')); } });
  • 24. ES6 : Async Programming /* Promises */ myFirstPromise() .then(firstResult => mySecondPromise(firstResult)) .then(secondResult => myThirdPromise(secondResult)) .then(thirdResult => { /* Code utilisant le 3ème résultat */ }).catch(err => { /* Gestion de l’erreur, quelque soit l’étape où elle a eu lieu */ });
  • 25. ES7 : Async Programming /* async await */ async function myOperations(){ const firstResult = await myFirstOperation(); const secondResult = await mySecondOperation(firstResult); const thirdResult = await myThirdOperation(secondResult); /* Code */ }; try { myOperations(); } catch (err) { /* Gestion de l’erreur, quelque soit l’étape où elle a eu lieu */ }
  • 27.
  • 28. Node 8 / NPM 5
  • 29. NPM 5.0.0 • --save by default • Autmaticaly create a package- lock.json • npm cache rewrited • You will have to ree-download all your package cache • npm fallback automaticaly to cache if no network • -- prefer-offline • -- prefer-online • -- offline • Large package download issue resolved
  • 31.
  • 32. Nouveautés Node 8 • Say hello to V8 5.8 • Forward compatibility with V8 5.9 and V8 6.0
  • 33. Node.js API (N-API) • Platform for building native addons. • Independant from the underlying JavaScript Runtime • API is Application Binary Interface (ABI) stable accross Node.JS • Every native addons will be compatible with • Chrome V8 • ChakraCore (https://github.com/nodejs/node-chakracore/ )
  • 34.
  • 35. Node 8 : async_hooks async_hooks : nodejs async tracing “tracking the lifetime of asynchronous resources created inside a Node.js application” const async_hooks = require('async_hooks'); const cid = async_hooks.currentId(); const tid = async_hooks.triggerId(); const asyncHook = async_hooks.createHook({ init, before, after, destroy }); asyncHook.enable(); function init(asyncId, type, triggerId, resource) {} function before(asyncId) {} function after(asyncId) {} function destroy(asyncId) {}
  • 36. Node 8 : WHATWG URL Standard • URL Standard : https://url.spec.whatwg.org/ • The URL Standard defines URLs, domains, IP addresses, the application/x-www-form-urlencoded format, and their API. • The URL standard takes the following approach towards making URLs fully interoperable import * as urlUtility from 'url'; const myUrl = new urlUtility.URL('/a/path', 'https://example.org/'); console.log(myUrl.toString());
  • 37. Node 8 : util.promisify() • util.promisify() API that allows standard Node.js callback style APIs to be wrapped in a function that returns a Promise • Callback Style : (err, value) => {} function breeze(a: number, callback: (err: any, value?: number) => void) { if (a > 10) { callback(undefined, a * a); } else { callback("a must be greater than 10"); } } const awaitableBreeze = util.promisify(breeze);
  • 39.
  • 40. Les Modules CommonJS / AMD / ESM ?
  • 41. Modules in Browser • Safari 10.1 • Chrome canary 60 • Firefox 54 • Edge 15 With FLAGS https://jakearchibald.com/2017/es-modules-in-browsers/
  • 42. NodeJS modules : CommonJS • Synchronous • Evaluated during runtime
  • 43. ESM vs CJS export class person { getFullName() { return `${this.lastName} ${this.firstName}`; } } import * as people from './person'; var p = new people.person(); class person { getFullName() { return `${this.lastName} ${this.firstName}`; } } exports.person = person; const people = require("./person"); var p = new people.person();
  • 44. ESM modules in NodeJS • https://github.com/nodejs/node-eps/blob/master/002-es- modules.md • Implement interoperability for EcmaScript 6 modules (ESM) and Node’s existing module system (CJS) • Allow a common module syntax for Browser (ES6 spec) and Server side
  • 45. EF modules vs NodeJS modules • CommonJS is a dynamic loader modules system • Synchronous • Evaluated during runtime • ES is a static loader modules system • Asynchronous • Evaluated during parse time
  • 46. Example console.log('entry eval'); require('middle'); console.log('entry done); export {}; console.log('middle eval'); require('right'); console.log('middle done'); entry eval middle eval right eval right done middle done entry done export {}; console.log('right eval'); console.log('right done'); entry eval entry done middle eval middle done right eval right done sync async
  • 47. What Node wants to : Node wants to be able to : • Import a CJS module from ES (import from 'commonjs-module’ ) • Import a ESM module from CJS (require('es6-module’))
  • 48. ESM vs CJS. Solutions evaluated ? • Does Node.js want to ship a synchronous or asynchronous module loader? • Returning a promise (async) • Returning an object (sync) • Both ? • Multiple Solutions investigated: • Use CJS (require) for actuals .js files / Use ESM (import) with a newly file .mjs • Use a double parsing time • Config file • Obiwan Kenobi
  • 49.
  • 50. Detectiong CJS / ES Modules • https://github.com/nodejs/node/wiki/ES6-Module-Detection-in-Node • https://github.com/dherman/defense-of-dot-js/blob/master/proposal.md
  • 51. References • http://codeheroics.github.io/talks/nodemjs/ • https://medium.com/the-node-js-collection/an-update-on-es6-modules-in- node-js-42c958b890c • https://hackernoon.com/node-js-tc-39-and-modules-a1118aecf95e • https://medium.com/webpack/the-state-of-javascript-modules- 4636d1774358 • https://github.com/nodejs/node-eps/blob/master/002-es6-modules.md • https://github.com/nodejs/node-eps/issues/57 (mjs tradeoff) • http://2ality.com/2017/01/babel-esm-spec-mode.html • http://2ality.com/2017/05/es-module-specifiers.html
  • 52. Michael Jackson Script • Code compiler must know if it’s a CJS or ES module • In certain circumstance an import * from ‘foo’ could be a CJS module or an ES module (same syntax !) • Node.js will need to have some kind of mechanism for identifying in advance what kind of file is being loaded • foo.js will treat foo.js as CommonJS • bar.mjs will treat bar.mjs as an ESM Module. console.log(`Module load ${Date()}`)
  • 53. Or .. Changing ES Modules spec in ECMASCRIPT : • A module allways requires an import or an export • All modules are parsed. If it doesn't contain any of these statements, it is not an ES Module.
  • 54. Or … Would be recognized as a CommonJS module, while Would be an ES module. console.log(`Module load ${Date()}`) console.log(`Module load ${Date()}`) export{}
  • 55. But… •It works within Babel / Typescript !! •Under the hood, it’s just a transpilation to CJS Modules 
  • 56. Timeline • At the current point in time, there are still a number of specification and implementation issues that need to happen on the ES6 and Virtual Machine side of things before Node.js can even begin working up a supportable implementation of ES6 modules. Work is in progress but it is going to take some time — We’re currently looking at around a year at least. • Node V10 « around October 2018 » https://github.com/nodejs/Release
  • 57. ES6 : Modules (ESM) • TypeScript : Transpiling ESM Syntax in CommonJS modules • Node.js 9+ : Implementation with flags import {Person} from "./People"; import {Person, Material as M} from "./People"; import * as People from "./People"; import guy from './People';
  • 58.
  • 59. https://medium.com/web-on-the-edge/es-modules-in-node-today-32cff914e4b ES Modules in Node Today with polyfil @std/esm @std/esm Works from Node.js 4 Use *.mjs modules file extension

Notas del editor

  1. Quand vous compilez du TypeScript, vous transformez votre code en JavaScript. Comme TypeScript est trés proche de JavaScript (ES6+), vous pouvez dire que vous Transpillez.
  2. Démo : Créer un nouveau projet TS avec Node Montrer l’intelissense Monter comment créer un server express rapidement npm install express npm install @types/express import * as express from 'express'; var app = express(); app.use("/", (req, res) => { res.send("Hello World"); }); app.listen(3000); Créer une classe Person pour montrer le passage de E5, ES6 dans TS export class Person{ firstName:string; lastName:string; constructor(fn:string, ln:string, public age=27){ this.firstName = fn; this.lastName = ln; } getFullName(){ return `Full name : ${this.firstName} ${this.lastName} ${this.age} ` } } Montrer comment on lance VS Code avec TS pour l’expérience de débuggage
  3. import fetch from 'node-fetch’; // Demo 1 créer un waiter à partir d'une promise async function wait(delay:number){ return new Promise((rs, rj) => { setTimeout(rs, delay); }); } // Démo : Ajouter node-fecth app.use("/", async (req, res) => { fetch('http://www.google.com').then((v) => { let responseText = `Hello ${p.getFullName()}<br /> ${v.statusText} `; res.send(responseText); }); })
  4. Lancer nvs et lancer chakra core Ajouter dans le rendu de la page [${process.execPath}]
  5. import * as util from "util"; declare module 'util' { export function promisify(fn: Function): (...args: any[]) => Promise<any>; } function breeze(a: number, callback: (err: any, value?: number) => void) { if (a > 10) { callback(undefined, a * a); } else { callback("a must be greater than 10"); } } const breezeAsync = util.promisify(breeze);
  6. export class Person { firstName: string; lastName: string; constructor(fn: string, ln: string, public age = 27) { this.firstName = fn; this.lastName = ln; } getFullName() { return `Full name : ${this.firstName} ${this.lastName} ${this.age} ` } } export class Kid { } export class adzdazddadadzad { } export class people { kid = () => new Kid(); person = (fn, ln, age) => new Person(fn, ln, age); az = () => new Kid() } var pp = new people(); export default pp;
  7. export class Person { constructor(fn, ln, age = 27) { this.firstName = fn; this.lastName = ln; this.age = age; } getFullName() { return `Full name : ${this.firstName} ${this.lastName} ${this.age} ` } } export class Kid { } export class adzdazddadadzad { } export class people { person(fn, ln, age) { return new Person(fn, ln, age) } kid() { return new Kid() } ad() { return new adzdazddadadzad(); } } var pp = new people(); export default pp;