-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
executable file
·309 lines (269 loc) · 10.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript VM internals, EventLoop, Async and ScopeChains</title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/default.css" id="theme">
<link rel="stylesheet" href="css/style.css">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/tomorrow-night.css">
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h2>JavaScript VM internals</h2>
<h3>EventLoop, Async and ScopeChains</h3>
<p>
<small>by Arindam Paul / <a href="#">@geek_paul</a></small>
<br>
<small>Amazon Campus</small>
<br>
<small>© Amazon 2015</small>
</p>
</section>
<section data-background="#34495e" data-background-transition="slide">
<img src="./images/sicp.png" width="150%" alt="SICP"><blockquote>
“When you don’t know what you believe, everything becomes an argument. Everything is debatable. But when you stand for something, decisions are obvious.”
― Jason Fried, Rework
</blockquote>
</section>
<section class="slide">
<h2>Agenda</h2>
<table border="0">
<tr>
<td style="vertical-align: top;">
<ul>
<li class="slide">JavaScript Interpretation and Memory Model</li>
<li class="slide">Compilation and Variable Hoisting</li>
<li class="slide">Function Execution</li>
<li class="slide">Scope Chains and Closure</li>
<li class="slide">JavaScript Runtime and Event loop</li>
<li class="slide">Async Examples</li>
<li class="slide">Single Threaded parallel execution</li>
</ul>
</td>
<td style="vertical-align: top;">
<img src="./images/gifs/way_to_project.gif" alt="">
</td>
</tr>
</table>
</section>
<section data-transition="linear" data-background="#4d7e65" data-background-transition="slide">
<h2>Memory Allocation and Garbage Collection</h2>
<h4>Let's pretend to be the Runtime and execute the code</h4>
</section>
<section>
<img src="images/img/closure_step1.png" alt="">
</section>
<section>
<img src="images/img/closure_step2.png" alt="">
</section>
<section>
<img src="images/img/closure_step3.png" alt="">
</section>
<section>
<img src="images/img/closure_step4.png" alt="">
</section>
<section>
<img src="images/img/closure_step5.png" alt="">
</section>
<section>
<img src="images/img/closure_step6.png" alt="">
</section>
<section>
<img src="images/img/closure_step7.png" alt="">
</section>
<section>
<img src="images/img/closure_step8.png" alt="">
</section>
<section>
<img src="images/img/closure_step9.png" alt="">
</section>
<section>
<img src="images/img/closure_step10.png" alt="">
</section>
<section>
<img src="images/img/closure_step11.png" alt="">
</section>
<section>
<img src="images/img/closure_step12.png" alt="">
</section>
<section>
<img src="images/img/closure_step12_5.png" alt="">
</section>
<section>
<img src="images/img/closure_step13.png" alt="">
</section>
<section>
<img src="images/img/closure_step14.png" alt="">
</section>
<section>
<img src="images/img/closure_step15.png" alt="">
</section>
<section>
<img src="images/img/closure_step16.png" alt="">
</section>
<section>
<img src="images/img/closure_step17.png" alt="">
</section>
<section>
<img src="images/img/closure_step18.png" alt="">
</section>
<section>
<img src="images/img/closure_step19.png" alt="">
</section>
<section>
<img src="images/img/closure_step20.png" alt="">
</section>
<section>
<img src="images/img/closure_step21.png" alt="">
</section>
<section>
<img src="images/img/closure_step22.png" alt="">
</section>
<section>
<img src="images/img/closure_step23.png" alt="">
</section>
<section>
<img src="images/img/closure_step24.png" alt="">
</section>
<section>
<img src="images/img/closure_step25.png" alt="">
</section>
<section>
<img src="images/img/closure_step26.png" alt="">
</section>
<section>
<img src="images/img/closure_step28.png" alt="">
</section>
<section>
<img src="images/img/closure_step29.png" alt="">
</section>
<section>
<img src="images/img/closure_step30.png" alt="">
</section>
<section>
<img src="images/img/closure_step30.png" alt="">
</section>
<section>
<img src="images/img/closure_step31.png" alt="">
</section>
<section>
<img src="images/img/closure_step32.png" alt="">
</section>
<section>
<img src="images/img/closure_step33.png" alt="">
</section>
<section>
<img src="images/img/closure_step34.png" alt="">
</section>
<section data-transition="linear" data-background="#4d7e65" data-background-transition="slide">
<h2>Closures</h2>
<p>What happens when a function is executed outside of it's original scope chains? </p><p>Moreover, what happens when a variable holds on to a function reference which get's defined in such deep function execution chain.</p>
</section>
<section>
<h3>So What is Closure?</h3>
<p>It is an implicit, permanent link between a function and it's scope chain..</p>
<p>A function definition's (lambda) hidden [[scope]] reference.</p>
<ul>
<li>Holds the scope chain (preventing garbage collection.)</li>
<li>It is used and copied as the "outer environment reference" anytime the function is run.</li>
</ul>
</section>
<section>
<h2>Implicit Closure</h2>
<pre><code data-trim contenteditable class="javascript">
var data = "My Data!";
setTimeout(function() {
console.log(data); // prints "My Data!"
}, 3000);
</code></pre>
</section>
<section>
<h2>Explicit Closures</h2>
<pre><code data-trim contenteditable class="javascript">
function makeAdder(n) {
var inc = n;
var sum = 0;
return function add() {
sum = sum + inc;
return sum;
};
}
var adder3 = makeAdder(3);
</code></pre>
</section>
<section data-transition="linear" data-background="#4d7e65" data-background-transition="slide">
<h2>Closure Demo</h2>
</section>
<section data-transition="linear" data-background="#34495e" data-background-transition="slide">
<h2>Event Loop and Async Programming</h2>
<p>Enough Slides, let's go directly to the demo and see it in Action.</p>
</section>
<section>
<h2>And the moment when it all worked...</h2>
<img src="./images/gifs/code_worked.gif" width="500px" alt="Question">
</section>
<section data-transition="linear" data-background="#34495e" data-background-transition="slide">
<h2>Questions?</h2>
<img src="./images/img/brucelee.jpg">
<blockquote>
"When there is freedom from mechanical conditioning, there is simplicity. The classical man is just a bundle of routine, ideas and tradition. If you follow the classical pattern, you are understanding the routine, the tradition, the shadow - you are not understanding yourself." - Bruce Lee
</blockquote>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
multiplex: {
// Example values. Generate your own.
secret: null, // Obtained from the socket.io server. Gives this (the master) control of the presentation
id: '357f5472a5a9e04d', // Obtained from socket.io server
url: '172.27.244.192:1948' // Location of socket.io server
},
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } },
//{ src: 'plugin/wave/webcam-swiper-0.1.js'},
//{ src: 'plugin/wave/client.js'},
// { src: 'plugin/leap/leap.js', async: true }
// { src: 'plugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } }
// { src: 'plugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }
//{ src: 'socket.io/socket.io.js', async: true },
//{ src: 'plugin/notes-server/client.js', async: true },
// other deps
{ src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.10/socket.io.min.js', async: true },
{ src: 'plugin/multiplex/master.js', async: true }
]
});
</script>
</body>
</html>