SlideShare a Scribd company logo
1 of 28
JavaScript Everywhere
            From Nose To Tail




            Carl Husselbee - Sensis
Cliffano Subagio (@cliffano) - Shine Technologies
Citysearch.com.au
New Platform

  Improved application performance
  Better memory usage
  Improved content publishing reliability
  Zero content duplication
  Improved user experience

(project is still ongoing...)
The Three Amigos



 +         +
One JavaScript To Rule Them All
In A Nutshell
CouchDB
         Document oriented

             Schema free

    Design document in JavaScript

        Incremental replication

              HTTP API
Document

Simply a JSON object
{
    "_id": "listing-123",
    "_rev": "D1C946B7",
    "business_name": "Wolfgang Puck",
    "desc": "Fine dining and casual dining...",
    "rating": 5,
    "city": "Melbourne"
}

Stays as JSON on all layers
Replication


 Content publishing - replication rule
 curl -X POST "http://host/_replicate"
 -d '{"source": "db-src", "target": "db-target", "continuous": true}'
 -H "Content-Type: application/json"

 Content indexing - continuous changes feed
 curl -X GET "http://host/db/_changes?feed=continuous&since=123"
Design Document
A simple map reduce
"views": {
   "melbourne_rating": {
     "map": function (doc) {
         if (doc.city === 'Melbourne') { emit(null, doc.rating); }
     },
     "reduce": function (key, values, rereduce) {
         return sum(values);
     }}}

Highly testable
Easy to mock up
Cradle


CouchDB client for Node.js
Uses CouchDB REST API
Asynchronous
Built-in caching
Node.js

          Server-side JavaScript


              Based on V8


             Single Threaded


            Non-blocking I/O
Single Threaded
No more thread deadlock
More predictable app server memory usage
Like Nginx vs Apache
Non-blocking I/O

I/O is expensive
Traditional web app wastes time on I/O
 // blocking                      // non-blocking
 var listings = db.getListings(); var callback = function
 render(listings);                (listings) {
                                      render(listings);
                                  }
                                  db.getListings(callback);


Node.js provides non-blocking API
The Callback Trap
Nested Callbacks
var util = require(‘util’), listingId = 'listing-123';
function commentsCb(err, result) {
   if (err) {
   } else {
       console.log('Comments: ' + util.inspect(result));
   }
}
function listingCb(err, result) {
   if (err) {
   } else {
       console.log('Listing: ' + util.inspect(result));
       db.getComments(listingId, commentsCb)
   }
}
db.getListing(listingId, listingCb);
A Better Way
Use control flow module
var async = require('async'), listingId = 'listing-123';
function getComments(cb) {
    db.getComments(listingId, cb);
}
function getListing(cb) {
    db.getListing(listingId, cb);
}
async.parallel({ comments: getComments, listing: getListing },
function (err, results) {
    // results gives { listing: listingResult, comments: commentsResult }
});

Lots of other solutions: TameJS, Step, Seq, etc
Async In A Loop

This looks innocent

for (var i = 0; i < 1000000; i++) {
   console.log('Meditate on this, you must!');
}
Async In A Loop


console.log is asynchronous
Node.js is faster than terminal display
Library Changes

Within the past one year:
 Homegrown web framework >> Express
 node-couch >> Cradle
 Various template engines >> Jazz
 Promises >> Callbacks + Async
Testing

Insanely fast even on slow PC
15,000 SLOC
100% test coverage
34 seconds
YUITest, JSCoverage, nodelint
Homegrown Modules
Jazz - template engine
{foreach doc in widget.docs}
   {if (doc.type eq 'video')}
       <span><a href="{doc.videourl}">{doc.title}</a></span>
   {else}
       <a href="{helper.createUrl(doc.key)}">
          <h3>{doc.title}</h3>
       </a>
   {end}
{end}

No business logic
Synchronous compilation, asynchronous evalua
More Homegrown Modules


Log4js-node - logging framework
Severity level and rolling log file
Couchtato - CouchDB document utility tool
Doesn’t require CouchDB design doc knowledge
Continuous Integration


 Jenkins Node.js Plugin
 Nestor - Jenkins Node.js CLI
Conclusion




      CouchDB rocks! Node.js rocks!
       JavaScript web stack rocks!
Questions?
Resources
CouchDB - http://couchdb.apache.org

Node.js - http://nodejs.org

Jazz - http://github.com/shinetech/jazz

log4js-node - http://github.com/csausdev/log4js-node

Couchtato - http://github.com/cliffano/couchtato

Jenkins Node.js Plugin - https://wiki.jenkins-ci.org/display/JENKINS/NodeJS
+Plugin

Nestor - http://github.com/cliffano/nestor
Credits


 http://www.flickr.com/photos/daveaustria/2654190796/ by Dave Austria

 http://www.flickr.com/photos/38485387@N02/3580728177/ by flickrfavorites

 http://www.housecontainer.nl/blog/about-me/127-dj-yoda-from-star-wars.html

 http://www.miccicohan.net/blog/studio-antics-and-of-coursethe-rolling-stones/

More Related Content

What's hot

Functional Web Development
Functional Web DevelopmentFunctional Web Development
Functional Web Development
FITC
 
Scalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JSScalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JS
Cosmin Mereuta
 

What's hot (20)

AWS user group September 2017 - Rob Ribeiro "Seeking Solutions for Debugging ...
AWS user group September 2017 - Rob Ribeiro "Seeking Solutions for Debugging ...AWS user group September 2017 - Rob Ribeiro "Seeking Solutions for Debugging ...
AWS user group September 2017 - Rob Ribeiro "Seeking Solutions for Debugging ...
 
Functional Web Development
Functional Web DevelopmentFunctional Web Development
Functional Web Development
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
 
Event Loop in Javascript
Event Loop in JavascriptEvent Loop in Javascript
Event Loop in Javascript
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platforms
 
«От экспериментов с инфраструктурой до внедрения в продакшен»​
«От экспериментов с инфраструктурой до внедрения в продакшен»​«От экспериментов с инфраструктурой до внедрения в продакшен»​
«От экспериментов с инфраструктурой до внедрения в продакшен»​
 
Google App Engine Developer - Day4
Google App Engine Developer - Day4Google App Engine Developer - Day4
Google App Engine Developer - Day4
 
"Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native ""Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native "
 
Playing With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsPlaying With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.js
 
Cutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryCutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQuery
 
Server Side Event Driven Programming
Server Side Event Driven ProgrammingServer Side Event Driven Programming
Server Side Event Driven Programming
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Mssql to mysql - Anton Ivanov
Mssql to mysql - Anton IvanovMssql to mysql - Anton Ivanov
Mssql to mysql - Anton Ivanov
 
Headless drupal + react js Oleksandr Linyvyi
Headless drupal + react js   Oleksandr LinyvyiHeadless drupal + react js   Oleksandr Linyvyi
Headless drupal + react js Oleksandr Linyvyi
 
OpenStreetMap is Data
OpenStreetMap is DataOpenStreetMap is Data
OpenStreetMap is Data
 
Scalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JSScalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JS
 
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
 
Umleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB appUmleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB app
 
LAMP Stack (Reloaded) - Infrastructure as Code with Terraform & Packer
LAMP Stack (Reloaded) - Infrastructure as Code with Terraform & PackerLAMP Stack (Reloaded) - Infrastructure as Code with Terraform & Packer
LAMP Stack (Reloaded) - Infrastructure as Code with Terraform & Packer
 
非同期javascriptの過去と未来
非同期javascriptの過去と未来非同期javascriptの過去と未来
非同期javascriptの過去と未来
 

Viewers also liked (7)

5 Tips for Writing Better JavaScript
5 Tips for Writing Better JavaScript5 Tips for Writing Better JavaScript
5 Tips for Writing Better JavaScript
 
Using Node.js for everything or what it is to write a book about it
Using Node.js for everything or what it is to write a book about itUsing Node.js for everything or what it is to write a book about it
Using Node.js for everything or what it is to write a book about it
 
Developing large scale JavaScript applications
Developing large scale JavaScript applicationsDeveloping large scale JavaScript applications
Developing large scale JavaScript applications
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture
 
Reactjs - the good, the bad and the ugly
Reactjs - the good, the bad and the uglyReactjs - the good, the bad and the ugly
Reactjs - the good, the bad and the ugly
 
Unidirectional data flow
Unidirectional data flowUnidirectional data flow
Unidirectional data flow
 
Modern Web Applications
Modern Web ApplicationsModern Web Applications
Modern Web Applications
 

Similar to Javascript Everywhere From Nose To Tail

Node js introduction
Node js introductionNode js introduction
Node js introduction
Alex Su
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
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
Tatsuhiko Miyagawa
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsFull-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.js
Michael Lehmann
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
Ben Lin
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
Igor Bronovskyy
 
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache KafkaSolutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Guido Schmutz
 
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
confluent
 
Node js
Node jsNode js
Node js
hazzaz
 

Similar to Javascript Everywhere From Nose To Tail (20)

NodeJS
NodeJSNodeJS
NodeJS
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Future Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NETFuture Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NET
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Quick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase ServerQuick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase Server
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 
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
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsFull-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.js
 
Serverless in-action
Serverless in-actionServerless in-action
Serverless in-action
 
Serverless archtiectures
Serverless archtiecturesServerless archtiectures
Serverless archtiectures
 
e-suap - client technologies- english version
e-suap - client technologies- english versione-suap - client technologies- english version
e-suap - client technologies- english version
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
AngularJS and SPA
AngularJS and SPAAngularJS and SPA
AngularJS and SPA
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache KafkaSolutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
 
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
 
Data models in Angular 1 & 2
Data models in Angular 1 & 2Data models in Angular 1 & 2
Data models in Angular 1 & 2
 
Node js
Node jsNode js
Node js
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Couchbas for dummies
Couchbas for dummiesCouchbas for dummies
Couchbas for dummies
 

More from Cliffano Subagio

Cross-Workloads Resource-Level Relationship in AWS
Cross-Workloads Resource-Level Relationship in AWSCross-Workloads Resource-Level Relationship in AWS
Cross-Workloads Resource-Level Relationship in AWS
Cliffano Subagio
 

More from Cliffano Subagio (20)

Cross-Workloads Resource-Level Relationship in AWS
Cross-Workloads Resource-Level Relationship in AWSCross-Workloads Resource-Level Relationship in AWS
Cross-Workloads Resource-Level Relationship in AWS
 
AEM OpenCloud Delivery Practices
AEM OpenCloud Delivery PracticesAEM OpenCloud Delivery Practices
AEM OpenCloud Delivery Practices
 
OpenAPI Generator The Babel Fish of The API World - apidays Live Paris
OpenAPI Generator The Babel Fish of The API World - apidays Live ParisOpenAPI Generator The Babel Fish of The API World - apidays Live Paris
OpenAPI Generator The Babel Fish of The API World - apidays Live Paris
 
OpenAPI Generator The Babel Fish of The API World - apidays Live Australia
OpenAPI Generator The Babel Fish of The API World - apidays Live AustraliaOpenAPI Generator The Babel Fish of The API World - apidays Live Australia
OpenAPI Generator The Babel Fish of The API World - apidays Live Australia
 
A Journey to Improve Infrastructure Compliance With InSpec
A Journey to Improve Infrastructure Compliance With InSpecA Journey to Improve Infrastructure Compliance With InSpec
A Journey to Improve Infrastructure Compliance With InSpec
 
How to Fit an Infrastructure Platform into Multiple Enterprise Environments
How to Fit an Infrastructure Platform into Multiple Enterprise EnvironmentsHow to Fit an Infrastructure Platform into Multiple Enterprise Environments
How to Fit an Infrastructure Platform into Multiple Enterprise Environments
 
Swagger AEM - An OpenAPI Specification for AEM
Swagger AEM - An OpenAPI Specification for AEMSwagger AEM - An OpenAPI Specification for AEM
Swagger AEM - An OpenAPI Specification for AEM
 
Introducing AEM OpenCloud
Introducing AEM OpenCloudIntroducing AEM OpenCloud
Introducing AEM OpenCloud
 
A Quick Look at Accessibility in the World of DevOps
A Quick Look at Accessibility in the World of DevOpsA Quick Look at Accessibility in the World of DevOps
A Quick Look at Accessibility in the World of DevOps
 
Conversation With Your Application Using DialogFlow and CloudFunctions
Conversation With Your Application Using DialogFlow and CloudFunctionsConversation With Your Application Using DialogFlow and CloudFunctions
Conversation With Your Application Using DialogFlow and CloudFunctions
 
Let's Build Voice Assistant Learning Games For Kids
Let's Build Voice Assistant Learning Games For KidsLet's Build Voice Assistant Learning Games For Kids
Let's Build Voice Assistant Learning Games For Kids
 
Having A Talk With Jenkins
Having A Talk With JenkinsHaving A Talk With Jenkins
Having A Talk With Jenkins
 
AEM Open Cloud - The First Two Years
AEM Open Cloud - The First Two YearsAEM Open Cloud - The First Two Years
AEM Open Cloud - The First Two Years
 
AEM OpenCloud - What's New Since 2.0.0
AEM OpenCloud - What's New Since 2.0.0AEM OpenCloud - What's New Since 2.0.0
AEM OpenCloud - What's New Since 2.0.0
 
Beyond AEM Curl Commands
Beyond AEM Curl CommandsBeyond AEM Curl Commands
Beyond AEM Curl Commands
 
AEM OpenCloud
AEM OpenCloudAEM OpenCloud
AEM OpenCloud
 
Open Source AEM Platform: A Short Intro
Open Source AEM Platform: A Short IntroOpen Source AEM Platform: A Short Intro
Open Source AEM Platform: A Short Intro
 
How To Play Music On A Vacuum Cleaner
How To Play Music On A Vacuum CleanerHow To Play Music On A Vacuum Cleaner
How To Play Music On A Vacuum Cleaner
 
Bringing Jenkins Remote Access API To The Masses
Bringing Jenkins Remote Access API To The MassesBringing Jenkins Remote Access API To The Masses
Bringing Jenkins Remote Access API To The Masses
 
Application Deployment Using Ansible
Application Deployment Using AnsibleApplication Deployment Using Ansible
Application Deployment Using Ansible
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Javascript Everywhere From Nose To Tail

  • 1. JavaScript Everywhere From Nose To Tail Carl Husselbee - Sensis Cliffano Subagio (@cliffano) - Shine Technologies
  • 3. New Platform Improved application performance Better memory usage Improved content publishing reliability Zero content duplication Improved user experience (project is still ongoing...)
  • 5. One JavaScript To Rule Them All
  • 7. CouchDB Document oriented Schema free Design document in JavaScript Incremental replication HTTP API
  • 8. Document Simply a JSON object { "_id": "listing-123", "_rev": "D1C946B7", "business_name": "Wolfgang Puck", "desc": "Fine dining and casual dining...", "rating": 5, "city": "Melbourne" } Stays as JSON on all layers
  • 9. Replication Content publishing - replication rule curl -X POST "http://host/_replicate" -d '{"source": "db-src", "target": "db-target", "continuous": true}' -H "Content-Type: application/json" Content indexing - continuous changes feed curl -X GET "http://host/db/_changes?feed=continuous&since=123"
  • 10. Design Document A simple map reduce "views": { "melbourne_rating": { "map": function (doc) { if (doc.city === 'Melbourne') { emit(null, doc.rating); } }, "reduce": function (key, values, rereduce) { return sum(values); }}} Highly testable Easy to mock up
  • 11. Cradle CouchDB client for Node.js Uses CouchDB REST API Asynchronous Built-in caching
  • 12. Node.js Server-side JavaScript Based on V8 Single Threaded Non-blocking I/O
  • 13. Single Threaded No more thread deadlock More predictable app server memory usage Like Nginx vs Apache
  • 14. Non-blocking I/O I/O is expensive Traditional web app wastes time on I/O // blocking // non-blocking var listings = db.getListings(); var callback = function render(listings); (listings) { render(listings); } db.getListings(callback); Node.js provides non-blocking API
  • 16. Nested Callbacks var util = require(‘util’), listingId = 'listing-123'; function commentsCb(err, result) { if (err) { } else { console.log('Comments: ' + util.inspect(result)); } } function listingCb(err, result) { if (err) { } else { console.log('Listing: ' + util.inspect(result)); db.getComments(listingId, commentsCb) } } db.getListing(listingId, listingCb);
  • 17. A Better Way Use control flow module var async = require('async'), listingId = 'listing-123'; function getComments(cb) { db.getComments(listingId, cb); } function getListing(cb) { db.getListing(listingId, cb); } async.parallel({ comments: getComments, listing: getListing }, function (err, results) { // results gives { listing: listingResult, comments: commentsResult } }); Lots of other solutions: TameJS, Step, Seq, etc
  • 18. Async In A Loop This looks innocent for (var i = 0; i < 1000000; i++) { console.log('Meditate on this, you must!'); }
  • 19. Async In A Loop console.log is asynchronous Node.js is faster than terminal display
  • 20. Library Changes Within the past one year: Homegrown web framework >> Express node-couch >> Cradle Various template engines >> Jazz Promises >> Callbacks + Async
  • 21. Testing Insanely fast even on slow PC 15,000 SLOC 100% test coverage 34 seconds YUITest, JSCoverage, nodelint
  • 22. Homegrown Modules Jazz - template engine {foreach doc in widget.docs} {if (doc.type eq 'video')} <span><a href="{doc.videourl}">{doc.title}</a></span> {else} <a href="{helper.createUrl(doc.key)}"> <h3>{doc.title}</h3> </a> {end} {end} No business logic Synchronous compilation, asynchronous evalua
  • 23. More Homegrown Modules Log4js-node - logging framework Severity level and rolling log file Couchtato - CouchDB document utility tool Doesn’t require CouchDB design doc knowledge
  • 24. Continuous Integration Jenkins Node.js Plugin Nestor - Jenkins Node.js CLI
  • 25. Conclusion CouchDB rocks! Node.js rocks! JavaScript web stack rocks!
  • 27. Resources CouchDB - http://couchdb.apache.org Node.js - http://nodejs.org Jazz - http://github.com/shinetech/jazz log4js-node - http://github.com/csausdev/log4js-node Couchtato - http://github.com/cliffano/couchtato Jenkins Node.js Plugin - https://wiki.jenkins-ci.org/display/JENKINS/NodeJS +Plugin Nestor - http://github.com/cliffano/nestor
  • 28. Credits http://www.flickr.com/photos/daveaustria/2654190796/ by Dave Austria http://www.flickr.com/photos/38485387@N02/3580728177/ by flickrfavorites http://www.housecontainer.nl/blog/about-me/127-dj-yoda-from-star-wars.html http://www.miccicohan.net/blog/studio-antics-and-of-coursethe-rolling-stones/

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n