Skip to content
Snippets Groups Projects
Commit be9c4bfd authored by Stefan Dierauf's avatar Stefan Dierauf
Browse files

updtaed outline + new slides'

parent 38601d86
No related branches found
No related tags found
No related merge requests found
...@@ -34,7 +34,7 @@ module.exports = (grunt) -> ...@@ -34,7 +34,7 @@ module.exports = (grunt) ->
livereload: livereload:
options: options:
port: process.env.PORT || 80 port: process.env.PORT || 3000
# Change hostname to '0.0.0.0' to access # Change hostname to '0.0.0.0' to access
# the server from outside. # the server from outside.
hostname: '0.0.0.0' hostname: '0.0.0.0'
......
...@@ -10,10 +10,12 @@ var requestHandler = function (request, response) { ...@@ -10,10 +10,12 @@ var requestHandler = function (request, response) {
} }
http.createServer(requestHandler).listen(1337, '127.0.0.1'); http.createServer(requestHandler).listen(1337, '127.0.0.1');
``` ```
- important background stuff about node
- can handle all kinds of requests, GET, POST etc via 'request' object thats passed to the handler - can handle all kinds of requests, GET, POST etc via 'request' object thats passed to the handler
- plenty of 'modules' that make this less of a pain - plenty of 'modules' that make this less of a pain
- so simple!! - so simple!!
1.5) outline of nodejs 1.5) outline of nodejs
- v8 engine that compile/interprets js - v8 engine that compile/interprets js
- high performance http parser (in C) - high performance http parser (in C)
...@@ -41,6 +43,7 @@ https://www.youtube.com/watch?v=hWhMKalEicY ...@@ -41,6 +43,7 @@ https://www.youtube.com/watch?v=hWhMKalEicY
it will be enqueued, and node will get around to handling that file eventually it will be enqueued, and node will get around to handling that file eventually
- dont do cpu heavy tasks in node - dont do cpu heavy tasks in node
s
4) javascript part, callback-based scheme 4) javascript part, callback-based scheme
- http://vimeo.com/111122950 around 5:30 - http://vimeo.com/111122950 around 5:30
......
pics/who_uses.png

95.2 KiB

var http = require('http'); var http = require('http');
var requestHandler = function (request, response) { function requestHandler(request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'}); response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello CSE 333\n'); response.end('Hello CSE 333\n');
} }
......
## How is node put together?
Three main components:
* Google V8 engine that compiles/optimizes Javascript
* High performance http parser
...@@ -2,11 +2,8 @@ ...@@ -2,11 +2,8 @@
"nodejs.md", "nodejs.md",
"who-is-this-kid.md", "who-is-this-kid.md",
"outline.md", "outline.md",
"what-even-is-node.md", "why-node-is-awesome.md",
"problem-background.md", "why-node-is-awesome-pt-2.md",
"javascript-to-the-rescue.md", "who-uses-node.md",
"javascript-ex1.md", "how-is-node-put-together.md"
"javascript-ex2.md",
"anaymous-callbacks.md",
"event-loop.md"
] ]
\ No newline at end of file
## Outline ## Outline
1. What even *is* node? 1. Why node is awesome
* What even ***is*** javascript?? 2. Nodejs architecture overview
2. Awesome stuff about node 3. V8, c++, and optimizing oh my
3. Disadvantages of node 4. Why javascript? (aka all glory to the event loop)
4. Who uses nodejs in production? 5. Recap + takeaways
5. Live demo D:
* *mandatory participation*
\ No newline at end of file
## Who uses node?
<img src="pics/who_uses.png">
Uber, Yahoo, Microsoft, Ebay, Cloud9 IDE,
Dow Jones, LinkedIn, The New York Times,
PayPal
## Why node is awesome pt 2
* Very simple to set up a server
* It's Just Javascript
* Plenty of composable modules
* Very active development (the New Hotness)
\ No newline at end of file
## Why node is awesome
```javascript
// simple-server.js
var http = require('http');
function requestHandler(request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello CSE 333\n');
}
http.createServer(requestHandler).listen(1337, '127.0.0.1');
```
var http = require('http');
var sys = require('sys');
var spawn = require('child_process').spawn;
// var ls = spawn('ls', ['-lh', '/']);
// ls.stdout.on('data', function(data) {
// console.log(data.toString('ascii'));
// })
http.createServer(function (req, res) {
var ls = spawn('ls', ['-lh', '/']);
ls.stdout.on('data', function(data) {
// console.log(data.toString('ascii'));
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(data.toString('ascii'));
})
}).listen(3555, '127.0.0.1');
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment