SlideShare a Scribd company logo
VS 
Node.js vs Play Framework
Node.js: server-side JavaScript runtime environment; 
open source; single threaded; non-blocking I/O.
express.js: the most popular web 
framework for Node.js.
Play Framework: Java/Scala web framework; open 
source; multithreaded; non-blocking I/O.
Yevgeniy Brikman 
Former Play Tech Lead at LinkedIn. Long time Node.js user.
The framework scorecard 
Learn 
Develop 
Test 
Secure 
Build 
Deploy 
Debug 
Scale 
Maintain 
Share
For each feature we discuss... 
1 
Much worse than most frameworks 
About the same as most frameworks 
Much better than most frameworks 
5 
10
The framework scorecard 
Learn 
Develop 
Test 
Secure 
Build 
Deploy 
Debug 
Scale 
Maintain 
Share
Node.js: 1-click installers for every OS
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/'); 
server.js 
The “Hello World” Node app: 1 file, 6 lines of code.
var express = require('express'); 
var app = express(); 
app.get('/', function(req, res){ 
res.send('Hello World'); 
}); 
var server = app.listen(1337, function() { 
console.log('Listening on port %d', server.address().port); 
}); 
server.js 
The “Hello World” Express app: 1 file, 8 lines of code.
Run using node <filename>. Starts instantly!
Hit http://localhost:1337 to test
nodeschool.io
Node Beginner Book, Mastering Node.js, 
Node: Up and Running, Node.js in Action
Node API Docs
Express.js guide
Express Web Application Development Express.js Guide
Express.js API docs
And much, much more 
Tons of resources; very gradual learning curve.
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10
Play: download from playframework.com, 
extract, add activator to your PATH
Generate a new app using activator new
The “Hello World” Play app: ~35 files and folders
Run the app using activator run
(Downloading all dependencies can take a 
while the first time around)
Hit http://localhost:9000 to test
Play Framework Documentation
Activator Templates
Play for Scala Learning Play Framework 2
Ultimate Guide to Getting Started with Play. 
Not as many resources; steep learning curve.
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7
GET clients/:id Clients.show(id: Long) 
def show(id: Long) = Action { request => 
getClient(id).map { client => 
Ok(views.html.clients.show(client)) 
} 
} 
Routing 
app.get('clients/:id', function(req, res) { 
getClient(req.params.id, function(client) { 
res.render('show', client); 
}); 
}); 
RESTful routing. Extracts query & path 
params. 
RESTful routing. Extracts query & path 
params. Type safe. Actions are 
composable. Reverse routing.
@(name: String, headline: String) 
<div class="client"> 
<h1>@name</h1> 
<div class="headline"> 
Headline: @headline 
</div> 
</div> 
Templates 
<div class="client"> 
<h1>{{name}}</h1> 
<div class="headline"> 
Headline: {{headline}} 
</div> 
</div> 
Many template options: handlebars, 
mustache, dust, jade, etc. Most support 
client-side rendering! 
Twirl templates are compiled into Scala 
functions: type safe and composable! 
Other template types via plugins.
i18n 
Translations: i18next-node, i18n-node. 
Formatting: moment.js, numeral.js. 
Translations: Play i18n API. 
Formatting: Java formatting libraries. 
<div class="client"> 
<h1>{{name}}</h1> 
<div class="headline"> 
{{t "headline.label" headline=headline}} 
</div> 
</div> 
@(name: String, headline: String) 
<div class="client"> 
<h1>@name</h1> 
<div class="headline"> 
Messages("headline.label", headline) 
</div> 
</div>
var regForm = forms.create({ 
name: fields.string({required: true}), 
age: fields.number({min: 18}) 
Forms, node-formidable, validator.js. Play form binding and validation API. 
Form binding and validation 
}); 
regForm.handle(req, { 
success: function(form) { ... }, 
error: function(form) { ... } 
}); 
val regForm = Form(mapping( 
"name" -> nonEmptyText, 
"age" -> number(min = 18) 
)(UserData.apply)(UserData.unapply)) 
regForm.bindFromRequest.fold( 
err => BadRequest("Validation error"), 
data => Ok(s"Hi $data.name!") 
)
// Automatically parse application/json body 
app.use(bodyParser.json()); 
app.post('/clients', function (req, res, next) { 
var name = req.body.name; 
var age = req.body.age; 
res.send(name + " is " + age + " years old."); 
}); 
POST /clients Clients.create 
case class Person(name: String, age: Int) 
implicit val prsnFmt = Json.format[Person] 
def create = Action(parse.json) { request => 
val person = request.body.as[Person] 
Ok(s"$person.name is $person.age years old") 
} 
bodyParser, xml2js, node-formidable. Play JSON, XML, File Upload APIs. 
JSON, XML, File Upload
Data 
Slick, Anorm, Ebean, JPA 
MySQL, MariaDB, PostgreSLQ, SQLite, Oracle, SQL Server, 
DB2, Derby, H2 
Sequelize, Bookshelf.js, node-orm2 SQL 
MySQL, MariaDB, PostgreSQL, SQLite 
NoSQL 
mongojs/mongoose, cassandra-client, 
cradle/nano, node_redis, node-neo4j 
MongoDB, Cassandra, CouchDB, Redis, Neo4j 
ReactiveMongo, DataStax, sprouch, play-plugins- 
redis, Neo4j-play, JPA 
MongoDB, Cassandra, CouchDB, Redis, Neo4j 
node-memcached, connect-cache Caching 
memcached, in-memory (not recommended) 
play2-memcached, memcontinuationed, 
Play Cache, ehcache, Guava 
memcached, in-memory 
node-db-migrate, node-migrate Schemas Play database evolutions
socket.io: server & client APIs; 
WebSockets, Flash Sockets, polling, etc. 
Play WebSockets, Comet, and 
EventSource APIs. Server-side only. 
Real-time web 
// server code 
io.on('connection', function (socket) { 
socket.emit('msg', 'Server says hi!'); 
socket.on('msg', function (msg) { … }); 
}); 
def chat = WebSocket.acceptWithActor { 
request => out => Props(new Chat(out)) 
} 
class Chat(out: ActorRef) extends Actor { 
def receive = { 
case m: String => out ! s"Got msg: $m" 
} 
} 
// client code 
socket.emit('msg', 'Client says hi!'); 
socket.on('msg', function (msg) { … });
● Express.js is a minimal framework ● Play is a full stack framework 
● You need plugins for most tasks 
● Finding good plugins takes time 
● Gluing plugins together takes time 
● There are defaults for most tasks 
● Defaults are mostly high quality 
● All defaults can be replaced
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10
Unit testing: Jasmine, Mocha, QUnit, 
nodeunit, Expresso or Vows
var request = require('supertest') 
, app = require('express')(); 
app.get('/user', function(req, res){ 
res.send(200, { name: 'tobi' }); 
}); 
request(app) 
.get('/user') 
.expect('Content-Type', /json/) 
.expect(200); 
Functional testing: use supertest or call 
server.listen directly.
UI testing: phantom.js or zombie.js
Code coverage: Istanbul or Blanket.js
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10
Unit testing: junit, ScalaTest, specs2, or testng
"respond to the index Action" in new App(FakeApplication()) { 
val Some(result) = route(FakeRequest(GET, "/Bob")) 
status(result) mustEqual OK 
contentType(result) mustEqual Some("text/html") 
charset(result) mustEqual Some("utf-8") 
contentAsString(result) must include ("Hello Bob") 
} 
Functional testing: use Play’s built-in 
functional test helpers.
class ExampleSpec extends PlaySpec with OneServerPerSuite with OneBrowserPerSuite { 
"The OneBrowserPerTest trait" must { 
"provide a web driver" in { 
go to (s"http://localhost:$port/testing") 
pageTitle mustBe "Test Page" 
click on find(name("b")).value 
eventually { pageTitle mustBe "scalatest" } 
} 
} 
} 
UI testing: use Play’s built-in integration test 
helpers and built-in Selenium support.
Code coverage: jacoco4sbt or scct
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10
(not enabled by default!) Connect CSRF Middleware CSRF 
(not enabled by default!) 
Depends on template engine XSS Twirl escapes correctly 
Vulnerabilities: eval, setTimeout, Injection 
Security 
CSRFFilter 
setInterval, new Function Few vulnerabilities of this sort 
Helmet middleware Headers SecurityHeadersFilter 
passport.js, everyauth Auth SecureSocial, deadbolt, play-authenticate 
Node Security Project Advisories Play Security Vulnerabilities
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8
{ 
"name": "Hello World App", 
"version": "0.0.3", 
"dependencies": { 
"express": "4.8.0", 
"underscore": "1.6.0" 
}, 
"scripts": { 
"test": "node tests/run.js", 
"lint": "jshint src" 
} 
} 
Node.js uses NPM to manage dependencies and 
basic build commands
Many options available for more complicated 
builds: grunt.js, gulp.js, or broccoli
Thousands of plugins for all common build tasks
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10
Play uses SBT as the build system. SBT is an 
interactive build system.
object AppBuild extends Build { 
lazy val root = Project(id = "root", base = file(".")).settings( 
name := "test-play-app", 
version := version, 
libraryDependencies += Seq( 
"org.scala-tools" % "scala-stm_2.11.1" % "0.3", 
"org.apache.derby" % "derby" % "10.4.1.3" 
) 
) 
def version = Option(System.getProperty("version")).getOrElse("0.0.3") 
} 
In SBT, build definitions are written in Scala! 
… But the learning curve is very steep.
Dependencies are managed using Ivy: 
familiar, but slow.
Play uses sbt-web to build static content: few 
plugins; depends on Rhino (slow) or node.js (!).
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7
Many node-friendly hosting options: Heroku, 
Joyent, Azure, OpenShift, Nodejitsu
Monitoring: New Relic, Nodetime, 
AppDynamics, node-monitor
if (cluster.isMaster) { 
for (var i = 0; i < numCPUs; i++) { 
cluster.fork(); // Fork workers 
} 
cluster.on('exit', function(worker, code, signal) { 
console.log('worker ' + worker.process.pid + ' died'); 
}); 
} else { 
http.createServer(function(req, res) { 
// ... 
}).listen(8000); 
} 
Use cluster to run one node instance per CPU
Use forever, monit, or Domain to handle crashes.
{ 
"dbConfig": { 
"host": "localhost", 
"port": 5984, 
"dbName": "customers" 
} 
} 
config/default.json 
var config = require('config'); 
var host = config.get('dbConfig.host'); 
server.js 
Configuration: node-config or nconf
Use nginx, apache, or ATS to load balance, 
serve static content, terminate SSL 
Client 
Data Center 
Reverse proxy 
(e.g. nginx) DB 
Static server 
(e.g. nginx) 
Node 
instNaondcee 
instNaondcee 
instNaondcee 
instNaondcee 
instance 
Node 
instNaondcee 
instNaondcee 
instNaondcee 
instance 
Node 
instNaondcee 
instNaondcee 
instNaondcee 
instance
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8
A few Play-friendly hosting options: Heroku, 
playframework-cloud, CloudBees
Monitoring: New Relic, metrics-play
Use the SBT Native Packager to package the 
app as tgz, deb, RPM, etc.
dbConfig = { 
host: "localhost", 
port: 5984, 
dbName: "customers" 
} 
conf/application.conf 
val host = Play.current.configuration.getString("dbConfig.host") 
app/controllers/Application.scala 
Configuration: Play comes with Typesafe Config
Use nginx, apache, or ATS to load balance, 
serve static content, terminate SSL 
Client 
Data Center 
Reverse proxy 
(e.g. nginx) 
Play app 
DB 
Static server 
(e.g. nginx) 
Play app 
Play app
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7
Node.js: use IntelliJ or node-inspector to debug
Use DTrace, TraceGL, node-stackviz, and node-profiler 
to debug perf issues
var winston = require("winston"); 
winston.info("CHILL WINSTON! ... I put it in the logs."); 
Use winston, log4js, or bunyan for logging
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7 
10
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7 
10
Play runs on the JVM, so you can use your 
favorite IDE to debug: IntelliJ, Eclipse, NetBeans
In dev, Play shows errors right in the browser
Use YourKit, VisualVM, BTrace, and jmap to 
debug perf issues
Use logback, slf4j, or log4j for logging
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7 
10 10
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7 
10 10
Part 1: scaling for lots of traffic
TechEmpower benchmarks. 
Warning: microbenchmarks are not a substitute for real world perf testing!
JSON serialization
Single query 
(Note: JDBC is blocking!)
Multiple queries 
(Note: JDBC is blocking!)
Internet Load 
Balancer 
Frontend 
Server 
Frontend 
Server 
Frontend 
Server 
Backend 
Server 
Backend 
Server 
Backend 
Server 
Backend 
Server 
Backend 
Server 
Data 
Store 
Data 
Store 
Data 
Store 
Data 
Store 
LinkedIn experience #1: Play and Node.js are very 
fast in a service oriented architecture with NIO.
// BAD: write files synchronously 
fs.writeFileSync('message.txt', 'Hello Node'); 
console.log("It's saved, but you just blocked ALL requests!"); 
// Good: write files asynchronously 
fs.writeFile('message.txt', 'Hello Node', function (err) { 
console.log("It's saved and the server remains responsive!"); 
}); 
LinkedIn experience #2: Play is ok with blocking I/O 
& CPU/memory bound use cases. Node.js is not.
Part 2: scaling for large teams and projects
Node.js: best for small projects, short 
projects, small teams.
Play: best for longer projects. Slower ramp up, but 
scales well with team and project size.
For comparison: Spring MVC
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7 
10 
10 
10 
10
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7 
10 
10 
10 
10
Maintenance: the good parts
Functional programming: first class functions, 
closures, underscore.js
JavaScript is ubiquitous...
...Which means you can share developers, 
practices, and even code: rendr, derby, meteor
Node core is (mostly) stable and mature. Bugs, 
regressions, and backwards incompatibility are rare.
Maintenance: the bad parts
Node.js vs Play Framework
'' == '0' // false 
0 == '' // true 
0 == '0' // true 
false == 'false' // false 
false == '0' // true 
false == undefined // false 
false == null // false 
null == undefined // true 
' trn ' == 0 // true 
Bad Parts
// Default scope is global 
var foo = "I'm a global variable!" 
// Setting undeclared variables puts them in global scope too 
bar = "I'm also a global variable!"; 
if (foo) { 
// Look ma, no block scope! 
var baz = "Believe it or not, I'll also be a global variable!" 
} 
Awful Parts
Wat
this keyword
doSomethingAsync(req1, function(err1, res1) { 
doSomethingAsync(req2, function(err2, res2) { 
doSomethingAsync(req3, function(err3, res3) { 
doSomethingAsync(req4, function(err4, res4) { 
// ... 
}); 
}); 
}); 
}); 
Callback hell: control flow, error handling, 
and composition are all difficult
Many NPM packages are NOT stable or mature. 
Incompatibility + bugs + dynamic typing = pain.
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7 
10 
10 
10 
10 
3
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7 
10 
10 
10 
10 
3
Maintenance: the good parts
def sort(a: List[Int]): List[Int] = { 
if (a.length < 2) a 
else { 
val pivot = a(a.length / 2) 
sort(a.filter(_ < pivot)) ::: 
a.filter(_ == pivot) ::: 
sort(a.filter(_ > pivot)) 
Functional programming 
} 
}
Powerful type system
val NameTagPattern = "Hello, my name is (.+) (.+)".r 
val ListPattern = "Last: (.+). First: (.+).".r 
// Case classes automatically generate immutable fields, equals, hashCode, constructor 
case class Name(first: String, last: String) 
// Use Option to avoid returning null if there is no name found 
def extractName(str: String): Option[Name] = { 
Option(str).collectFirst { 
// Pattern matching on regular expressions 
case NameTagPattern(fname, lname) => Name(fname, lname) 
case ListPattern(lname, fname) => Name(fname, lname) 
} 
} 
Very expressive: case classes, pattern 
matching, lazy, option, implicits
Runs on the JVM; interop with Java.
Concurrency & streaming tools: Futures, Akka, 
STM, threads, Scala.rx, Async/Await, Iteratees
def index = Action { 
// Make 3 sequential, async calls 
for { 
foo <- WS.url(url1).get() 
bar <- WS.url(url2).get() 
baz <- WS.url(url3).get() 
} yield { 
// Build a result using foo, bar, and baz 
} 
} 
No callback hell!
Good IDE support
Maintenance: the bad parts
Slow compiler
Fortunately, Play/SBT support incremental 
compilation and hot reload!
Complexity
More complexity
Play is stable, but not mature: backwards 
incompatible API changes every release.
Even worse: Scala is not binary compatible 
between releases!
Backwards incompatibility = pain. 
… Static typing makes it a little more manageable.
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7 
10 
10 
10 
10 
3 8
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7 
10 
10 
10 
10 
3 8
544 Contributors 351 
2,376 Watchers 576 
31,332 Stars 5,077 
6,970 Forks 1,872 
3,066 PR’s 2,201 
Github activity as of 08/10/14
StackOverflow 10,698 
53,555 Questions 
Google Group 
14,199 Members 11,577 
Google Group 
~400 Posts/Month ~1,100 
StackOverflow, mailing list activity as of 08/12/14
4 langpop.com 18 
10 TIOBE 39 
5 CodeEval 12 
7 IEEE Spectrum 17 
1 RedMonk 13 
12 Lang-Index 26 
Language Popularity as of 08/12/14
88,000 packages in NPM ~80 Play Modules
88,000 packages in NPM 83,000 artifacts in Maven
Joyent offers commercial 
support for Node.js 
Typesafe offers commercial 
support for Play
Node.js in production
Play in production
1,172 LinkedIn 49 
3,605 Indeed 179 
214 CareerBuilder 16 
Open jobs as of 08/13/14
82,698 LinkedIn 9,037 
2,267 Indeed 206 
447 CareerBuilder 30 
Candidates as of 08/13/14
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7 
10 
10 
10 
10 
3 8 
10 7
Learn 
Develop 
Test 
Secure 
Build 
The framework scorecard 
Deploy 
Debug 
Scale 
Maintain 
Share 
10 7 
8 10 
10 10 
6 8 
10 7 
8 7 
10 
10 
10 
10 
3 8 
10 7
Final score 
85 
84
Final score 
85 
84
Node.js vs Play Framework
Both frameworks are great. Decide based on 
strengths/weakness, not my arbitrary score!
Use node.js if: 
1. You’re building small apps with small teams 
2. You already have a bunch of JavaScript ninjas 
3. Your app is mostly client-side JavaScript 
4. Your app is mostly real-time 
5. Your app is purely I/O bound
Don’t use node.js if: 
1. You don’t write lots of automated tests 
2. Your code base or team is going to get huge 
3. You do lots of CPU or memory intensive tasks
Use Play if: 
1. You’re already using the JVM 
2. You like type safety and functional programming 
3. Your code base or team is going to get big 
4. You want a full stack framework 
5. You need flexibility: non-blocking I/O, blocking I/O, 
CPU intensive tasks, memory intensive tasks
Don’t use Play if: 
1. You don’t have time to master Play, Scala, and SBT 
2. You hate functional programming or static typing
Questions?

More Related Content

What's hot (20)

PPTX
CORNEAL OPACIFICATION (Case presentation)
HibaSherin2
 
PPTX
Vitreous substitutes
SSSIHMS-PG
 
PPTX
Proliferative Vitreoretinopathy
Arindam Rakshit
 
PPTX
Corneal opacity
AbhishekYadav962
 
PPTX
Aqueous humour dynamics
VisheshSAXENA11
 
PPT
Eales’ Disease
guest86523812
 
PPTX
Physiology of cornea
Shreeji Shrestha
 
PPTX
Scleritis a case presentation
Laxmi Eye Institute
 
PPTX
Ptosis
Amr Mounir
 
PPTX
Epiphora
Lakshmi Murthy
 
PPT
Transient Visual Loss
S.M. Hasanuzzaman
 
PPTX
VISUAL FIELD.pptx
Ida Hidayah
 
PPTX
Case presentation-congenital & developmental cataract
Sivarathana
 
PDF
OPTICS OF HUMAN EYE & REFRACTIVE ERRORS
Suraj Dhara
 
PPTX
chemical eye injuries, approach and management
Dana Sultan
 
PPT
Nystagmus and Nystagmoid Movements
neurophq8
 
PPTX
Epiphora
Sivateja Challa
 
PPTX
Anatomy of the eyelids
SAMEEKSHA AGRAWAL
 
PPTX
Corneal degeneration
rakshyabasnet1
 
CORNEAL OPACIFICATION (Case presentation)
HibaSherin2
 
Vitreous substitutes
SSSIHMS-PG
 
Proliferative Vitreoretinopathy
Arindam Rakshit
 
Corneal opacity
AbhishekYadav962
 
Aqueous humour dynamics
VisheshSAXENA11
 
Eales’ Disease
guest86523812
 
Physiology of cornea
Shreeji Shrestha
 
Scleritis a case presentation
Laxmi Eye Institute
 
Ptosis
Amr Mounir
 
Epiphora
Lakshmi Murthy
 
Transient Visual Loss
S.M. Hasanuzzaman
 
VISUAL FIELD.pptx
Ida Hidayah
 
Case presentation-congenital & developmental cataract
Sivarathana
 
OPTICS OF HUMAN EYE & REFRACTIVE ERRORS
Suraj Dhara
 
chemical eye injuries, approach and management
Dana Sultan
 
Nystagmus and Nystagmoid Movements
neurophq8
 
Epiphora
Sivateja Challa
 
Anatomy of the eyelids
SAMEEKSHA AGRAWAL
 
Corneal degeneration
rakshyabasnet1
 

Similar to Node.js vs Play Framework (20)

PDF
Node.js vs Play Framework (with Japanese subtitles)
Yevgeniy Brikman
 
PDF
Play Framework Introduction
m-kurz
 
PDF
Play Framework and Activator
Kevin Webber
 
PDF
Play framework productivity formula
Sorin Chiprian
 
PDF
An Introduction to Play 2 Framework
PT.JUG
 
PDF
Modern Web Framework : Play framework
Suman Adak
 
PDF
Let's Play- Overview
benewu
 
PDF
Play 2.0
elizhender
 
PDF
Play Framework
Harinath Krishnamoorthy
 
PPTX
Silicon Valley Code Camp 2011: Play! as you REST
Manish Pandit
 
PDF
Play Framework: async I/O with Java and Scala
Yevgeniy Brikman
 
PDF
Scala play-framework
Abdhesh Kumar
 
PDF
Using Play Framework 2 in production
Christian Papauschek
 
ODP
eXo Platform SEA - Play Framework Introduction
vstorm83
 
PDF
Web application development using Play Framework (with Java)
Saeed Zarinfam
 
PPT
Hands on web development with play 2.0
Abbas Raza
 
PPTX
How to Play at Work - A Play Framework Tutorial
AssistSoftware
 
PDF
Play Framework: The Basics
Philip Langer
 
PDF
Typesafe stack - Scala, Akka and Play
Luka Zakrajšek
 
PDF
Node.js
Matt Simonis
 
Node.js vs Play Framework (with Japanese subtitles)
Yevgeniy Brikman
 
Play Framework Introduction
m-kurz
 
Play Framework and Activator
Kevin Webber
 
Play framework productivity formula
Sorin Chiprian
 
An Introduction to Play 2 Framework
PT.JUG
 
Modern Web Framework : Play framework
Suman Adak
 
Let's Play- Overview
benewu
 
Play 2.0
elizhender
 
Play Framework
Harinath Krishnamoorthy
 
Silicon Valley Code Camp 2011: Play! as you REST
Manish Pandit
 
Play Framework: async I/O with Java and Scala
Yevgeniy Brikman
 
Scala play-framework
Abdhesh Kumar
 
Using Play Framework 2 in production
Christian Papauschek
 
eXo Platform SEA - Play Framework Introduction
vstorm83
 
Web application development using Play Framework (with Java)
Saeed Zarinfam
 
Hands on web development with play 2.0
Abbas Raza
 
How to Play at Work - A Play Framework Tutorial
AssistSoftware
 
Play Framework: The Basics
Philip Langer
 
Typesafe stack - Scala, Akka and Play
Luka Zakrajšek
 
Node.js
Matt Simonis
 
Ad

More from Yevgeniy Brikman (20)

PDF
Cloud adoption fails - 5 ways deployments go wrong and 5 solutions
Yevgeniy Brikman
 
PDF
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
Yevgeniy Brikman
 
PDF
Lessons learned from writing over 300,000 lines of infrastructure code
Yevgeniy Brikman
 
PPTX
Gruntwork Executive Summary
Yevgeniy Brikman
 
PPTX
Reusable, composable, battle-tested Terraform modules
Yevgeniy Brikman
 
PPTX
The Truth About Startups: What I wish someone had told me about entrepreneurs...
Yevgeniy Brikman
 
PPTX
An intro to Docker, Terraform, and Amazon ECS
Yevgeniy Brikman
 
PPTX
Comprehensive Terraform Training
Yevgeniy Brikman
 
PPTX
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Yevgeniy Brikman
 
PPTX
Agility Requires Safety
Yevgeniy Brikman
 
PPTX
Startup Ideas and Validation
Yevgeniy Brikman
 
PPTX
A Guide to Hiring for your Startup
Yevgeniy Brikman
 
PDF
Startup DNA: Speed Wins
Yevgeniy Brikman
 
PDF
Rapid prototyping
Yevgeniy Brikman
 
PDF
Composable and streamable Play apps
Yevgeniy Brikman
 
PDF
The Play Framework at LinkedIn
Yevgeniy Brikman
 
PDF
Kings of Code Hack Battle
Yevgeniy Brikman
 
PDF
Hackdays and [in]cubator
Yevgeniy Brikman
 
PPTX
Startup DNA: the formula behind successful startups in Silicon Valley (update...
Yevgeniy Brikman
 
PDF
Dust.js
Yevgeniy Brikman
 
Cloud adoption fails - 5 ways deployments go wrong and 5 solutions
Yevgeniy Brikman
 
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
Yevgeniy Brikman
 
Lessons learned from writing over 300,000 lines of infrastructure code
Yevgeniy Brikman
 
Gruntwork Executive Summary
Yevgeniy Brikman
 
Reusable, composable, battle-tested Terraform modules
Yevgeniy Brikman
 
The Truth About Startups: What I wish someone had told me about entrepreneurs...
Yevgeniy Brikman
 
An intro to Docker, Terraform, and Amazon ECS
Yevgeniy Brikman
 
Comprehensive Terraform Training
Yevgeniy Brikman
 
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Yevgeniy Brikman
 
Agility Requires Safety
Yevgeniy Brikman
 
Startup Ideas and Validation
Yevgeniy Brikman
 
A Guide to Hiring for your Startup
Yevgeniy Brikman
 
Startup DNA: Speed Wins
Yevgeniy Brikman
 
Rapid prototyping
Yevgeniy Brikman
 
Composable and streamable Play apps
Yevgeniy Brikman
 
The Play Framework at LinkedIn
Yevgeniy Brikman
 
Kings of Code Hack Battle
Yevgeniy Brikman
 
Hackdays and [in]cubator
Yevgeniy Brikman
 
Startup DNA: the formula behind successful startups in Silicon Valley (update...
Yevgeniy Brikman
 
Ad

Recently uploaded (20)

PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 

Node.js vs Play Framework

  • 1. VS Node.js vs Play Framework
  • 2. Node.js: server-side JavaScript runtime environment; open source; single threaded; non-blocking I/O.
  • 3. express.js: the most popular web framework for Node.js.
  • 4. Play Framework: Java/Scala web framework; open source; multithreaded; non-blocking I/O.
  • 5. Yevgeniy Brikman Former Play Tech Lead at LinkedIn. Long time Node.js user.
  • 6. The framework scorecard Learn Develop Test Secure Build Deploy Debug Scale Maintain Share
  • 7. For each feature we discuss... 1 Much worse than most frameworks About the same as most frameworks Much better than most frameworks 5 10
  • 8. The framework scorecard Learn Develop Test Secure Build Deploy Debug Scale Maintain Share
  • 10. 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/'); server.js The “Hello World” Node app: 1 file, 6 lines of code.
  • 11. var express = require('express'); var app = express(); app.get('/', function(req, res){ res.send('Hello World'); }); var server = app.listen(1337, function() { console.log('Listening on port %d', server.address().port); }); server.js The “Hello World” Express app: 1 file, 8 lines of code.
  • 12. Run using node <filename>. Starts instantly!
  • 15. Node Beginner Book, Mastering Node.js, Node: Up and Running, Node.js in Action
  • 18. Express Web Application Development Express.js Guide
  • 20. And much, much more Tons of resources; very gradual learning curve.
  • 21. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10
  • 22. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10
  • 23. Play: download from playframework.com, extract, add activator to your PATH
  • 24. Generate a new app using activator new
  • 25. The “Hello World” Play app: ~35 files and folders
  • 26. Run the app using activator run
  • 27. (Downloading all dependencies can take a while the first time around)
  • 31. Play for Scala Learning Play Framework 2
  • 32. Ultimate Guide to Getting Started with Play. Not as many resources; steep learning curve.
  • 33. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7
  • 34. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7
  • 35. GET clients/:id Clients.show(id: Long) def show(id: Long) = Action { request => getClient(id).map { client => Ok(views.html.clients.show(client)) } } Routing app.get('clients/:id', function(req, res) { getClient(req.params.id, function(client) { res.render('show', client); }); }); RESTful routing. Extracts query & path params. RESTful routing. Extracts query & path params. Type safe. Actions are composable. Reverse routing.
  • 36. @(name: String, headline: String) <div class="client"> <h1>@name</h1> <div class="headline"> Headline: @headline </div> </div> Templates <div class="client"> <h1>{{name}}</h1> <div class="headline"> Headline: {{headline}} </div> </div> Many template options: handlebars, mustache, dust, jade, etc. Most support client-side rendering! Twirl templates are compiled into Scala functions: type safe and composable! Other template types via plugins.
  • 37. i18n Translations: i18next-node, i18n-node. Formatting: moment.js, numeral.js. Translations: Play i18n API. Formatting: Java formatting libraries. <div class="client"> <h1>{{name}}</h1> <div class="headline"> {{t "headline.label" headline=headline}} </div> </div> @(name: String, headline: String) <div class="client"> <h1>@name</h1> <div class="headline"> Messages("headline.label", headline) </div> </div>
  • 38. var regForm = forms.create({ name: fields.string({required: true}), age: fields.number({min: 18}) Forms, node-formidable, validator.js. Play form binding and validation API. Form binding and validation }); regForm.handle(req, { success: function(form) { ... }, error: function(form) { ... } }); val regForm = Form(mapping( "name" -> nonEmptyText, "age" -> number(min = 18) )(UserData.apply)(UserData.unapply)) regForm.bindFromRequest.fold( err => BadRequest("Validation error"), data => Ok(s"Hi $data.name!") )
  • 39. // Automatically parse application/json body app.use(bodyParser.json()); app.post('/clients', function (req, res, next) { var name = req.body.name; var age = req.body.age; res.send(name + " is " + age + " years old."); }); POST /clients Clients.create case class Person(name: String, age: Int) implicit val prsnFmt = Json.format[Person] def create = Action(parse.json) { request => val person = request.body.as[Person] Ok(s"$person.name is $person.age years old") } bodyParser, xml2js, node-formidable. Play JSON, XML, File Upload APIs. JSON, XML, File Upload
  • 40. Data Slick, Anorm, Ebean, JPA MySQL, MariaDB, PostgreSLQ, SQLite, Oracle, SQL Server, DB2, Derby, H2 Sequelize, Bookshelf.js, node-orm2 SQL MySQL, MariaDB, PostgreSQL, SQLite NoSQL mongojs/mongoose, cassandra-client, cradle/nano, node_redis, node-neo4j MongoDB, Cassandra, CouchDB, Redis, Neo4j ReactiveMongo, DataStax, sprouch, play-plugins- redis, Neo4j-play, JPA MongoDB, Cassandra, CouchDB, Redis, Neo4j node-memcached, connect-cache Caching memcached, in-memory (not recommended) play2-memcached, memcontinuationed, Play Cache, ehcache, Guava memcached, in-memory node-db-migrate, node-migrate Schemas Play database evolutions
  • 41. socket.io: server & client APIs; WebSockets, Flash Sockets, polling, etc. Play WebSockets, Comet, and EventSource APIs. Server-side only. Real-time web // server code io.on('connection', function (socket) { socket.emit('msg', 'Server says hi!'); socket.on('msg', function (msg) { … }); }); def chat = WebSocket.acceptWithActor { request => out => Props(new Chat(out)) } class Chat(out: ActorRef) extends Actor { def receive = { case m: String => out ! s"Got msg: $m" } } // client code socket.emit('msg', 'Client says hi!'); socket.on('msg', function (msg) { … });
  • 42. ● Express.js is a minimal framework ● Play is a full stack framework ● You need plugins for most tasks ● Finding good plugins takes time ● Gluing plugins together takes time ● There are defaults for most tasks ● Defaults are mostly high quality ● All defaults can be replaced
  • 43. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10
  • 44. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10
  • 45. Unit testing: Jasmine, Mocha, QUnit, nodeunit, Expresso or Vows
  • 46. var request = require('supertest') , app = require('express')(); app.get('/user', function(req, res){ res.send(200, { name: 'tobi' }); }); request(app) .get('/user') .expect('Content-Type', /json/) .expect(200); Functional testing: use supertest or call server.listen directly.
  • 47. UI testing: phantom.js or zombie.js
  • 48. Code coverage: Istanbul or Blanket.js
  • 49. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10
  • 50. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10
  • 51. Unit testing: junit, ScalaTest, specs2, or testng
  • 52. "respond to the index Action" in new App(FakeApplication()) { val Some(result) = route(FakeRequest(GET, "/Bob")) status(result) mustEqual OK contentType(result) mustEqual Some("text/html") charset(result) mustEqual Some("utf-8") contentAsString(result) must include ("Hello Bob") } Functional testing: use Play’s built-in functional test helpers.
  • 53. class ExampleSpec extends PlaySpec with OneServerPerSuite with OneBrowserPerSuite { "The OneBrowserPerTest trait" must { "provide a web driver" in { go to (s"http://localhost:$port/testing") pageTitle mustBe "Test Page" click on find(name("b")).value eventually { pageTitle mustBe "scalatest" } } } } UI testing: use Play’s built-in integration test helpers and built-in Selenium support.
  • 55. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10
  • 56. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10
  • 57. (not enabled by default!) Connect CSRF Middleware CSRF (not enabled by default!) Depends on template engine XSS Twirl escapes correctly Vulnerabilities: eval, setTimeout, Injection Security CSRFFilter setInterval, new Function Few vulnerabilities of this sort Helmet middleware Headers SecurityHeadersFilter passport.js, everyauth Auth SecureSocial, deadbolt, play-authenticate Node Security Project Advisories Play Security Vulnerabilities
  • 58. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8
  • 59. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8
  • 60. { "name": "Hello World App", "version": "0.0.3", "dependencies": { "express": "4.8.0", "underscore": "1.6.0" }, "scripts": { "test": "node tests/run.js", "lint": "jshint src" } } Node.js uses NPM to manage dependencies and basic build commands
  • 61. Many options available for more complicated builds: grunt.js, gulp.js, or broccoli
  • 62. Thousands of plugins for all common build tasks
  • 63. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10
  • 64. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10
  • 65. Play uses SBT as the build system. SBT is an interactive build system.
  • 66. object AppBuild extends Build { lazy val root = Project(id = "root", base = file(".")).settings( name := "test-play-app", version := version, libraryDependencies += Seq( "org.scala-tools" % "scala-stm_2.11.1" % "0.3", "org.apache.derby" % "derby" % "10.4.1.3" ) ) def version = Option(System.getProperty("version")).getOrElse("0.0.3") } In SBT, build definitions are written in Scala! … But the learning curve is very steep.
  • 67. Dependencies are managed using Ivy: familiar, but slow.
  • 68. Play uses sbt-web to build static content: few plugins; depends on Rhino (slow) or node.js (!).
  • 69. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7
  • 70. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7
  • 71. Many node-friendly hosting options: Heroku, Joyent, Azure, OpenShift, Nodejitsu
  • 72. Monitoring: New Relic, Nodetime, AppDynamics, node-monitor
  • 73. if (cluster.isMaster) { for (var i = 0; i < numCPUs; i++) { cluster.fork(); // Fork workers } cluster.on('exit', function(worker, code, signal) { console.log('worker ' + worker.process.pid + ' died'); }); } else { http.createServer(function(req, res) { // ... }).listen(8000); } Use cluster to run one node instance per CPU
  • 74. Use forever, monit, or Domain to handle crashes.
  • 75. { "dbConfig": { "host": "localhost", "port": 5984, "dbName": "customers" } } config/default.json var config = require('config'); var host = config.get('dbConfig.host'); server.js Configuration: node-config or nconf
  • 76. Use nginx, apache, or ATS to load balance, serve static content, terminate SSL Client Data Center Reverse proxy (e.g. nginx) DB Static server (e.g. nginx) Node instNaondcee instNaondcee instNaondcee instNaondcee instance Node instNaondcee instNaondcee instNaondcee instance Node instNaondcee instNaondcee instNaondcee instance
  • 77. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8
  • 78. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8
  • 79. A few Play-friendly hosting options: Heroku, playframework-cloud, CloudBees
  • 80. Monitoring: New Relic, metrics-play
  • 81. Use the SBT Native Packager to package the app as tgz, deb, RPM, etc.
  • 82. dbConfig = { host: "localhost", port: 5984, dbName: "customers" } conf/application.conf val host = Play.current.configuration.getString("dbConfig.host") app/controllers/Application.scala Configuration: Play comes with Typesafe Config
  • 83. Use nginx, apache, or ATS to load balance, serve static content, terminate SSL Client Data Center Reverse proxy (e.g. nginx) Play app DB Static server (e.g. nginx) Play app Play app
  • 84. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7
  • 85. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7
  • 86. Node.js: use IntelliJ or node-inspector to debug
  • 87. Use DTrace, TraceGL, node-stackviz, and node-profiler to debug perf issues
  • 88. var winston = require("winston"); winston.info("CHILL WINSTON! ... I put it in the logs."); Use winston, log4js, or bunyan for logging
  • 89. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7 10
  • 90. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7 10
  • 91. Play runs on the JVM, so you can use your favorite IDE to debug: IntelliJ, Eclipse, NetBeans
  • 92. In dev, Play shows errors right in the browser
  • 93. Use YourKit, VisualVM, BTrace, and jmap to debug perf issues
  • 94. Use logback, slf4j, or log4j for logging
  • 95. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7 10 10
  • 96. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7 10 10
  • 97. Part 1: scaling for lots of traffic
  • 98. TechEmpower benchmarks. Warning: microbenchmarks are not a substitute for real world perf testing!
  • 100. Single query (Note: JDBC is blocking!)
  • 101. Multiple queries (Note: JDBC is blocking!)
  • 102. Internet Load Balancer Frontend Server Frontend Server Frontend Server Backend Server Backend Server Backend Server Backend Server Backend Server Data Store Data Store Data Store Data Store LinkedIn experience #1: Play and Node.js are very fast in a service oriented architecture with NIO.
  • 103. // BAD: write files synchronously fs.writeFileSync('message.txt', 'Hello Node'); console.log("It's saved, but you just blocked ALL requests!"); // Good: write files asynchronously fs.writeFile('message.txt', 'Hello Node', function (err) { console.log("It's saved and the server remains responsive!"); }); LinkedIn experience #2: Play is ok with blocking I/O & CPU/memory bound use cases. Node.js is not.
  • 104. Part 2: scaling for large teams and projects
  • 105. Node.js: best for small projects, short projects, small teams.
  • 106. Play: best for longer projects. Slower ramp up, but scales well with team and project size.
  • 108. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7 10 10 10 10
  • 109. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7 10 10 10 10
  • 111. Functional programming: first class functions, closures, underscore.js
  • 113. ...Which means you can share developers, practices, and even code: rendr, derby, meteor
  • 114. Node core is (mostly) stable and mature. Bugs, regressions, and backwards incompatibility are rare.
  • 117. '' == '0' // false 0 == '' // true 0 == '0' // true false == 'false' // false false == '0' // true false == undefined // false false == null // false null == undefined // true ' trn ' == 0 // true Bad Parts
  • 118. // Default scope is global var foo = "I'm a global variable!" // Setting undeclared variables puts them in global scope too bar = "I'm also a global variable!"; if (foo) { // Look ma, no block scope! var baz = "Believe it or not, I'll also be a global variable!" } Awful Parts
  • 119. Wat
  • 121. doSomethingAsync(req1, function(err1, res1) { doSomethingAsync(req2, function(err2, res2) { doSomethingAsync(req3, function(err3, res3) { doSomethingAsync(req4, function(err4, res4) { // ... }); }); }); }); Callback hell: control flow, error handling, and composition are all difficult
  • 122. Many NPM packages are NOT stable or mature. Incompatibility + bugs + dynamic typing = pain.
  • 123. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7 10 10 10 10 3
  • 124. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7 10 10 10 10 3
  • 126. def sort(a: List[Int]): List[Int] = { if (a.length < 2) a else { val pivot = a(a.length / 2) sort(a.filter(_ < pivot)) ::: a.filter(_ == pivot) ::: sort(a.filter(_ > pivot)) Functional programming } }
  • 128. val NameTagPattern = "Hello, my name is (.+) (.+)".r val ListPattern = "Last: (.+). First: (.+).".r // Case classes automatically generate immutable fields, equals, hashCode, constructor case class Name(first: String, last: String) // Use Option to avoid returning null if there is no name found def extractName(str: String): Option[Name] = { Option(str).collectFirst { // Pattern matching on regular expressions case NameTagPattern(fname, lname) => Name(fname, lname) case ListPattern(lname, fname) => Name(fname, lname) } } Very expressive: case classes, pattern matching, lazy, option, implicits
  • 129. Runs on the JVM; interop with Java.
  • 130. Concurrency & streaming tools: Futures, Akka, STM, threads, Scala.rx, Async/Await, Iteratees
  • 131. def index = Action { // Make 3 sequential, async calls for { foo <- WS.url(url1).get() bar <- WS.url(url2).get() baz <- WS.url(url3).get() } yield { // Build a result using foo, bar, and baz } } No callback hell!
  • 135. Fortunately, Play/SBT support incremental compilation and hot reload!
  • 138. Play is stable, but not mature: backwards incompatible API changes every release.
  • 139. Even worse: Scala is not binary compatible between releases!
  • 140. Backwards incompatibility = pain. … Static typing makes it a little more manageable.
  • 141. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7 10 10 10 10 3 8
  • 142. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7 10 10 10 10 3 8
  • 143. 544 Contributors 351 2,376 Watchers 576 31,332 Stars 5,077 6,970 Forks 1,872 3,066 PR’s 2,201 Github activity as of 08/10/14
  • 144. StackOverflow 10,698 53,555 Questions Google Group 14,199 Members 11,577 Google Group ~400 Posts/Month ~1,100 StackOverflow, mailing list activity as of 08/12/14
  • 145. 4 langpop.com 18 10 TIOBE 39 5 CodeEval 12 7 IEEE Spectrum 17 1 RedMonk 13 12 Lang-Index 26 Language Popularity as of 08/12/14
  • 146. 88,000 packages in NPM ~80 Play Modules
  • 147. 88,000 packages in NPM 83,000 artifacts in Maven
  • 148. Joyent offers commercial support for Node.js Typesafe offers commercial support for Play
  • 151. 1,172 LinkedIn 49 3,605 Indeed 179 214 CareerBuilder 16 Open jobs as of 08/13/14
  • 152. 82,698 LinkedIn 9,037 2,267 Indeed 206 447 CareerBuilder 30 Candidates as of 08/13/14
  • 153. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7 10 10 10 10 3 8 10 7
  • 154. Learn Develop Test Secure Build The framework scorecard Deploy Debug Scale Maintain Share 10 7 8 10 10 10 6 8 10 7 8 7 10 10 10 10 3 8 10 7
  • 158. Both frameworks are great. Decide based on strengths/weakness, not my arbitrary score!
  • 159. Use node.js if: 1. You’re building small apps with small teams 2. You already have a bunch of JavaScript ninjas 3. Your app is mostly client-side JavaScript 4. Your app is mostly real-time 5. Your app is purely I/O bound
  • 160. Don’t use node.js if: 1. You don’t write lots of automated tests 2. Your code base or team is going to get huge 3. You do lots of CPU or memory intensive tasks
  • 161. Use Play if: 1. You’re already using the JVM 2. You like type safety and functional programming 3. Your code base or team is going to get big 4. You want a full stack framework 5. You need flexibility: non-blocking I/O, blocking I/O, CPU intensive tasks, memory intensive tasks
  • 162. Don’t use Play if: 1. You don’t have time to master Play, Scala, and SBT 2. You hate functional programming or static typing