SlideShare a Scribd company logo
1 of 88
SERVER SIDE SCRIPTING




Marc Gear    PHP London June
            2011
CHAMPION
CHAMPION
CONTENDER
CONTENDER
PHP vs node.js

• super brief intro to node.js
• strengths & weaknesses
• where & why to use node.js
mod_php
shared nothing
procedural
massive
“Evented I/O for V8
    JavaScript”
WTF?
“Evented I/O for V8
    JavaScript”
“Evented I/O for V8
    JavaScript”
“Evented I/O for V8
    JavaScript”
“Evented I/O for V8
    JavaScript”
Clients   Webserver
Clients   Webserver
Clients   Webserver
Clients   Webserver
Clients   Webserver
callbacks
Round 1
Round 1
mod_php vs ...
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Worldn');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
Lightnode         beeline          Picard
Nitrode           biggie-router    simplex
antinode          choreographer    Pipe-layer
node-paperboy     clutch           frank
node-static       connect          webservice.js
oui               dispatch         zappa
static            escort           archetype
static-resource   journey          broke
Ni                node-router      chain
(fab)             node.routes.js   coltraine
kaph              nozzle           djangode
Nerve             sherpa           drty
Prick             rowan            Express
restmvc.js        vroom            Grasshopper
everywhere
apache
lightty
ngnix
IIS
cgi
Round 2
Round 2
performance
evented
who cares?
me
webscale
PHP faster?
Round 3
Round 3
 code
PHP
closures
$bread = 'rye';
$sandwich = function($filling) use ($bread) {
    echo $bread, $filling, $bread;
}
$bread = 'rye';
$sandwich = function($filling) use ($bread) {
    echo $bread, $filling, $bread;
}
$sandwich('pastrami');
$sandwich('egg & cress');
$bread = 'rye';
$sandwich = function($filling) use ($bread) {
    echo $bread, $filling, $bread;
}
$fillings = array('pastrami', 'egg & cress');
array_walk($fillings, $sandwich);
$bread = 'rye';
$fillings = array('pastrami', 'egg & cress');
array_walk($fillings, function($filling) use ($bread) {
    echo $bread, $filling, $bread;
});
JavaScript
Browser
Browser         Server
             Webserver
Browser
Browser         Server
             Webserver



                 JavaScript
Browser
Browser            Server
                Webserver



   JavaScript       JavaScript
Browser
Browser                   Server
                       Webserver



                json
   JavaScript              JavaScript
backbone.js
handlebars.js
Round 4
Round 4
databases
CouchDB
MongoDB
+ others
node-mysql
PDO
mysqlnd
noSQL
Round 5
Round 5
frameworks
express.js
var app = require('express').createServer();
app.get('/', function(req, res) {
    res.send('hello world');
});
app.listen(80);
Silex
Appserver-in-PHP
Round 5
Round 5
bottom line
PHP still
awesome
Node has its
   uses
Bespoke servers
websockets
Marc Gear
@marcgear
marcgear@gmail.com

More Related Content

What's hot

Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1Hamidreza Soleimani
 
Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Asher Martin
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBHengki Sihombing
 
ServiceWorker: New game changer is coming!
ServiceWorker: New game changer is coming!ServiceWorker: New game changer is coming!
ServiceWorker: New game changer is coming!Chang W. Doh
 
Introduction to performance tuning perl web applications
Introduction to performance tuning perl web applicationsIntroduction to performance tuning perl web applications
Introduction to performance tuning perl web applicationsPerrin Harkins
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for RubistsSagiv Ofek
 
Php assíncrono com_react_php
Php assíncrono com_react_phpPhp assíncrono com_react_php
Php assíncrono com_react_phpRenato Lucena
 
LCA2014 - Introduction to Go
LCA2014 - Introduction to GoLCA2014 - Introduction to Go
LCA2014 - Introduction to Godreamwidth
 
Let s Enjoy Node.js
Let s Enjoy Node.jsLet s Enjoy Node.js
Let s Enjoy Node.jsFred Chien
 
Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"EPAM Systems
 
NodeJS: n00b no more
NodeJS: n00b no moreNodeJS: n00b no more
NodeJS: n00b no moreBen Peachey
 
Event Driven Architecture Concepts in Web Technologies - Part 2
Event Driven Architecture Concepts in Web Technologies - Part 2Event Driven Architecture Concepts in Web Technologies - Part 2
Event Driven Architecture Concepts in Web Technologies - Part 2Hamidreza Soleimani
 
Frontend Track NodeJS
Frontend Track NodeJSFrontend Track NodeJS
Frontend Track NodeJSMarcelo Serpa
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJSHüseyin BABAL
 
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
 

What's hot (20)

Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1Event Driven Architecture Concepts in Web Technologies - Part 1
Event Driven Architecture Concepts in Web Technologies - Part 1
 
Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
 
ServiceWorker: New game changer is coming!
ServiceWorker: New game changer is coming!ServiceWorker: New game changer is coming!
ServiceWorker: New game changer is coming!
 
Introduction to performance tuning perl web applications
Introduction to performance tuning perl web applicationsIntroduction to performance tuning perl web applications
Introduction to performance tuning perl web applications
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
 
Php assíncrono com_react_php
Php assíncrono com_react_phpPhp assíncrono com_react_php
Php assíncrono com_react_php
 
LCA2014 - Introduction to Go
LCA2014 - Introduction to GoLCA2014 - Introduction to Go
LCA2014 - Introduction to Go
 
Let s Enjoy Node.js
Let s Enjoy Node.jsLet s Enjoy Node.js
Let s Enjoy Node.js
 
node.js - Fast event based web application development
node.js - Fast event based web application developmentnode.js - Fast event based web application development
node.js - Fast event based web application development
 
Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"
 
NodeJS: n00b no more
NodeJS: n00b no moreNodeJS: n00b no more
NodeJS: n00b no more
 
Event Driven Architecture Concepts in Web Technologies - Part 2
Event Driven Architecture Concepts in Web Technologies - Part 2Event Driven Architecture Concepts in Web Technologies - Part 2
Event Driven Architecture Concepts in Web Technologies - Part 2
 
The SPDY Protocol
The SPDY ProtocolThe SPDY Protocol
The SPDY Protocol
 
Frontend Track NodeJS
Frontend Track NodeJSFrontend Track NodeJS
Frontend Track NodeJS
 
Apache
ApacheApache
Apache
 
Node.js
Node.jsNode.js
Node.js
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJS
 
CouchApp - Build scalable web applications and relax
CouchApp - Build scalable web applications and relaxCouchApp - Build scalable web applications and relax
CouchApp - Build scalable web applications and relax
 
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
 

Viewers also liked

How To Deploy A Cloud Based Webserver in 5 minutes - LAMP
How To Deploy A Cloud Based Webserver in 5 minutes - LAMPHow To Deploy A Cloud Based Webserver in 5 minutes - LAMP
How To Deploy A Cloud Based Webserver in 5 minutes - LAMPMatt Dunlap
 
Blue Angels Case Study
Blue Angels Case StudyBlue Angels Case Study
Blue Angels Case StudyEffective
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.jsguileen
 
Turning Marketing Words into a Branded People Experience
Turning Marketing Words into a Branded People ExperienceTurning Marketing Words into a Branded People Experience
Turning Marketing Words into a Branded People ExperienceBridge Training and Events
 
Web Security Introduction Webserver hacking refers to ...
Web Security Introduction Webserver hacking refers to ...Web Security Introduction Webserver hacking refers to ...
Web Security Introduction Webserver hacking refers to ...webhostingguy
 
PHPNW14 - Getting Started With AWS
PHPNW14 - Getting Started With AWSPHPNW14 - Getting Started With AWS
PHPNW14 - Getting Started With AWSbenwaine
 
AWS Cloudfront Howto
AWS Cloudfront HowtoAWS Cloudfront Howto
AWS Cloudfront Howtomailbhargav
 
Pentesting web applications
Pentesting web applicationsPentesting web applications
Pentesting web applicationsSatish b
 
Webservices: connecting Joomla! with other programs.
Webservices: connecting Joomla! with other programs.Webservices: connecting Joomla! with other programs.
Webservices: connecting Joomla! with other programs.Herman Peeren
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPressvnsavage
 
WebSphere App Server vs JBoss vs WebLogic vs Tomcat
WebSphere App Server vs JBoss vs WebLogic vs TomcatWebSphere App Server vs JBoss vs WebLogic vs Tomcat
WebSphere App Server vs JBoss vs WebLogic vs TomcatWASdev Community
 
WebSphere Application Server Family (Editions Comparison)
WebSphere Application Server Family (Editions Comparison)WebSphere Application Server Family (Editions Comparison)
WebSphere Application Server Family (Editions Comparison)ejlp12
 
Client Vs. Server Rendering
Client Vs. Server RenderingClient Vs. Server Rendering
Client Vs. Server RenderingDavid Amend
 

Viewers also liked (20)

How To Deploy A Cloud Based Webserver in 5 minutes - LAMP
How To Deploy A Cloud Based Webserver in 5 minutes - LAMPHow To Deploy A Cloud Based Webserver in 5 minutes - LAMP
How To Deploy A Cloud Based Webserver in 5 minutes - LAMP
 
Blue Angels Case Study
Blue Angels Case StudyBlue Angels Case Study
Blue Angels Case Study
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
 
Web Fendamentals
Web FendamentalsWeb Fendamentals
Web Fendamentals
 
Nodejs
NodejsNodejs
Nodejs
 
Turning Marketing Words into a Branded People Experience
Turning Marketing Words into a Branded People ExperienceTurning Marketing Words into a Branded People Experience
Turning Marketing Words into a Branded People Experience
 
Web Security Introduction Webserver hacking refers to ...
Web Security Introduction Webserver hacking refers to ...Web Security Introduction Webserver hacking refers to ...
Web Security Introduction Webserver hacking refers to ...
 
Ajax And JSON
Ajax And JSONAjax And JSON
Ajax And JSON
 
Basic Website 101
Basic Website 101Basic Website 101
Basic Website 101
 
Summer training seminar
Summer training seminarSummer training seminar
Summer training seminar
 
PHPNW14 - Getting Started With AWS
PHPNW14 - Getting Started With AWSPHPNW14 - Getting Started With AWS
PHPNW14 - Getting Started With AWS
 
Joomla REST API
Joomla REST APIJoomla REST API
Joomla REST API
 
AWS Cloudfront Howto
AWS Cloudfront HowtoAWS Cloudfront Howto
AWS Cloudfront Howto
 
Pentesting web applications
Pentesting web applicationsPentesting web applications
Pentesting web applications
 
Webservices: connecting Joomla! with other programs.
Webservices: connecting Joomla! with other programs.Webservices: connecting Joomla! with other programs.
Webservices: connecting Joomla! with other programs.
 
SmokeTests
SmokeTestsSmokeTests
SmokeTests
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
 
WebSphere App Server vs JBoss vs WebLogic vs Tomcat
WebSphere App Server vs JBoss vs WebLogic vs TomcatWebSphere App Server vs JBoss vs WebLogic vs Tomcat
WebSphere App Server vs JBoss vs WebLogic vs Tomcat
 
WebSphere Application Server Family (Editions Comparison)
WebSphere Application Server Family (Editions Comparison)WebSphere Application Server Family (Editions Comparison)
WebSphere Application Server Family (Editions Comparison)
 
Client Vs. Server Rendering
Client Vs. Server RenderingClient Vs. Server Rendering
Client Vs. Server Rendering
 

Similar to Server side scripting smack down - Node.js vs PHP

Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Node js introduction
Node js introductionNode js introduction
Node js introductionAlex Su
 
Facebook的缓存系统
Facebook的缓存系统Facebook的缓存系统
Facebook的缓存系统yiditushe
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
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
 
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
 
Introduction to Node.js Platform
Introduction to Node.js PlatformIntroduction to Node.js Platform
Introduction to Node.js PlatformNaresh Chintalcheru
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with ExamplesGabriele Lana
 
Nodejsexplained 101116115055-phpapp02
Nodejsexplained 101116115055-phpapp02Nodejsexplained 101116115055-phpapp02
Nodejsexplained 101116115055-phpapp02Sunny Gupta
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationAndrew Rota
 
node.js - Eventful JavaScript on the Server
node.js - Eventful JavaScript on the Servernode.js - Eventful JavaScript on the Server
node.js - Eventful JavaScript on the ServerDavid Ruiz
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS drupalcampest
 

Similar to Server side scripting smack down - Node.js vs PHP (20)

Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Event driven programming -- Node.JS
Event driven programming -- Node.JSEvent driven programming -- Node.JS
Event driven programming -- Node.JS
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3Nodejs - A-quick-tour-v3
Nodejs - A-quick-tour-v3
 
NodeJS
NodeJSNodeJS
NodeJS
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
 
Facebook的缓存系统
Facebook的缓存系统Facebook的缓存系统
Facebook的缓存系统
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
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.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.
 
Introduction to Node.js Platform
Introduction to Node.js PlatformIntroduction to Node.js Platform
Introduction to Node.js Platform
 
Node.js - A Quick Tour
Node.js - A Quick TourNode.js - A Quick Tour
Node.js - A Quick Tour
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
 
Nodejsexplained 101116115055-phpapp02
Nodejsexplained 101116115055-phpapp02Nodejsexplained 101116115055-phpapp02
Nodejsexplained 101116115055-phpapp02
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
node.js - Eventful JavaScript on the Server
node.js - Eventful JavaScript on the Servernode.js - Eventful JavaScript on the Server
node.js - Eventful JavaScript on the Server
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Node.js
Node.jsNode.js
Node.js
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 
hacking with node.JS
hacking with node.JShacking with node.JS
hacking with node.JS
 

Recently uploaded

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
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
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
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
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Recently uploaded (20)

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
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
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
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
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
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
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

Server side scripting smack down - Node.js vs PHP

Editor's Notes

  1. Hello, and welcome to this Scripting Language Smackdown at PHP London 2011. We have a hell of a contest here tonight. INTRODUCING:\n
  2. de facto scripting language since 1997,\npowering in excess of 20 million domains \nthe brainchild of Rasmus Lerdof: \n
  3. \n
  4. Just two years old and already demolishing the competition\nHeralded as the best thing since both sliced bread and PHP,\nCreated by Ryan Dahl:\n
  5. \n
  6. Okay - i can't do a whole talk like that...\nI'm going to talk to you today about PHP vs Node.JS, give a brief introduction to Node, comparing its strengths and weaknesses to PHPs strengths and weaknesses, and also try and give you some ideas of where and why you might want to use node in anger. I've only got 20 minutes so we'll go pretty quick. Lets take a look at the competitors:\n
  7. I am not going to tell you a whole bunch of stuff about PHP, but I'm going to cover some key things you need to have in mind when weighing it up here:\n\n
  8. mod_php is one of the main reasons PHP is so successful. What is it? Its the apache module that just plugs in and makes PHP work beautifully with the worlds most popular web server. What makes it great?\n\n
  9. Its the killer move. It means each execution of a PHP script is independant of every other execution of that script. That means you dont have to worry about memory leaks, or garbage collection most of the time, not all of the time, but most of the time.\n
  10. it is procedural - yes it does OO but what I mean that you wait for the of code above to finish execution before you run. Thats a pretty important point right there to remember. \n\nIn php you wait for the line above you to finish execution before you run. Its so obvious its almost insane to mention it right? Wrong. I'll show you why in a bit.\n\n
  11. PHP is massive - tons of extensions, code libraries, frameworks,\nhuge install base/user base/documentation. \n\nruns some of the biggest sites on the interweb\n\nIts continued success is due, in part, to its past success.\n\n
  12. So thats PHP. But this is a fight, so we need an avatar to represent PHP in this fight. If php was a pro wrestler this is who it’d be.\n
  13. The hulkster. Its old, its classic, its an all rounder, everyone loves it (unless they hate it), its flamboyant while still being pragmatic.\n
  14. On to node. \nIts _already_ cheating because its not a scripting language at all. its...\n
  15. \n
  16. What is that supposed to mean. As a catch phrase, its not even catchy or clever. Lets break it down and work through it. \n\n\n
  17. I’m going to go backwards. Does everyone know what javascript is?\nAny one not know what javascript it?\n\nIts server-side javascript. Which if you’re from 2001, sounds like a horrible horrible idea. But javascript has changed since then, well it hasn’t changed, but the implementations have, and how we’re using it has. \n\nNow its the most widely used interpreted programming language.\n
  18. V8, V8 javascript. Thats not version 8, its the javascript engine that runs inside Google Chrome. It is probably the reason you use chrome, if you use chrome. becuase it makes everything seem quicker. In googles own benchmarks, it outperforms other browsers by orders of magnitude. \n\nThats sort of because google cheats a bit, and the tests are heavily biased on recursive calls, which V8 is really good at. But that turns out to be good news for node and you’ll see why soon.\n
  19. I’m going to hope that you all know that IO means input/output. \n
  20. so i’ll explain what evented IO means\n
  21. Imagine a webserver. So your client comes and asks for a page, you go get it, give it to them, and wait for the next request. \n
  22. If another request comes in before you finish serving the first guy... they have to wait. You're waiting for the disk, or the database, or some API, or some other shit. \n\nUntil everything gets backed up waiting for the webserver to handle the requests in front\n
  23. So you run multiple threads, so you can handle lots of concurrent requests. Behind the scenes you still have to worry about file locking and all that shit, but people are not waiting as long for their stuff. Maybe you're making a few duplicate disk reads, or db queries, but you can fix that with some caching.\n
  24. Until you cant run enough threads anymore. So what do you do now? You need to take a different approach. \n
  25. Instead of handling each request with a thread, you just accept the request, and process it in an 'event loop'. Here the thread loops through the requests and when it has to do some IO, it does it asyncronously.\n
  26. It fires off a request for a resource, but doesn't wait for the response before processing the next task it has. When the resource has returned, the server is notified by an event, and calls the code it was told about when the request went out - the callback\n\nnearly EVERYTHING in node is event driven - you just chuck an event, and the callback will happen sometime in the future, and you don't really care when. - the server continues without blocking on that request. Doing this in PHP is like pulling teeth\n\n
  27. Lets get this fight started... round one\n
  28. mod_php vs what?\n
  29. In node you can’t just plug it into an existing webserver and everything just works out of the box like you can in PHP. You have to write your own. At its most basic that looks like this. Obviously this gives you plenty of opportunity\n
  30. to balls it all up yourself. Luckily node has a way round this. It has a pretty awesome package manager called npm and the community is pretty good too, so there are lots of modules available.\n
  31. This is a list of some of the modules that operate as webservers. Some are micro frameworks in thier own right, some will serve static content pretty quick. But what i’m trying to say is that you dont _have_ to write your own. You just can if you want.\n\nCompare this with PHP though.\n
  32. PHP runs on everything\n
  33. \n
  34. \n
  35. \n
  36. \n
  37. this is all because of CGI - implemented by webservers since the dawn of time, or at least since i was in short trousers. \n
  38. Node\n
  39. Doesn’t even run on windows at the moment. But i’ll leave that up to you to decide whether thats a good thing or not\n\nSo how is our champ doing in the ring?\n
  40. Here he is. He has hardly started. He’s not even finished taking off his vest. What a guy.\n
  41. On to round two\n
  42. Performance. Which of these is going to give you more bang for your buck?\n\n\n
  43. Remember node is evented, so i guess that means it should be faster at everything right?\n
  44. Who cares? I mean it. It doesn’t matter.\n\nbench mark it yourself for specific applications. \n\nYour appriasal process for using any technology in a commercial setting should not be based upon the benchmark comparison conducted by some blogger in turkmenistahn\n
  45. neither should it be based on reports of how fast something it is by some guy in a pub (ie me).\n \n
  46. truth is, node is probably faster for a whole bunch of applications, because its even more webscale than PHP. But really - benchmark it yourself.\n
  47. Recently I saw some blog posts noting that PHP was faster, or used less memory. Its all down to the application.\n\nEnd of round 2, whats our champion up to?\n
  48. Holy shit, he’s throwing that other dude around. He’s powering through this. He’s taken a couple of knocks but he’s started strong.\n
  49. Round three... whats this about?\n
  50. Oooh code. I love code. Its the enjoyment of bending something to my will.\n
  51. Not going to talk a lot about PHP code, I hope you all know what it looks like, how it works. Quickly going to run through a PHP 5.3 feature\n\n
  52. A closure is an anonymous function, which can be used as either a variable, or an argument to another function\n
  53. OMG its a code slide. Dont worry not too many of these.\n\nHere is a closure in PHP. Its a function being assigned to a variable. Thats neat.\n
  54. BANG - we’re calling that variable as though it was a function (which it is). Thats some crazy stuff. Look at it go. Whats next...\n
  55. Oh yeah. We can pass that variable around as an argument. Lets array_walk with that guy.\nHe’s makin sandwiches like pret a manger.\n\nThats great and all, but its not really that useful. the variable isn’t really that different to a namespaced function call. Lets beef up the anonimity.\n
  56. Now we’re just throwing that closure straight into array_walk. its just getting thrown around and disposed of.\n\n\n
  57. If any of you have used much javascript, esp jQuery this should look familiar. You do this a lot in JavaScript.\n
  58. But its here that node really steps up a gear though. \n
  59. If you get your server side in javascript\n
  60. and you already have your client side in javascript\n
  61. and all the communication between them is all in javascript object notation...\n\nThen your complete stack is in JavaScript. Couple that with storage in a noSQL database that stores objects as json like mongodb.\n\n\n
  62. If you’re using javascript everywhere you can invest in your client side app. You can use stuff like backbone.js onthe client and server side, and share your models\n
  63. there are even logic-less templating systems in javascript. All of a sudden you only need to be familiar with one language.\n\nI’m not necessarily advocating that, but I do think its pretty cool.\n\nThats round 3 - ding ding. How is our champ doing?\n
  64. Oh dear... he’s looking worn out now, he’s been going a while, and this sort of thing takes its toll on old men. Lets move on... i think he’s starting to sway\n
  65. \n
  66. Okay. No matter what app you write, at some point you’re going to have to persist some data somewhere, and your scripting language/framework/whatever needs to support that.\n
  67. As I’ve already mentioned, there are some noSQL dbs that store everything in json, some of them have json apis.\n\nBecause of the nature of these things, the latest craze of node.js goes hand in hand with the craze of noSQL. there are a multitude of modules that support talking to these databases\n
  68. and there is plenty of support for more traditional dbs too\n\nThe key thing is - they all work asyncronously. You fire off a query and dont wait for it to return, node just gets on with doing somehting else instead. In PHP - you ask for something and you better be prepared to wait for it to get back to you before you do anything else.\n
  69. but PHP has PDO\na tidy (not perfect) abstraction - nothing like that in Node.js - its too fragmented at the moment\n
  70. it has native drivers for mysqlnd.\n
  71. it has loads of libraries and even some extensions for using noSQL dbs and just about every sort of relational db too\n\nding ding. Now lets see whats going on in the ring\n
  72. Its not looking good is it. things are looking bad.\n
  73. \n
  74. Frameworks. PHP should have this in the bag right? I mean like how many frameworks are there available for php\n
  75. Some of those are even pretty good. \n\nSo possibly, but i want to talk quickly about something node has which is pretty clever.\n
  76. Express is a microframework inspired by Sinatra in Ruby.\nIt only really provides routing and templating, but has hooks for a lot of other bits. It is the easiest way to get started building node.js web apps.\n
  77. This is the last code slide.\n\nIts the basic example from the express js site - its just wires a route to a function, a closure. What you pass in instead of that hello world can do whatever you like.\n\nIts so neat infact that the PHP world is starting to copy it.\n
  78. Check out Silex. Its a PHP microframework by sensiolabs, the company behind Symfony, and it makes use of php 5.3's closures to provide the same sort of routing in PHP.\n\nSure its just routing, and routing is fairly easy, but doing things this way is unbelivably light weight, and its incredibly quick to get started building stuff this way.\n\n
  79. appserver in php is a whole nother talk but its really pretty cool\n\nit breaks shared nothing completely, preconnecting to network resources like DBs, preloading configs/sharing resources and so forth. making response times really quick and letting you tie in node apps to your existing PHP back end.\n\nNow lets see how the Hulkster is faring...\n\n
  80. HES ON HIS FEET\nTHE CROUD ARE GOING WILD.\n\nEmpowered by the croud he’s back up - ready to fight... Hulking up!\n
  81. \n
  82. Whats the bottom line.\n
  83. PHP has still got it. We continue to keep up with the competition. There’s some innovation in there too.\n
  84. node has its uses\n\n
  85. ideal for bespoke daemons - you need a custom smtp something or other, or an image webservice or something\n\n\n
  86. Use it for just about anything with websockets: sockets.io makes it unbelievably easy to do. Live chat or something like that\n\nWho won the fight? who knows. it could definatly go either way\n\n
  87. Maybe node and PHP will end up getting on really well and making beautiful music together. \n
  88. I’ve been marc gear\ndon’t follow me on twitter.\n\nI work at Moo.com, we print cool stuff like this.\n\nWe’re hiring developers, ping me your cv at the address on the screen.\n