Your SlideShare is downloading. ×
0
JavaScript Everywhere            From Nose To Tail            Carl Husselbee - SensisCliffano Subagio (@cliffano) - Shine ...
Citysearch.com.au
New Platform  Improved application performance  Better memory usage  Improved content publishing reliability  Zero content...
The Three Amigos +         +
One JavaScript To Rule Them All
In A Nutshell
CouchDB         Document oriented             Schema free    Design document in JavaScript        Incremental replication ...
DocumentSimply a JSON object{    "_id": "listing-123",    "_rev": "D1C946B7",    "business_name": "Wolfgang Puck",    "des...
Replication Content publishing - replication rule curl -X POST "http://host/_replicate" -d {"source": "db-src", "target": ...
Design DocumentA simple map reduce"views": {   "melbourne_rating": {     "map": function (doc) {         if (doc.city === ...
CradleCouchDB client for Node.jsUses CouchDB REST APIAsynchronousBuilt-in caching
Node.js          Server-side JavaScript              Based on V8             Single Threaded            Non-blocking I/O
Single ThreadedNo more thread deadlockMore predictable app server memory usageLike Nginx vs Apache
Non-blocking I/OI/O is expensiveTraditional web app wastes time on I/O // blocking                      // non-blocking va...
The Callback Trap
Nested Callbacksvar util = require(‘util’), listingId = listing-123;function commentsCb(err, result) {   if (err) {   } el...
A Better WayUse control flow modulevar async = require(async), listingId = listing-123;function getComments(cb) {    db.ge...
Async In A LoopThis looks innocentfor (var i = 0; i < 1000000; i++) {   console.log(Meditate on this, you must!);}
Async In A Loopconsole.log is asynchronousNode.js is faster than terminal display
Library ChangesWithin the past one year: Homegrown web framework >> Express node-couch >> Cradle Various template engines ...
TestingInsanely fast even on slow PC15,000 SLOC100% test coverage34 secondsYUITest, JSCoverage, nodelint
Homegrown ModulesJazz - template engine{foreach doc in widget.docs}   {if (doc.type eq video)}       <span><a href="{doc.v...
More Homegrown ModulesLog4js-node - logging frameworkSeverity level and rolling log fileCouchtato - CouchDB document utili...
Continuous Integration Jenkins Node.js Plugin Nestor - Jenkins Node.js CLI
Conclusion      CouchDB rocks! Node.js rocks!       JavaScript web stack rocks!
Questions?
ResourcesCouchDB - http://couchdb.apache.orgNode.js - http://nodejs.orgJazz - http://github.com/shinetech/jazzlog4js-node ...
Credits http://www.flickr.com/photos/daveaustria/2654190796/ by Dave Austria http://www.flickr.com/photos/38485387@N02/358...
Upcoming SlideShare
Loading in...5
×

Javascript Everywhere From Nose To Tail

7,648

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
7,648
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
51
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "Javascript Everywhere From Nose To Tail"

    1. 1. JavaScript Everywhere From Nose To Tail Carl Husselbee - SensisCliffano Subagio (@cliffano) - Shine Technologies
    2. 2. Citysearch.com.au
    3. 3. New Platform Improved application performance Better memory usage Improved content publishing reliability Zero content duplication Improved user experience(project is still ongoing...)
    4. 4. The Three Amigos + +
    5. 5. One JavaScript To Rule Them All
    6. 6. In A Nutshell
    7. 7. CouchDB Document oriented Schema free Design document in JavaScript Incremental replication HTTP API
    8. 8. DocumentSimply 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. 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. 10. Design DocumentA 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 testableEasy to mock up
    11. 11. CradleCouchDB client for Node.jsUses CouchDB REST APIAsynchronousBuilt-in caching
    12. 12. Node.js Server-side JavaScript Based on V8 Single Threaded Non-blocking I/O
    13. 13. Single ThreadedNo more thread deadlockMore predictable app server memory usageLike Nginx vs Apache
    14. 14. Non-blocking I/OI/O is expensiveTraditional 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
    15. 15. The Callback Trap
    16. 16. Nested Callbacksvar 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. 17. A Better WayUse control flow modulevar 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. 18. Async In A LoopThis looks innocentfor (var i = 0; i < 1000000; i++) { console.log(Meditate on this, you must!);}
    19. 19. Async In A Loopconsole.log is asynchronousNode.js is faster than terminal display
    20. 20. Library ChangesWithin the past one year: Homegrown web framework >> Express node-couch >> Cradle Various template engines >> Jazz Promises >> Callbacks + Async
    21. 21. TestingInsanely fast even on slow PC15,000 SLOC100% test coverage34 secondsYUITest, JSCoverage, nodelint
    22. 22. Homegrown ModulesJazz - 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 logicSynchronous compilation, asynchronous evalua
    23. 23. More Homegrown ModulesLog4js-node - logging frameworkSeverity level and rolling log fileCouchtato - CouchDB document utility toolDoesn’t require CouchDB design doc knowledge
    24. 24. Continuous Integration Jenkins Node.js Plugin Nestor - Jenkins Node.js CLI
    25. 25. Conclusion CouchDB rocks! Node.js rocks! JavaScript web stack rocks!
    26. 26. Questions?
    27. 27. ResourcesCouchDB - http://couchdb.apache.orgNode.js - http://nodejs.orgJazz - http://github.com/shinetech/jazzlog4js-node - http://github.com/csausdev/log4js-nodeCouchtato - http://github.com/cliffano/couchtatoJenkins Node.js Plugin - https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+PluginNestor - http://github.com/cliffano/nestor
    28. 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/
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×