15
Introduction à Node.JS Vincent Peybernes

Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Embed Size (px)

Citation preview

Page 1: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

Vincent Peybernes

Page 2: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

Une plate-forme de développement d'application en JavaScript open source.

Node.js is a platform built on Chrome's JavaScript runtime for easily building fast,

scalable network applications.nodejs.org

Page 3: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

• Plateforme open-source• Un exécutable ‘node’• Le moteur JavaScript V8• Une API filesystem & network• Un single-thread event loop• Une API asynchrone

Page 4: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

• Supporte tout HTTP/1.1• Connexions persistantes et pipelines• Système de cache amélioré• Sécurité améliorée

Node.JS => HTTP/1.1

www8.org

Page 5: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

• Une implémentation de CommonJS : require()

• Un dépôt de module : NPM (plus de 15k modules)

• Une API pour l’exposition des modules

Node.JS => modulaire

application cmd-conf

• Majorité des modules open-source (GitHub)

Page 6: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

Le roi ordonne et traite dans l’ordre où les exécutants reviennent.

Node.JS => API asynchrone

Page 7: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

• Pas de traitement simultané au sein d’un thread

• Long calcule = attente

Node.JS => mono tâche

Mais...

• Module système naturellement multi-thread• Fork et spawn• Clustering

Page 8: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

• Appel de commande système : child_process.

• Javascript V8 (librairie C++)

• Module Addon C/C++• Mapping d’objet C++• Appel de callback JS par C++

Node.JS + C++ = ♥

Page 9: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

• Pas de système de incorporé natif.• Module de driver multiple

Node.JS et le stockage de donnée.

• NoSQL : Redis, MongoDB...• SQL : MySQL, OracleDB, MS SQL, PostGres...

Page 10: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

• File System• HTTP/SSL/URL• IO de la console• Stream• Crypto• DNS (résolution)• VM JavaScript• Socket• Event• ...

Node.JS et plus si affinité...

Page 11: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

• Application temps réel• Application à forte disponibilité

• Traitement léger• Donnée à faible typage• JavaScript != POO

Concrètement

Page 12: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

Qui aime Node.JS ?

Yahoo! Manhattan

https://github.com/joyent/node/wikiProjects, Applications, and Companies Using Node

Page 13: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

• Version 0.8.12• Refactor d’API• Recul insuffisant• Interfaçage incomplet avec d’autre outils

Pourquoi pas vous ?

À proposer au client avec précaution.

Page 14: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

Démo

Socket Chat

http://browserquest.mozilla.org/

http://valtech-demo.techniv.fr/

Page 15: Introduction à Node.JS Vincent Peybernes. Introduction à Node.JS Une plate-forme de développement d'application en JavaScript open source. Node.js is

Introduction à Node.JS

public.haveQuestion(function(){ speaker.log("bla bla");});