-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchapter1.html
538 lines (431 loc) · 22.8 KB
/
chapter1.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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Learning React - Welcome</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, minimal-ui">
<link rel="icon" type="image/x-icon" href="mc2/images/favicon.ico">
<link rel="stylesheet" href="mc2/styles/reveal.css">
<link rel="stylesheet" href="mc2/styles/theme.css" id="theme">
<link rel="stylesheet" href="mc2/styles/code.css">
<link rel="stylesheet" href="styles/react.css">
</head>
<body>
<div id="pos"></div>
<div class="reveal">
<div class="slides">
<section class="slide chaptertitle">
<div class="slidecontent">
<div class="chapternumber"> chapter 1 of 14 </div>
<h1>Welcome</h1>
<span>to the jungle</span>
</div>
</section>
<section class="slide sectionlist">
<div class="slidecontent">
<h3>Sections in this chapter</h3>
<ol>
<li><a href="#/2">Course structure</a></li>
<li><a href="#/3">The Web platform</a></li>
<li><a href="#/4">Approaching the web</a></li>
<li><a href="#/5">The JavaScript language</a></li>
<li><a href="#/6">Course resources</a></li>
</ol>
</div>
</section>
<section>
<section class="slide sectiontitle">
<div class="slidecontent">
<div class='sectioncount'>Section 1/5</div>
<h3>Course structure</h3>
<p>How we'll go about things</p>
</div>
</section>
<section class="slide" data-pos="1-1-1">
<span class="pos">1-1-1</span>
<div class="slidecontent"><p>The course is divided into several <strong>chapters</strong>, where you're currently in the first.</p>
<p><img src="resources/1-1-1-87.svg" alt="dot"></p>
<p>We access the chapters from an <strong>index</strong>, giving you a <strong>birds-eye view</strong> of the entire contents.</p>
</div></section>
<section class="slide" data-pos="1-1-2">
<span class="pos">1-1-2</span>
<div class="slidecontent"><p>Each <strong>chapter</strong> has many <strong>sections</strong>:</p>
<p><img src="resources/1-1-2-41.svg" alt="dot"></p>
</div></section>
<section class="slide" data-pos="1-1-3">
<span class="pos">1-1-3</span>
<div class="slidecontent"><p>In the <strong>printed material</strong> (or PDF) and in the <strong>presentation top-right corner</strong>, the slides are numbered <strong><code>X‑Y‑Z</code></strong> where...</p>
<ul>
<li><code>X</code> is the number of the current <strong>chapter</strong></li>
<li><code>Y</code> is the number of the section <strong>section</strong> within that chapter</li>
<li><code>Z</code> is the number of the <strong>slide</strong> within that section</li>
</ul>
</div></section>
<section class="slide" data-pos="1-1-4">
<span class="pos">1-1-4</span>
<div class="slidecontent"><p>Some sections are <strong>exercises</strong>, where you'll get to internalise what we've been talking about through a
<strong>practical task</strong>.</p>
<p>These are all <strong>tied together</strong> in that it is one single app that you will keep tinkering with.</p>
</div></section>
<section class="slide" data-pos="1-1-5">
<span class="pos">1-1-5</span>
<div class="slidecontent"><p>The latest bunch of chapters are <strong>Appendixes</strong>, meant to be used as references as needed.</p>
<p>For example, if you're not comfortable with <strong>new language features</strong> you can check out the <strong>ES6 appendix</strong>!</p>
</div></section>
<section class="slide" data-pos="1-1-6">
<span class="pos">1-1-6</span>
<div class="slidecontent"><p>Finally - it is <strong>forbidden to keep a question to yourself</strong>. Ask away!</p>
<p>Because, <strong>there are no stupid questions</strong>! <span style='text-decoration: line-through;'>Only stupid people.</span></p>
</div></section>
</section>
<section>
<section class="slide sectiontitle">
<div class="slidecontent">
<div class='sectioncount'>Section 2/5</div>
<h3>The Web platform</h3>
<p>a.k.a. the holy trinity</p>
</div>
</section>
<section class="slide" data-pos="1-2-1">
<span class="pos">1-2-1</span>
<div class="slidecontent"><p>The <strong>Web platform</strong> is really the combination of three separate technologies:</p>
<p><img src="resources/1-2-1-80.svg" alt="dot"></p>
</div></section>
<section class="slide" data-pos="1-2-2">
<span class="pos">1-2-2</span>
<div class="slidecontent"><p>(There was also a dark time when <strong>Java applets</strong> were used in webpages, but we don't talk about that...)</p>
<p><img src="resources/1-2-2-107.svg" alt="dot"></p>
</div></section>
<section class="slide" data-pos="1-2-3">
<span class="pos">1-2-3</span>
<div class="slidecontent"><p>(And we don't acknowledge the existence of <strong>flash</strong> either)</p>
<p><img src="resources/1-2-3-62.svg" alt="dot"></p>
</div></section>
<section class="slide" data-pos="1-2-4">
<span class="pos">1-2-4</span>
<div class="slidecontent"><p>Traditionally, <strong>web apps looked like this</strong>:</p>
<p><img src="resources/1-2-4-47.svg" alt="dot"></p>
<p>Web tech was <strong>just the UI</strong>. The real coding was done in <code>php</code> / <code>ruby</code> / <code>java</code> / <code>.NET</code>.</p>
</div></section>
<section class="slide" data-pos="1-2-5">
<span class="pos">1-2-5</span>
<div class="slidecontent"><p>But a <strong>modern SPA</strong> (Single Page Application) is more like this:</p>
<p><img src="resources/1-2-5-67.svg" alt="dot"></p>
</div></section>
<section class="slide" data-pos="1-2-6">
<span class="pos">1-2-6</span>
<div class="slidecontent"><p>Additionally, web tech has <strong>escaped from the browser</strong>:</p>
<p><img src="resources/1-2-6-58.svg" alt="dot"></p>
</div></section>
<section class="slide" data-pos="1-2-7">
<span class="pos">1-2-7</span>
<div class="slidecontent"><p>And blurring the lines even further - there are frameworks to <strong>compile web to native code</strong>:</p>
<p><img src="resources/1-2-7-95.svg" alt="dot"></p>
</div></section>
<section class="slide" data-pos="1-2-8">
<span class="pos">1-2-8</span>
<div class="slidecontent"><p>In essence: <strong>web tech is on the (high) rise</strong>, and even if you intend to stay in a sheltered Java garden, knowledge about the web platform will serve you well.</p>
</div></section>
</section>
<section>
<section class="slide sectiontitle">
<div class="slidecontent">
<div class='sectioncount'>Section 3/5</div>
<h3>Approaching the web</h3>
<p>this and this and this and</p>
</div>
</section>
<section class="slide" data-pos="1-3-1">
<span class="pos">1-3-1</span>
<div class="slidecontent"><p>We must admit something up front regarding <strong>learning the web platform</strong>.</p>
</div></section>
<section class="slide" data-pos="1-3-2">
<span class="pos">1-3-2</span>
<div class="slidecontent"><p>It is often <strong>overwhelming to newcomers</strong> that there is an <strong>abundance of choices</strong> to make, for many different aspects;</p>
<ul>
<li>what <strong>framework</strong> to use</li>
<li>what <strong>build chain</strong> to use</li>
<li>which <strong>JS language flavour</strong> to use</li>
<li>what <strong>CSS preprocessor</strong> to use</li>
<li>what <strong>style rules</strong> to enforce</li>
<li><strong>how to enforce</strong> those rules</li>
</ul>
<p>...and many more.</p>
</div></section>
<section class="slide" data-pos="1-3-3">
<span class="pos">1-3-3</span>
<div class="slidecontent"><p>And for <strong>each of those choices</strong>, you must consider;</p>
<p><img src="resources/1-3-3-55.svg" alt="dot"></p>
</div></section>
<section class="slide" data-pos="1-3-4">
<span class="pos">1-3-4</span>
<div class="slidecontent"><p>...and <strong>also</strong>:</p>
<p><img src="resources/1-3-4-18.svg" alt="dot"></p>
<p>...and likely a few more that we've forgotten.</p>
</div></section>
<section class="slide" data-pos="1-3-5">
<span class="pos">1-3-5</span>
<div class="slidecontent"><p>Regarding the <strong>choice of framework</strong>, the <strong>most important aspect</strong> is perhaps that of <strong>complexity</strong>:</p>
<p><img src="resources/1-3-5-105.svg" alt="dot"></p>
</div></section>
<section class="slide" data-pos="1-3-6">
<span class="pos">1-3-6</span>
<div class="slidecontent"><p>Observe that there is <strong>no right or wrong</strong> in the complexity choice.</p>
<p>The important thing is to <strong>be aware of where on the scale you are</strong>, and <strong>understand the consequences of that</strong>.</p>
</div></section>
<section class="slide" data-pos="1-3-7">
<span class="pos">1-3-7</span>
<div class="slidecontent"><p>To ease into adopting the web, here are some humble pointers!</p>
</div></section>
<section class="slide" data-pos="1-3-8">
<span class="pos">1-3-8</span>
<div class="slidecontent"><blockquote>
<p>Don't worry about <strong>having the latest</strong>. That'll be old next week anyway.</p>
</blockquote>
</div></section>
<section class="slide" data-pos="1-3-9">
<span class="pos">1-3-9</span>
<div class="slidecontent"><blockquote>
<p><strong>Respect the role of the architect</strong>. He/she needs to make informed decisions, the rest of us can just relax and use the tools!</p>
</blockquote>
</div></section>
<section class="slide" data-pos="1-3-10">
<span class="pos">1-3-10</span>
<div class="slidecontent"><blockquote>
<p>If you find a setup that works, <strong>go with it</strong>. You won't find the ideal setup to begin with anyway.</p>
</blockquote>
</div></section>
<section class="slide" data-pos="1-3-11">
<span class="pos">1-3-11</span>
<div class="slidecontent"><blockquote>
<p>Don't let your pride prevent you from <strong>using starter kits</strong>. For example, in the world of React, <a href="https://github.com/facebookincubator/create-react-app">create-react-app</a> is an excellent low-cost entryway!</p>
</blockquote>
</div></section>
</section>
<section>
<section class="slide sectiontitle">
<div class="slidecontent">
<div class='sectioncount'>Section 4/5</div>
<h3>The JavaScript language</h3>
<p>lingua franca of the web</p>
</div>
</section>
<section class="slide" data-pos="1-4-1">
<span class="pos">1-4-1</span>
<div class="slidecontent"><p>So - <strong>JavaScript</strong>! Let's kick things off with a <strong>chopper view of the language</strong>.</p>
</div></section>
<section class="slide" data-pos="1-4-2">
<span class="pos">1-4-2</span>
<div class="slidecontent"><p>First, here is an overview of the <strong>different JavaScript versions</strong>:</p>
<p><img src="resources/1-4-2-70.svg" alt="dot"></p>
<p>We will <strong>mostly use ES5</strong>, with some more modern stuff sprinkled in.</p>
</div></section>
<section class="slide" data-pos="1-4-3">
<span class="pos">1-4-3</span>
<div class="slidecontent"><p>...as well as some <strong>more stuff beyond the borders of JavaScript</strong>, but <strong>that comes later too</strong>!</p>
</div></section>
<section class="slide question" data-pos="1-4-4">
<span class="pos">1-4-4</span>
<div class="slidecontent">
<p>So, just <strong>how small is ES7</strong>? Err, I mean, ES2016.</p>
</div></section>
<section class="slide answer" data-pos="1-4-5">
<span class="pos">1-4-5</span>
<div class="slidecontent">
<p>Well, if you go to <a href="https://getgood.at/js/es7-in-7-days">https://getgood.at/js/es7-in-7-days</a>...</p>
<p><img src="resources/images/es7in7days.png" alt=""></p>
</div></section>
<section class="slide" data-pos="1-4-6">
<span class="pos">1-4-6</span>
<div class="slidecontent"><p>...then you have <strong>3.5 days to learn this</strong>:</p>
<pre><code class="lang-javascript">myArr.includes(<span class="hljs-string">'foo'</span>) <span class="hljs-comment">// returns true or false</span>
</code></pre>
<p>...and <strong>3.5 days to learn this</strong>:</p>
<pre><code class="lang-javascript"><span class="hljs-number">5</span> ** <span class="hljs-number">3</span> <span class="hljs-comment">// 125, same as Math.pow(5, 3)</span>
</code></pre>
</div></section>
<section class="slide" data-pos="1-4-7">
<span class="pos">1-4-7</span>
<div class="slidecontent"><p>And ES2017 isn't much bigger; it has 6 features.</p>
<p>What is going on?!</p>
</div></section>
<section class="slide" data-pos="1-4-8">
<span class="pos">1-4-8</span>
<div class="slidecontent"><p>After ES6 (ES2015), TC39 switched to a <strong>yearly release cycle</strong> where <strong>features compete individually</strong>.</p>
<p><img src="resources/images/gauntlet.jpg" alt=""></p>
</div></section>
<section class="slide" data-pos="1-4-9">
<span class="pos">1-4-9</span>
<div class="slidecontent"><p>The <strong>TC39 process</strong>:</p>
<p><img src="resources/1-4-9-23.svg" alt="dot"></p>
<p>Formal description <a href="https://tc39.github.io/process-document/">here</a></p>
</div></section>
<section class="slide" data-pos="1-4-10">
<span class="pos">1-4-10</span>
<div class="slidecontent"><p>So <strong>what's in the pipeline</strong>?</p>
<ul>
<li><a href="https://github.com/tc39/proposals/blob/master/stage-0-proposals.md">Stage 0 list</a> (23)</li>
<li><a href="https://github.com/tc39/proposals">Stage 1-3</a> (41, 8, 14)</li>
<li><a href="https://github.com/tc39/proposals/blob/master/finished-proposals.md">Stage 4</a> (8, not counting ES2016 and ES2017)</li>
</ul>
<p>(counts valid as of April 2018)</p>
</div></section>
<section class="slide" data-pos="1-4-11">
<span class="pos">1-4-11</span>
<div class="slidecontent"><p>Curious what a <strong>finished feature spec</strong> looks like?</p>
<p>Let's check out the spec for Exponentiation](<a href="http://rwaldron.github.io/exponentiation-operator/">http://rwaldron.github.io/exponentiation-operator/</a>)</p>
</div></section>
<section class="slide" data-pos="1-4-12">
<span class="pos">1-4-12</span>
<div class="slidecontent"><p>A <strong>recommended learning resource</strong> for new and upcoming syntaxes are these books by Alex Rauschmayer:</p>
<ul>
<li><a href="https://leanpub.com/exploring-es6">Exploring ES6</a></li>
<li><a href="https://leanpub.com/exploring-es2016-es2017">Exploring ES2016 and ES2017</a></li>
</ul>
<p>Both are <strong>free online</strong>.</p>
</div></section>
<section class="slide list" data-pos="1-4-13">
<span class="pos">1-4-13</span>
<div class="slidecontent">
<p>Since we <strong>can't trust all browsers to know the latest JS</strong>, we must <strong>convert our code</strong>. We do this either by...</p>
<ul>
<li><span>a</span><strong>polyfilling</strong></li>
<li><span>b</span><strong>transpiling</strong></li>
</ul>
</div></section>
<section class="slide num numA" data-pos="1-4-14">
<span class="pos">1-4-14</span>
<div class="slidecontent">
<p><strong>Polyfilling</strong> means <strong>adding a homebrew version</strong> of a method if a native one isn't available. This <strong>can be done programmatically</strong>, like this:</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">Array</span>.isArray = <span class="hljs-built_in">Array</span>.isArray || <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">a</span>)</span>{
<span class="hljs-keyword">return</span> <span class="hljs-string">''</span> + a !== a && {}.toString.call(a) == <span class="hljs-string">'[object Array]'</span>;
});
</code></pre>
</div></section>
<section class="slide num numB" data-pos="1-4-15">
<span class="pos">1-4-15</span>
<div class="slidecontent">
<p>But <strong>syntax changes</strong> requires a <strong>transpilation step</strong> that must be done <strong>prior to running the code</strong>. We <strong>cannot do this programmatically</strong>.</p>
</div></section>
<section class="slide" data-pos="1-4-16">
<span class="pos">1-4-16</span>
<div class="slidecontent"><p>Speaking of JavaScript's character - are you familiar with the <strong>3 levels of programming</strong>?</p>
<p><img src="resources/1-4-16-93.svg" alt="dot"></p>
</div></section>
<section class="slide question" data-pos="1-4-17">
<span class="pos">1-4-17</span>
<div class="slidecontent">
<p>They were interesting, but <strong>what do they have to do with JavaScript</strong>?</p>
</div></section>
<section class="slide answer" data-pos="1-4-18">
<span class="pos">1-4-18</span>
<div class="slidecontent">
<p>JavaScript's flexible nature <strong>encourages and empowers level 2 behavior</strong>.</p>
<p>So <strong>take care</strong>, and remember:</p>
<blockquote>
<p>With great power comes great responsibility</p>
</blockquote>
</div></section>
<section class="slide" data-pos="1-4-19">
<span class="pos">1-4-19</span>
<div class="slidecontent"><p>Wielding of that power requires you to <strong>have a grasp JS's quirks</strong>, of which there are many. </p>
<p>These ones are <strong>especially important</strong>:</p>
<ul>
<li><strong>Loose typing</strong> and <strong>truthiness</strong></li>
<li>The <strong>implicit <code>this</code> parameter</strong></li>
<li><strong>Lexical scoping</strong></li>
<li><strong>closures</strong></li>
</ul>
</div></section>
<section class="slide" data-pos="1-4-20">
<span class="pos">1-4-20</span>
<div class="slidecontent"><p>Here are three <strong>succinct primers</strong> for getting up to speed quickly:</p>
<ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript">MDN:s reintroduction to JS</a></li>
<li><a href="http://es6-features.org/">Interactive ES6 features overview</a></li>
<li><a href="http://bonsaiden.github.io/JavaScript-Garden/">JavaScript Garden</a></li>
</ul>
<p>For more <strong>general JS references</strong> we recommend <a href="https://developer.mozilla.org/en-US/">MDN</a> (and <strong>not W3Schools</strong>).</p>
</div></section>
</section>
<section>
<section class="slide sectiontitle">
<div class="slidecontent">
<div class='sectioncount'>Section 5/5</div>
<h3>Course resources</h3>
<p>Goodie bag time!</p>
</div>
</section>
<section class="slide" data-pos="1-5-1">
<span class="pos">1-5-1</span>
<div class="slidecontent"><p>You will be provided with a link to a <strong>course resource</strong> bundle, containing:</p>
<ul>
<li>A set of <strong>Demos</strong> - we'll show them off during the course, but this way you can peruse them at your leisure later on</li>
<li><strong>Exercises</strong>, which you'll be tasked with accomplishing at set points during the course</li>
<li>A <strong>PDF</strong> of this very presentation</li>
</ul>
</div></section>
</section>
</div>
</div>
<script type="text/javascript">
var basehref = window.location.href.replace(/chapter\d.*?$/,'')
document.addEventListener("keydown", function(e) {
var code = e.which || e.keyCode;
if (code === 13) {
window.location.href = basehref+"index.html?from=0";
} else if (code >= 49 && code <= 5 + 48) {
window.location.hash = "#/" + (code-48+1+0);
}
if (1 < 14) {
if (code === 99 || e.key === 'c') { // the letter C for next Chapter
window.location.href = basehref+"chapter2.html"
}
}
});
</script>
<script src="mc2/scripts/head.js" type="text/javascript"></script>
<script src="mc2/scripts/reveal.js" type="text/javascript"></script>
<script src="mc2/scripts/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
showNotes: false,
transition: 'slide',
dependencies: [
{ src: 'mc2/scripts/plugin/notes/notes.js', async: true }
]
});
window.onload = function() {
var links = document.querySelectorAll("a.link");
for(var i = 0; i < links.length; i++){
var link = links[i];
link.innerHTML = link.innerHTML.replace(/ /g,' ')
}
var posElem = document.getElementById('pos')
function updateReference() {
setTimeout(function() {
var currentpos = document.querySelector('section.present[data-pos]')
if (currentpos) {
posElem.innerHTML = currentpos.getAttribute('data-pos')
} else {
posElem.innerHTML = ''
}
if (document.querySelector('.present.chaptertitle')) {
document.body.classList.add('atchaptertitle');
} else {
document.body.classList.remove('atchaptertitle');
}
}, 10);
}
window.addEventListener("hashchange",updateReference);
updateReference();
};
</script>
</body>
</html>