diff --git a/pics/github_new.png b/pics/github_new.png new file mode 100644 index 0000000000000000000000000000000000000000..d3c542c57ed22e2d4eb115f911d162ee25a13811 Binary files /dev/null and b/pics/github_new.png differ diff --git a/slides/anaymous-callbacks.md b/slides/anaymous-callbacks.md deleted file mode 100644 index 1b82c3cb137159747c99b3de198e41edfbb192c9..0000000000000000000000000000000000000000 --- a/slides/anaymous-callbacks.md +++ /dev/null @@ -1,15 +0,0 @@ -## Anonymous Callbacks - -Don't need to explicitly name a function, instead just write the function as a parameter: - -```javascript -// Anonymous inlined callback -helloCaller("Bob Bobberson", function(name) { - // Finnish Hello - console.log("Moi " + name); -}); -``` -<pre> -Moi Bob Bobberson</pre> - -You see this **all the *time*** when dealing with nodejs and javascript in general \ No newline at end of file diff --git a/slides/event-loop.md b/slides/event-loop.md index 0c6ef334ea800a9c9a7defa40b8b48e019443a9b..9dc87277ae2503d96092fcfafb4e7ca02d001509 100644 --- a/slides/event-loop.md +++ b/slides/event-loop.md @@ -1,3 +1,5 @@ ## Event Loop -* What if \ No newline at end of file +* Async calls enqueued on event loop +* Node single-thread will dequeue and process +* When there's nothing left to do, node will sleep diff --git a/slides/google-v8.md b/slides/google-v8.md new file mode 100644 index 0000000000000000000000000000000000000000..47a65de4a8f788c2de95840824c73d2fbb37ddc3 --- /dev/null +++ b/slides/google-v8.md @@ -0,0 +1,9 @@ +## Google v8 + +* Google's open source javascript engine +* Used by google chrome +* Compiles javascript to machine code JIT +* + +'''''''''''show how node connects with c++ code? +'''''''''''show assembly? benchmarks? diff --git a/slides/how-is-node-put-together.md b/slides/how-is-node-put-together.md index beb8c3698ab89a5c0a3f34388813832f2f0f79f4..d82501d8b5cfa464df5932e520a0facfb62db909 100644 --- a/slides/how-is-node-put-together.md +++ b/slides/how-is-node-put-together.md @@ -1,5 +1,6 @@ ## How is node put together? -Three main components: -* Google V8 engine that compiles/optimizes Javascript -* High performance http parser +* Google v8 engine that compiles/optimizes Javascript +* High performance parts written in C (http, etc) +* Bridge between high performance parts to v8 (via v8 apis) +* Libuv as an abstraction layer for network and file system diff --git a/slides/javascript-ex1.md b/slides/javascript-ex1.md deleted file mode 100644 index 92f60f605a1cf2400a2dd936fc05cb1f2add327f..0000000000000000000000000000000000000000 --- a/slides/javascript-ex1.md +++ /dev/null @@ -1,15 +0,0 @@ -## Javascript example #1 - -Some simple DOM manipulation - -```javascript -// Grab every div on the page -var divs = document.querySelectorAll("div"); - -// Loop through each element -for (var i = 0; i < divs.length; i++) { - // Change the background image - divs[i].style.backgroundImage = - "url('http://stfn.me/stefchat/stefchatweb.jpg')"; -} -``` \ No newline at end of file diff --git a/slides/javascript-ex2.md b/slides/javascript-ex2.md deleted file mode 100644 index 642433815745a558b597675c6a778dbd5c04a67a..0000000000000000000000000000000000000000 --- a/slides/javascript-ex2.md +++ /dev/null @@ -1,28 +0,0 @@ -## Javascript Example #2 - -First class functions!! - -```javascript -function englishHello(name) { - console.log("Hello " + name); -} - -function swedishHello(name) { - console.log("Hej " + name); -} - -var cse333 = swedishHello; - -function helloCaller(name, helloFunction) { - helloFunction(name); -} - -helloCaller("Brendan Eich", englishHello); -helloCaller("Grace Hopper", swedishHello); -helloCaller("Abraham Lincoln", cse333); -``` - -<pre> -Hello Brendan Eich -Hej Grace Hopper -Hej Abraham Lincoln</pre> diff --git a/slides/javascript-to-the-rescue.md b/slides/javascript-to-the-rescue.md deleted file mode 100644 index 0e78619f38e0bcb4d19920d7ccb2c2de258a484e..0000000000000000000000000000000000000000 --- a/slides/javascript-to-the-rescue.md +++ /dev/null @@ -1,8 +0,0 @@ -## Javascript to the rescue - -* Designed in 10 days by Brendan Eich - * @see <a href="https://www.destroyallsoftware.com/talks/wat">Wat by Gary Bernhardt</a> -* Dynamic typing -* First class functions -* **Event loop** -* **Non-blocking I/O** diff --git a/slides/list.json b/slides/list.json index bc7901e86ddcf8cd8801fb62bf78113f16e7384a..c15eacd7215fe1e94b5a41d20ff5f6a59f2cd038 100644 --- a/slides/list.json +++ b/slides/list.json @@ -2,8 +2,19 @@ "nodejs.md", "who-is-this-kid.md", "outline.md", + "what-is-node.md", + "the-problem.md", + "the-solution.md", "why-node-is-awesome.md", "why-node-is-awesome-pt-2.md", "who-uses-node.md", - "how-is-node-put-together.md" + "how-is-node-put-together.md", + "google-v8.md", + "syscall-overhead.md", + "v8-benchmarks.md", + "pure-c-modules.md", + "outline-pt2.md", + "the-javascript-part.md", + "what-is-a-callback.md", + "event-loop.md" ] \ No newline at end of file diff --git a/slides/outline-pt2.md b/slides/outline-pt2.md new file mode 100644 index 0000000000000000000000000000000000000000..acff660a35c278fc6fcf50c72236c3404599d4e7 --- /dev/null +++ b/slides/outline-pt2.md @@ -0,0 +1,7 @@ +## Outline + +1. What is node/Why node is awesome +2. Nodejs architecture overview +3. V8, c++, and optimizing oh my +4. **Why javascript? (aka all glory to the event loop)** +5. Recap + takeaways diff --git a/slides/outline.md b/slides/outline.md index e5236cca5f967bdac6fd956674a6860cf6f52e27..ec51ecc7aa72213fd524b2df6b370fd858dbeda1 100644 --- a/slides/outline.md +++ b/slides/outline.md @@ -1,6 +1,6 @@ ## Outline -1. Why node is awesome +1. What is node/Why node is awesome 2. Nodejs architecture overview 3. V8, c++, and optimizing oh my 4. Why javascript? (aka all glory to the event loop) diff --git a/slides/pure-c-modules.md b/slides/pure-c-modules.md new file mode 100644 index 0000000000000000000000000000000000000000..e538c5d0fc28a78556d50504191d023b970b8acc --- /dev/null +++ b/slides/pure-c-modules.md @@ -0,0 +1,9 @@ +## Pure C modules + +Most of node's components are written in javascript, +but a few high performance ones are written in pure C +and then connect into v8 via v8 APIs + +* https://github.com/joyent/node/tree/master/deps/http_parser +* networking? +'''''''''''check with xi diff --git a/slides/syscall-overhead.md b/slides/syscall-overhead.md new file mode 100644 index 0000000000000000000000000000000000000000..acfacf2c9e06cd93c745314f95996069957fd334 --- /dev/null +++ b/slides/syscall-overhead.md @@ -0,0 +1,9 @@ +## Syscall overhead + +Hello world in C, node, and Java + +| Language | Syscall Count | +|----------|---------------| +| C | 13 | +| Java | 317 | +| Node | 491 | diff --git a/slides/the-javascript-part.md b/slides/the-javascript-part.md new file mode 100644 index 0000000000000000000000000000000000000000..3a2cb5c029eccc8369135815339da3126cc29e86 --- /dev/null +++ b/slides/the-javascript-part.md @@ -0,0 +1,9 @@ +## The javascript part + +* Javascript is one of the most popular languages in the world + +<img src="pics/github_new.png" style="width: 400px"> + +* Lots of people with knowledge of javascript +* Ergo, lots of people familiar with async + callbacks +* Nodejs uses lots of async + callbacks \ No newline at end of file diff --git a/slides/the-problem.md b/slides/the-problem.md new file mode 100644 index 0000000000000000000000000000000000000000..c7c8aa1f03a972da717a822df203274bb4d437c2 --- /dev/null +++ b/slides/the-problem.md @@ -0,0 +1,14 @@ +## The Problem + +* Servers have to handle lots of requests +* majority of I/O is disk bound + +``` +var result = database.query("kittens"); +// twaddle fingers +send(result); +``` + +Apache makes a new thread per request, +<br> +but uses hella memory \ No newline at end of file diff --git a/slides/the-solution.md b/slides/the-solution.md new file mode 100644 index 0000000000000000000000000000000000000000..ae754ff78f04a9eedd8e20d5ba67696892e823aa --- /dev/null +++ b/slides/the-solution.md @@ -0,0 +1,12 @@ +## The Solution + +Nodejs uses callbacks to defer dealing with I/O until it's ready + +``` +database.query("kittens", function (data) { + // database is done and has the data ready + send(data); +}); + +// do other servery things +``` diff --git a/slides/v8-benchmarks.md b/slides/v8-benchmarks.md new file mode 100644 index 0000000000000000000000000000000000000000..6bb1ddac61912567acae8d09cf1b7e87b048572a --- /dev/null +++ b/slides/v8-benchmarks.md @@ -0,0 +1,3 @@ +## v8 benchmarks + +'''''''''''''grab some benchmarks online diff --git a/slides/what-even-is-node.md b/slides/what-even-is-node.md deleted file mode 100644 index 64c41be6acebfd4776b69eaf3ddf35a841ddb834..0000000000000000000000000000000000000000 --- a/slides/what-even-is-node.md +++ /dev/null @@ -1 +0,0 @@ -## What even *is* node? diff --git a/slides/what-is-a-callback.md b/slides/what-is-a-callback.md new file mode 100644 index 0000000000000000000000000000000000000000..e00d09e58e62bda9ce0d0567d7a8a670aae02dfa --- /dev/null +++ b/slides/what-is-a-callback.md @@ -0,0 +1,19 @@ +## what is a callback + +Callbacks are functions that are passed as parameters to other functions, +and then called within those functions + +LinkedList implementation requires a function pointer to free a payload, +same idea + +``` +function helloCaller(helloFn, name) { + helloFn(name); +} + +function hello(name) { console.log("hello " + name); } +function swedishHello(name) { console.log("hej " + name); } + +helloCaller(hello, "CSE 333"); +helloCaller(swedishHello, "CSE 333"); +``` \ No newline at end of file diff --git a/slides/what-is-node.md b/slides/what-is-node.md new file mode 100644 index 0000000000000000000000000000000000000000..1348738f12bce8aaa3f79c10962d2f87473cc249 --- /dev/null +++ b/slides/what-is-node.md @@ -0,0 +1,6 @@ +## What is node + +* Asynchronous, event driven server framework +* Non-blocking I/O +* For frontend js noobs and "unix haxors" +* Single threaded! \ No newline at end of file diff --git a/slides/who-uses-node.md b/slides/who-uses-node.md index 89c4f45795bf7b76b68a71fa9caf2f6aae27e769..e5328ea29c0105b1a000ac914b595d38c0e969ca 100644 --- a/slides/who-uses-node.md +++ b/slides/who-uses-node.md @@ -4,4 +4,4 @@ Uber, Yahoo, Microsoft, Ebay, Cloud9 IDE, Dow Jones, LinkedIn, The New York Times, -PayPal +PayPal, Mal-Wart diff --git a/slides/why-node-is-awesome.md b/slides/why-node-is-awesome.md index 0e86d80f0c00f990a6fc42356d5cbad3f540d5cc..b310ecd6f6b1e13c488f58aa25405f81ac13553b 100644 --- a/slides/why-node-is-awesome.md +++ b/slides/why-node-is-awesome.md @@ -1,7 +1,6 @@ ## Why node is awesome ```javascript -// simple-server.js var http = require('http'); function requestHandler(request, response) {