JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka

3,328 views
3,220 views

Published on

JSCon 2011, arranged by phpXperts. held in American International University Bangladesh.

Published in: Technology

JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka

  1. 1. NodeJS JS as a Server-side Language Iraj Islam @irajislam Nurul Ferdous @ferdous NewsCredSaturday, September 17, 2011
  2. 2. Agenda NewsCred • Part 1. NodeJS • Part 2. ExpressJS • Questions?Saturday, September 17, 2011
  3. 3. Who We Are NewsCred Iraj Islam CTO/Co-founder, NewsCred Nurul Ferdous Senior Software Engineer, NewsCredSaturday, September 17, 2011
  4. 4. Part 1 NodeJS NewsCredSaturday, September 17, 2011
  5. 5. Server-side JS NewsCredSaturday, September 17, 2011
  6. 6. What’s NodeJS? NewsCred NodeJS What’s this all about?Saturday, September 17, 2011
  7. 7. What’s NodeJS? NewsCred NodeJS Evented I/O for V8 JavaScript.Saturday, September 17, 2011
  8. 8. What’s NodeJS? NewsCred Goal “Provide an easy way to build scalable network programs.”Saturday, September 17, 2011
  9. 9. History NewsCred The Evolution of the Web From static pages to real time data.Saturday, September 17, 2011
  10. 10. Why NodeJS? NewsCred The Age of Big Data Exabytes (1018) of data stored per year 1000 750 500 250 2006 2007 2008 0 2009 2010Saturday, September 17, 2011
  11. 11. Why NodeJS? NewsCred The Fast Food Analogy Synchronous vs. AsynchronousSaturday, September 17, 2011
  12. 12. Why NodeJS? NewsCred The Apache Solution Synchronous I/O Application File User readFile(); System getTweets(); Twitter API writeToDb(); MySQLSaturday, September 17, 2011
  13. 13. Why NodeJS? NewsCred The Apache Solution Blocking I/O Application File User readFile(); System Waiting... getTweets(); Twitter API Waiting... writeToDb(); MySQLSaturday, September 17, 2011
  14. 14. Why NodeJS? NewsCred The NodeJS Solution Asynchronous I/O Application File User readFile(); System getTweets(); Twitter API writeToDb(); MySQLSaturday, September 17, 2011
  15. 15. Why NodeJS? NewsCred The NodeJS Solution Non-blocking I/O Application File User readFile(); System getTweets(); Twitter API writeToDb(); MySQLSaturday, September 17, 2011
  16. 16. NodeJS Benefits NewsCred • Fast • Built on top of Google’s V8 JavaScript engine. • Scalable • Asynchronous, event-driven I/O model yields web scale. • Programmable • JavaScript API and pluggable module architecture.Saturday, September 17, 2011
  17. 17. NodeJS Use Cases NewsCred • Serving APIs • Serving real-time apps • Serving web apps • Streaming dataSaturday, September 17, 2011
  18. 18. NodeJS “Hello World!” NewsCred var http = require(http); http.createServer(function (request, response) { response.writeHead(200, {Content-Type: text/plain}); response.writeHead(Hello World!); }).listen(1337, 127.0.0.1);Saturday, September 17, 2011
  19. 19. Who’s Using NodeJS? NewsCredSaturday, September 17, 2011
  20. 20. Installing NodeJS NewsCred • Installing on Unix • Installing on Windows • Run http://nodejs.org/dist/v0.5.6/node.exeSaturday, September 17, 2011
  21. 21. Installing npm NewsCred • Node Package Manager (npm) • One line install: • curl http://npmjs.org/install.sh | sudo sh • Multi-line install: • Get the code from http://github.com/isaacs/npm • Do what the REAMME saysSaturday, September 17, 2011
  22. 22. Part 2 ExpressJS NewsCredSaturday, September 17, 2011
  23. 23. What’s ExpressJS? NewsCred ExpressJS High-performance NodeJS web framework.Saturday, September 17, 2011
  24. 24. Why ExpressJS? NewsCred • Full blown feature set • Routing • View rendering/templating • Sessions • Good documentation • Lots of examples • Many extensionsSaturday, September 17, 2011
  25. 25. Installing ExpressJS NewsCredSaturday, September 17, 2011
  26. 26. Directory Structure NewsCredSaturday, September 17, 2011
  27. 27. Configuration NewsCredSaturday, September 17, 2011
  28. 28. Application Settings NewsCredSaturday, September 17, 2011
  29. 29. Routing NewsCredSaturday, September 17, 2011
  30. 30. View Rendering NewsCred • Haml templates • Haml • Jade • Embedded JavaScript (EJS) templates • Coffeekup templates • Uses CoffeeScript • jQuery templatesSaturday, September 17, 2011
  31. 31. Views with Jade NewsCredSaturday, September 17, 2011
  32. 32. Sessions NewsCred • Currently cookie-based • Data store can be Redis, memory etc.Saturday, September 17, 2011
  33. 33. Packages NewsCred $ npm install -d # for installing dependanciesSaturday, September 17, 2011
  34. 34. Resources NewsCred • NodeJS • http://nodejs.org • http://github.com/dynamicguy/node-mongo-cms • ExpressJS • http://expressjs.com • Sencha Connect • http://github.com/senchalabs/connect/wikiSaturday, September 17, 2011
  35. 35. Questions? NewsCred Iraj Islam iraj@newscred.com, @irajislam Nurul Ferdous nurul@newscred.com, @ferdousSaturday, September 17, 2011

×