Your SlideShare is downloading. ×
0
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Javascript Everywhere From Nose To Tail

7,567

Published on

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

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

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
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

    • 1. JavaScript Everywhere From Nose To Tail Carl Husselbee - SensisCliffano Subagio (@cliffano) - Shine Technologies
    • 2. Citysearch.com.au
    • 3. New Platform Improved application performance Better memory usage Improved content publishing reliability Zero content duplication Improved user experience(project is still ongoing...)
    • 4. The Three Amigos + +
    • 5. One JavaScript To Rule Them All
    • 6. In A Nutshell
    • 7. CouchDB Document oriented Schema free Design document in JavaScript Incremental replication HTTP API
    • 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. 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 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. CradleCouchDB client for Node.jsUses CouchDB REST APIAsynchronousBuilt-in caching
    • 12. Node.js Server-side JavaScript Based on V8 Single Threaded Non-blocking I/O
    • 13. Single ThreadedNo more thread deadlockMore predictable app server memory usageLike Nginx vs Apache
    • 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. The Callback Trap
    • 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. 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. Async In A LoopThis looks innocentfor (var i = 0; i < 1000000; i++) { console.log(Meditate on this, you must!);}
    • 19. Async In A Loopconsole.log is asynchronousNode.js is faster than terminal display
    • 20. Library ChangesWithin the past one year: Homegrown web framework >> Express node-couch >> Cradle Various template engines >> Jazz Promises >> Callbacks + Async
    • 21. TestingInsanely fast even on slow PC15,000 SLOC100% test coverage34 secondsYUITest, JSCoverage, nodelint
    • 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. More Homegrown ModulesLog4js-node - logging frameworkSeverity level and rolling log fileCouchtato - CouchDB document utility toolDoesn’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!
    • 26. Questions?
    • 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. 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/

    ×