1 / 14

TechTalk: Node.js

TechTalk: Node.js. Jessica Davis, Juan Herrera, Ian Hoyt-McCullough, Varun Verma. Overview of Node.js. What is Node.js? An open-source, cross-platform JavaScript run-time environment that executes JavaScript code in a computing environment What is Node.js capable of doing?

pfogle
Download Presentation

TechTalk: Node.js

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TechTalk: Node.js Jessica Davis, Juan Herrera, Ian Hoyt-McCullough, Varun Verma

  2. Overview of Node.js • What is Node.js? • An open-source, cross-platform JavaScript run-time environment that executes JavaScript code in a computing environment • What is Node.js capable of doing? • Generating dynamic page content • Creating, opening, reading, writing,, deleting, and closing files on the server • Collecting form data • Adding, deleting, modifying data in your database • What operating systems officially support Node.js? • Linux, macOS, Microsoft Windows, and more • How is Node.js primarily used? • To build network programs, like web servers

  3. History of Node.js • 2009: Originally written by Ryan Dahl • Initial release supported on Linux and Mac OS X • Created after seeing a file upload progress bar on Flickr • Had to query the Web server for more information about the file • Node.js is a combination of: • Google’s V8 JavaScript engine • An event loop • A low-level I/O API • January 2010: npm was released as a package manager for Node.js • June 2011: Node.js was expanded to support more operating systems

  4. Demo A short demo… • npm init • npm scripts (npm start, npm test) • npm install <module> (nodemon) • Server code (next slide) • Dependencies (package.json)

  5. Demo var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.end('Hello world!'); }).listen(8000);

  6. Pros • Javascript easy to learn for front-end developers • Compiles directly into machine code • Many resources and support available • High support for asynchronous events • Handles concurrent requests sequentially in a single thread, using less RAM and system resources

  7. Cons • Cons • The single-threaded design can create bottlenecks when used in tasks with lots of computation • Must be careful dealing with exceptions in code, as uncaught ones may “bubble up” to the core node.js loop and crash the program for all requests • Coding paradigm is highly reliant on asynchronous callbacks, or functions run after certain functions return, so the scope and dependencies in the code can quickly become confusing, resulting in “callback hell” (need to learn to effective use of Promises in order to counteract this)

  8. Alternatives/Competition Ruby on Rails • Good for flexible databases • Worse performance than Node.js Django • Highly Scalable • Monolithic, not fit for small apps Flask • Minimalist, easy to learn • Not much Asynchronous support Php • SQL integration is very simple, huge existing codebase • Not as powerful or flexible as Node.js

  9. Use Cases • Good for streaming • Audio and Video files • Web apps similar to SoundCloud & Youtube • Specially suited for applications where you want to maintain persistent connection from the browser to server • Real-time updates • Online games • Collaborative tools • Chat interfaces • Gmail for instance • Cases of rapid development due to an extensive NPM ecosystem and ease of configuration • Cheaper cloud hosting • Desire a highly scalable application • Unified JavaScript development platform as it integrates well with MongoDB, AngularJS, & ReactJS

  10. Use Cases -Uber: Instantaneous real time updates, non-blocking -Netflix: Handles the real time audio & video streaming efficiently -LinkedIn: Efficiency & scale. Servers cut down from 15 to 4, & traffic capacity doubled -NASA: Reduced access time by 300%. This is due to the persistent connection maintained by the server

  11. Use Case Chat Example: Event Driven Apps var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); app.get('/', function(req, res){ res.sendFile(__dirname + '/index.html'); }); io.on('connection', function(socket){ console.log('an user connected'); socket.on('disconnect', function(){ console.log('user disconnected'); }); }); http.listen(3000, function(){ console.log('listening on *:3000'); });

  12. Use Case Chat Example: Event Driven Apps

  13. Any Questions?

  14. Sources/References https://www.mindinventory.com/blog/pros-and-cons-of-node-js-web-app-development/ https://www.netguru.com/blog/pros-cons-use-node.js-backend https://medium.com/the-node-js-collection/why-the-hell-would-you-use-node-js-4b053b94ab8e https://www.w3schools.com/nodejs/nodejs_intro.asp https://en.wikipedia.org/wiki/Node.js#Overview https://medium.com/@TechMagic/nodejs-vs-ruby-on-rails-comparison-2017-which-is-the-best-for-web-development-9aae7a3f08bf https://dzone.com/articles/nodejs-vs-djangois-javascript-better-than-python https://www.codingdojo.com/blog/choosing-python-web-frameworks

More Related