SlideShare una empresa de Scribd logo
1 de 140
Descargar para leer sin conexión
Friday, September 28, 12
WER BIN ICH?


    • Sebastian            Springer

    • https://github.com/sspringer82

    • @basti_springer

    • Teamlead             @ Mayflower



Friday, September 28, 12
WER SEID IHR?




Friday, September 28, 12
LET’S GO




Friday, September 28, 12
THEMEN
    • Installation                   • Dateisystem

    • Kernkomponenten                • Datenbanken

    • Beispiel                       • Promises

    • Module                         • Child   Processes

    • Eigener              Code      • Websockets

    • Asynchronität                  • Debugger

    • NPM                            • Testing

Friday, September 28, 12
INSTALLATION




Friday, September 28, 12
v0.8.11
                                v0.8.10
                           NODE-V0.8.9




Friday, September 28, 12
PAKETE

  • Unix
      http://nodejs.org/dist/v0.8.9/node-v0.8.9-linux-x64.tar.gz

  • Mac
      http://nodejs.org/dist/v0.8.9/node-v0.8.9.pkg

  • Windows
      http://nodejs.org/dist/v0.8.9/x64/node-v0.8.9-x64.msi


Friday, September 28, 12
HTTP://NODEJS.ORG/
                             DOWNLOAD/




Friday, September 28, 12
SOURCE




Friday, September 28, 12
HAT ES GEKLAPPT?




Friday, September 28, 12
DIE KERNKOMPONENTEN




Friday, September 28, 12
V8


    • Schneller            Zugriff auf Eigenschaften

    • Dynamische              Erstellung von Maschinencode

    • Garbage              Collection




Friday, September 28, 12
V8 - FAST PROPERTY ACCESS




Friday, September 28, 12
V8 - FAST PROPERTY ACCESS




Friday, September 28, 12
V8 - FAST PROPERTY ACCESS




Friday, September 28, 12
MASCHINENCODE




Friday, September 28, 12
V8 - GARBAGE COLLECTION


    • Programmausführung           wird angehalten

    • Es        wird nur ein Teil des Object Heaps geprüft

    • V8         kennt alle Objekte und Pointer im Speicher




Friday, September 28, 12
LIBEV


         • Full-featured        and high-performance event loop

         • libevent        als Basis

         • Alles, außer        der eigene Code ist parallel und asynchron




Friday, September 28, 12
LIBEIO


    • Eventbasierte           Bibliothek für asynchrone I/O Operationen

    • Ergänzung            zu libev

    • Features: Öffnen, Lesen, Schreiben, Löschen, etc.

    • Modul: fs




Friday, September 28, 12
C-ARES



    • asynchrone           DNS Auflösung

    • Modul: dns




Friday, September 28, 12
EVCOM


    • Basiert              auf libev

    • Eventbasierte               Library für Stream Sockets

    • Modul: net




Friday, September 28, 12
EIN KLEINES BEISPIEL




Friday, September 28, 12
INTERAKTIV




Friday, September 28, 12
WEBSERVER




Friday, September 28, 12
WEBSERVER




Friday, September 28, 12
WEBSERVER




Friday, September 28, 12
MODULE




Friday, September 28, 12
VERFÜGBARE MODULE

    • Stream                           • OS

    • Events                           • Debugger

    • File         System              • Cluster

    • Net                              • Util

    • HTTP                             • Buffer

    • Child                Processes   • UDP

Friday, September 28, 12
HTTP://NODEJS.ORG/API/




Friday, September 28, 12
STABILITÄTSINDEX

    •0       - Deprecated

    •1       - Experimental

    •2       - Unstable

    •3       - Stable

    •4       - API Frozen

    •5       - Locked

Friday, September 28, 12
STABILITÄTSINDEX




Friday, September 28, 12
MODULE VERWENDEN




Friday, September 28, 12
EIGENE KLASSEN DEFINIEREN




Friday, September 28, 12
...IM BROWSER




Friday, September 28, 12
...IN NODE
                             Human.js




Friday, September 28, 12
...IN NODE

                              server.js




Friday, September 28, 12
ASYNCHRONE
                           PROGRAMMIERUNG



Friday, September 28, 12
DATEI LESEN
                           node.js   Betriebssystem




                                               Leseoperation




Friday, September 28, 12
DATEI LESEN




Friday, September 28, 12
DATEI LESEN




Friday, September 28, 12
DATEI LESEN




Friday, September 28, 12
Friday, September 28, 12
NPM


    • Node                 Package Manager

    • Seit          node 0.6.3 Bundled

    • Repo                 @ https://npmjs.org/




Friday, September 28, 12
KOMMANDOS

    • npm             search <package>

    • npm             install <package>

    • npm             list

    • npm             update

    • npm             remove


Friday, September 28, 12
NPM SEARCH




Friday, September 28, 12
NPM INSTALL




Friday, September 28, 12
NPM LIST




Friday, September 28, 12
NPM UPDATE




Friday, September 28, 12
NPM REMOVE




Friday, September 28, 12
EIGENE NPM PAKETE




Friday, September 28, 12
EIGENE NPM PAKETE


    • npm                  adduser

         • Username, Passwort, E-Mail

    • npm                  publish <folder>|<tarball>




Friday, September 28, 12
HTTPS://GITHUB.COM/
                            JOYENT/NODE/WIKI/




Friday, September 28, 12
DATEISYSTEM




Friday, September 28, 12
DATEISYSTEM-FUNKTIONEN

    • exists               • unlink

    • readFile             • chmod

    • writeFile            • chown

    • appendFile           • ...

    • watchFile

    • rename

Friday, September 28, 12
FILE EXISTS




Friday, September 28, 12
FILE EXISTS




Friday, September 28, 12
FILE EXISTS




Friday, September 28, 12
APPEND FILE




Friday, September 28, 12
APPEND FILE




Friday, September 28, 12
APPEND FILE




Friday, September 28, 12
WATCH FILE




Friday, September 28, 12
WATCH FILE




Friday, September 28, 12
WATCH FILE




Friday, September 28, 12
WATCH FILE




Friday, September 28, 12
FRAGEN?




Friday, September 28, 12
DATENBANKEN




Friday, September 28, 12
Friday, September 28, 12
MySQL




Friday, September 28, 12
MySQL



                                   CouchDB




Friday, September 28, 12
MySQL



                                       CouchDB




                       MS SQL Server


Friday, September 28, 12
MySQL



                                       CouchDB

                  SQLite


                       MS SQL Server


Friday, September 28, 12
MySQL



                                       CouchDB
                                                 Redis
                  SQLite


                       MS SQL Server


Friday, September 28, 12
MySQL
                                       PostgreSQL

                                       CouchDB
                                                    Redis
                  SQLite


                       MS SQL Server


Friday, September 28, 12
MySQL
                                       PostgreSQL

                                       CouchDB
                                                        Redis
                  SQLite


                       MS SQL Server
                                                 Hive


Friday, September 28, 12
MySQL
                                       PostgreSQL
                              Mongo
                                       CouchDB
                                                        Redis
                  SQLite


                       MS SQL Server
                                                 Hive


Friday, September 28, 12
MySQL
                                       PostgreSQL
                                                        Oracle
                              Mongo
                                       CouchDB
                                                         Redis
                  SQLite


                       MS SQL Server
                                                 Hive


Friday, September 28, 12
MYSQL

    • npm             install mysql

    • Implementierung                 des mysql Protokolls




Friday, September 28, 12
MYSQL




Friday, September 28, 12
TEST-DATENBANK




Friday, September 28, 12
MYSQL




Friday, September 28, 12
MYSQL




Friday, September 28, 12
PROMISES




Friday, September 28, 12
PROMISES

    • Ergebnis             eines asynchronen Funktionsaufrufs

    • Rückgabewert               oder Exception

    • Promise              statt Blocking

    • CommonJS                Proposal

    • bis        0.2 Bestandteil von Node


Friday, September 28, 12
PYRAMID OF DOOM




Friday, September 28, 12
PROMISES




Friday, September 28, 12
PROMISE-LIBRARIES


    • https://github.com/kriskowal/q

    • https://github.com/kriszyp/promised-io

    • https://github.com/kriszyp/node-promise

    • ...




Friday, September 28, 12
OHNE PROMISES




Friday, September 28, 12
OHNE PROMISES




Friday, September 28, 12
PROMISES




Friday, September 28, 12
PROMISES




Friday, September 28, 12
PROMISES




Friday, September 28, 12
PROMISES




Friday, September 28, 12
CHILD PROCESSES




Friday, September 28, 12
CHILD PROCESSES


    • spawn                - Kommandoausführung

    • exec            - Kommandoausführung in Puffer

    • execFile              - Dateiausführung in Puffer

    • fork          - Node Prozess



Friday, September 28, 12
ETWAS RECHENINTENSIVES




Friday, September 28, 12
potenziell
                    ETWAS BLOCKIERENDES




Friday, September 28, 12
ETWAS BLOCKIERENDES




Friday, September 28, 12
ETWAS BLOCKIERENDES




Friday, September 28, 12
DIE LÖSUNG: WIR FORKEN




Friday, September 28, 12
CHILD PROCESSES




Friday, September 28, 12
CHILD PROCESSES




Friday, September 28, 12
CHILD PROCESSES




Friday, September 28, 12
WEBSOCKETS




Friday, September 28, 12
WEBSOCKETS


    • Protokoll               auf TCP-Basis

    • Bidirektionale              Client-Server-Kommunikation

    • Wird                 im Rahmen von HTML5 entwickelt

    • Unterstützung                durch Libraries



Friday, September 28, 12
Friday, September 28, 12
SOCKET.IO - SERVER




Friday, September 28, 12
SOCKET.IO - SERVER




Friday, September 28, 12
SOCKET.IO - CLIENT




Friday, September 28, 12
SOCKET.IO - CLIENT




Friday, September 28, 12
SOCKET.IO - CLIENT




Friday, September 28, 12
SOCKET.IO - SERVER




Friday, September 28, 12
DEBUGGER




Friday, September 28, 12
DEBUGGER




Friday, September 28, 12
DEBUGGER




Friday, September 28, 12
DEBUGGER




Friday, September 28, 12
DEBUGGER - STEP


    • next            -n

    • cont            -c

    • step           -s

    • out          -o



Friday, September 28, 12
DEBUGGER - WATCH


    • watch(expression)

    • unwatch(expression)

    • watchers




Friday, September 28, 12
DEBUGGER - WATCH




Friday, September 28, 12
DEBUGGER - REPL




Friday, September 28, 12
TESTING
Friday, September 28, 12
TEST FRAMEWORKS

    • node-unit

    • node             assertion testing

    • jasmine-node




Friday, September 28, 12
JASMINE-NODE




Friday, September 28, 12
JASMINE-NODE




Friday, September 28, 12
JASMINE-NODE
                             src/Calculator.js




Friday, September 28, 12
JASMINE-NODE
                            spec/Calculator.spec.js




Friday, September 28, 12
JASMINE-NODE




Friday, September 28, 12
JASMINE-NODE




Friday, September 28, 12
FRAGEN?




Friday, September 28, 12
KONTAKT
                           Sebastian Springer
                           sebastian.springer@mayflower.de

                           Mayflower GmbH
                           Mannhardtstr. 6
                           80538 München
                           Deutschland

                           @basti_springer

                           https://github.com/sspringer82



Friday, September 28, 12
SOCKETS




Friday, September 28, 12
SOCKETS

    • Kommunikation          über Netzwerk-/Datei-Sockets

    • Read-, Write-        und Read-Write-Sockets

    • ‘net’-Modul




Friday, September 28, 12
SOCKETS


         Write-Socket- Daten               Daten Read-Socket-
                             Socket-Server
            Client                                  Client




Friday, September 28, 12
SOCKETS - SERVER




Friday, September 28, 12
SOCKETS - READ




Friday, September 28, 12
SOCKETS - WRITE




Friday, September 28, 12
SOCKETS - SERVER




Friday, September 28, 12
SOCKETS - SERVER




Friday, September 28, 12
SOCKETS - SERVER




Friday, September 28, 12
SOCKETS - SERVER




Friday, September 28, 12

Más contenido relacionado

Similar a Node jsworkshop

The Wonderful World of Symfony Components
The Wonderful World of Symfony ComponentsThe Wonderful World of Symfony Components
The Wonderful World of Symfony ComponentsRyan Weaver
 
[T3CON12CA] TYPO3 Phoenix - The Current State
[T3CON12CA] TYPO3 Phoenix - The Current State[T3CON12CA] TYPO3 Phoenix - The Current State
[T3CON12CA] TYPO3 Phoenix - The Current StateChristian Müller
 
Conexao Java: Criando uma App Android
Conexao Java: Criando uma App AndroidConexao Java: Criando uma App Android
Conexao Java: Criando uma App AndroidErich Egert
 
Symfony - Introduction
Symfony - IntroductionSymfony - Introduction
Symfony - IntroductionPiers Warmers
 
Make something real for Firefox OS with Mozilla app templates
Make something real  for Firefox OS with Mozilla app templatesMake something real  for Firefox OS with Mozilla app templates
Make something real for Firefox OS with Mozilla app templatesPiotr Zalewa
 
Advanced Seaside
Advanced SeasideAdvanced Seaside
Advanced SeasideESUG
 
Node.js x Azure, cli usage, website deployment
Node.js x Azure, cli usage, website deploymentNode.js x Azure, cli usage, website deployment
Node.js x Azure, cli usage, website deploymentCaesar Chi
 
Chef - Configuration Management for the Cloud
Chef - Configuration Management for the CloudChef - Configuration Management for the Cloud
Chef - Configuration Management for the CloudJames Casey
 
OpenStack Deployment with Chef Workshop
OpenStack Deployment with Chef WorkshopOpenStack Deployment with Chef Workshop
OpenStack Deployment with Chef WorkshopMatt Ray
 
Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...NETWAYS
 
Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...Puppet
 
Backbone.js, Socket.io und Node.js im Einsatz
Backbone.js, Socket.io und Node.js im EinsatzBackbone.js, Socket.io und Node.js im Einsatz
Backbone.js, Socket.io und Node.js im EinsatzSebastian Springer
 
Building and deploying a distributed application with Docker, Mesos and Marathon
Building and deploying a distributed application with Docker, Mesos and MarathonBuilding and deploying a distributed application with Docker, Mesos and Marathon
Building and deploying a distributed application with Docker, Mesos and MarathonJulia Mateo
 
Performance & Responsive Web Design
Performance & Responsive Web DesignPerformance & Responsive Web Design
Performance & Responsive Web DesignZach Leatherman
 
It's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick DeboisIt's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick DeboisJAX London
 
Internship dotCloud
Internship dotCloudInternship dotCloud
Internship dotCloudJill Mee
 

Similar a Node jsworkshop (20)

The Wonderful World of Symfony Components
The Wonderful World of Symfony ComponentsThe Wonderful World of Symfony Components
The Wonderful World of Symfony Components
 
100% JS
100% JS100% JS
100% JS
 
[T3CON12CA] TYPO3 Phoenix - The Current State
[T3CON12CA] TYPO3 Phoenix - The Current State[T3CON12CA] TYPO3 Phoenix - The Current State
[T3CON12CA] TYPO3 Phoenix - The Current State
 
Conexao Java: Criando uma App Android
Conexao Java: Criando uma App AndroidConexao Java: Criando uma App Android
Conexao Java: Criando uma App Android
 
Symfony - Introduction
Symfony - IntroductionSymfony - Introduction
Symfony - Introduction
 
Make something real for Firefox OS with Mozilla app templates
Make something real  for Firefox OS with Mozilla app templatesMake something real  for Firefox OS with Mozilla app templates
Make something real for Firefox OS with Mozilla app templates
 
Advanced Seaside
Advanced SeasideAdvanced Seaside
Advanced Seaside
 
Node.js x Azure, cli usage, website deployment
Node.js x Azure, cli usage, website deploymentNode.js x Azure, cli usage, website deployment
Node.js x Azure, cli usage, website deployment
 
Chef - Configuration Management for the Cloud
Chef - Configuration Management for the CloudChef - Configuration Management for the Cloud
Chef - Configuration Management for the Cloud
 
OpenStack Deployment with Chef Workshop
OpenStack Deployment with Chef WorkshopOpenStack Deployment with Chef Workshop
OpenStack Deployment with Chef Workshop
 
Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...
 
Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...
 
Taming the rabbit
Taming the rabbitTaming the rabbit
Taming the rabbit
 
Backbone.js, Socket.io und Node.js im Einsatz
Backbone.js, Socket.io und Node.js im EinsatzBackbone.js, Socket.io und Node.js im Einsatz
Backbone.js, Socket.io und Node.js im Einsatz
 
Building and deploying a distributed application with Docker, Mesos and Marathon
Building and deploying a distributed application with Docker, Mesos and MarathonBuilding and deploying a distributed application with Docker, Mesos and Marathon
Building and deploying a distributed application with Docker, Mesos and Marathon
 
JavaScript QA Tools
JavaScript QA ToolsJavaScript QA Tools
JavaScript QA Tools
 
Performance & Responsive Web Design
Performance & Responsive Web DesignPerformance & Responsive Web Design
Performance & Responsive Web Design
 
It's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick DeboisIt's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick Debois
 
Internship dotCloud
Internship dotCloudInternship dotCloud
Internship dotCloud
 
Grails 2.0 Update
Grails 2.0 UpdateGrails 2.0 Update
Grails 2.0 Update
 

Más de Sebastian Springer

Creating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.jsCreating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.jsSebastian Springer
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsSebastian Springer
 
From Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceFrom Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceSebastian Springer
 
Von 0 auf 100 - Performance im Web
Von 0 auf 100 - Performance im WebVon 0 auf 100 - Performance im Web
Von 0 auf 100 - Performance im WebSebastian Springer
 
ECMAScript 6 im Produktivbetrieb
ECMAScript 6 im ProduktivbetriebECMAScript 6 im Produktivbetrieb
ECMAScript 6 im ProduktivbetriebSebastian Springer
 
Große Applikationen mit AngularJS
Große Applikationen mit AngularJSGroße Applikationen mit AngularJS
Große Applikationen mit AngularJSSebastian Springer
 
Best Practices für TDD in JavaScript
Best Practices für TDD in JavaScriptBest Practices für TDD in JavaScript
Best Practices für TDD in JavaScriptSebastian Springer
 
Warum ECMAScript 6 die Welt ein Stückchen besser macht
Warum ECMAScript 6 die Welt ein Stückchen besser machtWarum ECMAScript 6 die Welt ein Stückchen besser macht
Warum ECMAScript 6 die Welt ein Stückchen besser machtSebastian Springer
 

Más de Sebastian Springer (20)

Schnelleinstieg in Angular
Schnelleinstieg in AngularSchnelleinstieg in Angular
Schnelleinstieg in Angular
 
Creating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.jsCreating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.js
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 
From Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceFrom Zero to Hero – Web Performance
From Zero to Hero – Web Performance
 
Von 0 auf 100 - Performance im Web
Von 0 auf 100 - Performance im WebVon 0 auf 100 - Performance im Web
Von 0 auf 100 - Performance im Web
 
A/B Testing mit Node.js
A/B Testing mit Node.jsA/B Testing mit Node.js
A/B Testing mit Node.js
 
Angular2
Angular2Angular2
Angular2
 
Einführung in React
Einführung in ReactEinführung in React
Einführung in React
 
JavaScript Performance
JavaScript PerformanceJavaScript Performance
JavaScript Performance
 
ECMAScript 6 im Produktivbetrieb
ECMAScript 6 im ProduktivbetriebECMAScript 6 im Produktivbetrieb
ECMAScript 6 im Produktivbetrieb
 
Streams in Node.js
Streams in Node.jsStreams in Node.js
Streams in Node.js
 
JavaScript Performance
JavaScript PerformanceJavaScript Performance
JavaScript Performance
 
Große Applikationen mit AngularJS
Große Applikationen mit AngularJSGroße Applikationen mit AngularJS
Große Applikationen mit AngularJS
 
Testing tools
Testing toolsTesting tools
Testing tools
 
Node.js Security
Node.js SecurityNode.js Security
Node.js Security
 
Typescript
TypescriptTypescript
Typescript
 
Reactive Programming
Reactive ProgrammingReactive Programming
Reactive Programming
 
Best Practices für TDD in JavaScript
Best Practices für TDD in JavaScriptBest Practices für TDD in JavaScript
Best Practices für TDD in JavaScript
 
Warum ECMAScript 6 die Welt ein Stückchen besser macht
Warum ECMAScript 6 die Welt ein Stückchen besser machtWarum ECMAScript 6 die Welt ein Stückchen besser macht
Warum ECMAScript 6 die Welt ein Stückchen besser macht
 
Lean Startup mit JavaScript
Lean Startup mit JavaScriptLean Startup mit JavaScript
Lean Startup mit JavaScript
 

Node jsworkshop