-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
413 lines (401 loc) · 21.9 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
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Statically Typed JavaScript</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/simple.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<link rel="stylesheet" href="css/style.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section id="main">
<h2 class="title">Statically Typed JavaScript</h2>
<p><em>TypeScript and Flow</em></p>
</section>
<section id="speaker-and-company-info">
<section id="speaker-info" data-background="./img/telerik-bg.jpg">
<div class="speaker-img-container">
<img src="./img/speaker.jpg" width="200" />
</div>
<table class="speaker-contact-info">
<tbody>
<tr>
<td><img class="no-border" src="./img/email.png" width="50"></td>
<td style="vertical-align:middle"> <a href="mailto:denis@newventuresoftware.com?Subject=Hello" target="_blank">denis@newventuresoftware.com</a></td>
</tr>
<tr>
<td><img class="no-border" src="./img/github.png" width="50"></td>
<td style="vertical-align:middle"> <a href="https://github.com/deniskyashif" target="_blank">github.com/deniskyashif</a></td>
</tr>
<tr>
<td><img class="no-border" src="./img/twitter.png" width="50"></td>
<td style="vertical-align:middle"><a href="https://twitter.com/deniskyashif" target="_blank">@deniskyashif</a></td>
</tr>
</tbody>
</table>
</section>
<section id="certifications">
<div>
<img width="300" class="no-border" src="./img/medallion_sitefitiny-certified---300-dpi.png" />
<img width="350" class="no-border" src="./img/KendoUI_Badge_Square_Certified_Big.png" />
</div>
</section>
<section data-background="./img/nvs-intro.PNG"></section>
<section id="nvs-partners" data-background="./img/nvs-partners.PNG"></section>
</section>
<section data-background-color="#000">
<p><em><strong>Say NO to the slow and painful</em></strong></p>
<img alt="" src="./img/death-by-ppt.jpg" width="500" class="no-border" />
</section>
<!-- <section id="icebreaker">
<section>
<img src="./img/stage-fright.jpg" class="no-border" />
</section>
<section>
<h4>Breaking the Ice</h4>
<img src="./img/breaking-the-ice.jpg" width="525" />
</section>
<section>
<p>...</p>
</section>
</section> -->
<section id="agenda" class="color-white" data-background-image="./img/school-board.jpg">
<h3>Agenda</h3>
<ul>
<li class="fragment">Type Systems</li>
<li class="fragment">TypeScript</li>
<li class="fragment">Flow</li>
<li class="fragment">Q&A</li>
</ul>
</section>
<!-- Type Systems -->
<section>
<section>
<p><em>What is a Type System?</em></p>
</section>
<section data-background="#fff">
<img alt="" src="./img/hindley-milner.png" class="no-border" />
</section>
<section>
<h4 class="text-right">What is a Type System?</h4>
<p><strong>Set of rules</strong> that assigns a property called type to the various constructs of a computer program, such as variables, expressions, functions or modules.</p>
</section>
<section>
<h3>Nominal vs Structural</h3>
<div class="fragment" style="font-size: 0.8em">
<p><strong>Nominal</strong>: compatibility and equivalence of data types is determined by explicit declarations and/or the name of the types.</p>
<p><strong>Structural</strong>: type compatibility and equivalence are determined by the type's actual structure or definition.</p>
</div>
</section>
<section>
<h3>Static vs Dynamic</h3>
<div class="fragment" style="font-size: 0.8em">
<p><strong>Static type checking</strong> is the process of verifying the type safety of a program based on analysis of a program's text (source code).</p>
<p><strong>Dynamic type checking</strong> is the process of verifying the type safety of a program at runtime.</p>
</div>
</section>
<section>
<img alt="" src="./img/type-checking.jpg" class="no-border" width="650" />
</section>
<section data-background="#000">
<img src="./img/corleone-runtime.jpg" width="400" />
</section>
</section>
<!-- TypeScript -->
<section>
<section id="typescript" data-background="./img/type-script-bg.jpeg" data-background-transition="zoom"></section>
<section id="ts-overview" data-background-color="#007ACC">
<h4 class="text-right">What is TypeScript?</h4>
<ul>
<li>Language created by <code>Microsoft</code>.</li>
<li>Has optional <code>static typing</code>.</li>
<li><strong>Compiles to JavaScript</strong>.</li>
<li>Inherits concepts from <code>C#</code>.</li>
<li>Provides language service API.</li>
</ul>
</section>
<section id="ts-quote">
<p><em>It's always better to catch errors at compile time rather that at runtime.</em></p>
</section>
<section id="ts-benefits" data-background-color="#007ACC">
<h4 class="text-right">Benefits of TypeScript</h4>
<ul>
<li>Due to <code>static typing</code>, it's more <strong>predictable</strong>.</li>
<li>Due to <code>modules, namespaces and stronger OOP</code>, it <strong>scales better</strong> for larger apps.</li>
<li>Due to <code>compilation step</code>, some errors are caught <strong>compile-time</strong>, not run-time.</li>
</ul>
</section>
<section id="ts-venn">
<img src="./img/typescript-venn.png" class="no-border" width="300" />
</section>
<section id="ts-install">
<h4 class="text-right">Installing TypeScript</h4>
<div style="height: 50px"></div>
<p>Using the Node Package Manager.</p>
<pre><code class="bash">npm install --global typescript</code></pre>
<div style="height: 50px"></div>
</section>
<section id="ts-compile">
<h4 class="text-right">Compiling TypeScript</h4>
<p>TypeScript is written in <strong>.ts</strong> files, which can't be used directly in the browser.<br/>It need to be compiled to vanilla .js first.</p>
<pre><code class="bash">tsc main.ts</code></pre>
</section>
<section id="ts-config">
<h4 class="text-right">tsconfig.json</h4>
<p>Specifies the way TS is compiled.<br/>(autogeneratable with tsc --init)</p>
<pre><code class="json">{
"compilerOptions": {
"target": "es5", // Sets the output JS's version
"module": "commonjs", // Sets the module loader
"outDir": "dist", // Sets output JS files' location
"sourceMap": true, // Allows debugging
"noEmitOnError": true // Do not compile if errors
}
}</code></pre>
</section>
<section id="ts-summary" data-background="./img/ts.png" class="color-white">
<h3>Language Features</h3>
</section>
<section data-background-color="#007ACC">
<h3>Static Type System</h3>
<p><em>“Strongly typed languages reduce bugs by 15%.”</em></p>
</section>
<section id="basic-types">
<h3>Basic Types</h3>
<p>predefined in the language:</p>
<p><code>number, string, boolean, Array, enum, undefined, null, tuples, any, void, never</code></p>
</section>
<section id="ts-say-hello" data-background="#000">
<h3>Live Demo</h3>
<a href="https://www.typescriptlang.org/play/" target="_blank">
<img alt="" src="./img/montanta-type-checker.jpg" width="400" class="no-border" />
</a>
</section>
<section id="complex-types">
<h3>Complex Types</h3>
<p>created by the developer</p>
</section>
<section data-background-color="#007ACC">
<h3>Classes</h3>
<pre><code class="js">class Employee {
name: string;
constructor(name: string) {
this.name = name;
}
greet(): string {
return `Hi, my name is #{this.name}`;
}
}</code></pre>
</section>
<section id="ts-interfaces" data-background-color="#007ACC">
<h3>Interfaces</h3>
<div>
<pre><code class="ts">interface MyInterface {
member: number;
optionalMember?: boolean;
myMethod(param: string[]): number;
}
const instance: MyInterface = ...</code></pre>
</div>
</section>
<section class="live-demo" data-background-color="black">
<h3>Live Demo</h3>
<img alt="" src="./img/code-or-didnt-happen.jpg" />
</section>
<section id="ts-generics" data-background="./img/ts.png" class="color-white">
<h3>Generics</h3>
<p>
<em>Class<T></em>
</p>
<p>Creating a component that can work over a variety of types rather than a single one.</p>
</section>
<section class="live-demo" data-background-color="black">
<h3>Live Demo</h3>
<img alt="" src="./img/code-or-didnt-happen.jpg" />
</section>
<section id="ts-modules" data-background="./img/ts.png" class="color-white">
<h3>Modules</h3>
<p>
<em>import / export</em>
</p>
</section>
<section class="live-demo" data-background-color="black">
<h3>Live Demo</h3>
<img alt="" src="./img/code-or-didnt-happen.jpg" />
</section>
<section id="ts-esnext" data-background="./img/ts.png" class="color-white">
<h3>EcmaScript Next</h3>
</section>
<section class="live-demo" data-background-color="black">
<h3>Live Demo</h3>
<img alt="" src="./img/code-or-didnt-happen.jpg" />
</section>
<section id="ts-lang-services">
<h4 class="text-right">More than a language</h4>
<p>TypeScript also provides tooling and language services for autocompletion, code navigation and refactoring.</p>
</section>
<section id="ts-server" data-background-color="#007ACC">
<h3>tssserver</h3>
<p>Plugins for:</p>
<ul>
<li>Tide(Emacs)</li>
<li>VS Code TypeScript Support</li>
<li>TypeScript-Sublime-Plugin(Sublime Text)</li>
</ul>
</section>
<section id="d-ts-files">
<h3>Type Definition Files</h3>
<p>{lib}.d.ts</p>
<p>Distributed via NPM</p>
<pre><code class="bash">npm install --save @types/jquery</code></pre>
</section>
<section id="ts-angular">
<h3>TypeScript and Angular</h3>
<img src="./img/logo-angular-typescript-schulung.png" class="no-border" />
</section>
</section>
<!-- Flow -->
<section>
<section data-background="#2E343A">
<img alt="" src="./img/flow-logo.png" class="no-border" />
</section>
<section data-background="#2E343A">
<p>Flow is a <strong style="color: #E3BD3D">static type checker</strong> for JavaScript.</p>
</section>
<section id="flow-about">
<h3>Flow</h3>
<ul>
<li>Developed by Facebook</li>
<li>Not a compiler, but checker</li>
<li>Goal: No runtime errors</li>
</ul>
</section>
<section data-background="#2E343A">
<p><strong class="flow-highlight">Flow</strong> checks your code for errors through <strong style="color: #E3BD3D">static type annotations.</strong></p>
<pre class="fragment"><code class="js">// @flow
function square(n: number): number {
return n * n;
}
square('2'); // Error!</code></pre>
</section>
<section data-background="#2E343A">
<p>A lot of the time, <strong style="color: #E3BD3D">Flow</strong> can understand your code without any types at all.</p>
<div class="fragment">
<pre><code class="js">// @flow
function square(n) {
return n * n;
}
square('2'); // Error!</code></pre>
<p style="font-size: 0.8em"><em>TypeScript doesn't catch this without the <strong>"noImplicitAny"</strong> flag.</em></p>
</div>
</section>
<section>
<p>Type annotations can also be written as comments.</p>
<pre><code class="js">// @flow
function strLen(x) /* : string */ {
return x.length;
}
strLen('Hello, world!');</code></pre>
</section>
<section id="flow-demo" data-background-color="black">
<h3>Live Demo</h3>
<a href="https://flow.org/try/" target="_blank">
<img alt="" src="./img/code-or-didnt-happen.jpg" />
</a>
</section>
<section data-background="#2E343A">
<p><strong class="flow-highlight">Flow</strong> only does type checking and relies on <strong class="flow-highlight">Babel</strong> or <strong class="flow-highlight">flow-remove-types</strong> or some other tool to remove type annotations.</p>
<p><strong class="ts-highlight">TypeScript</strong> implements both a type checker and a compiler that emits plain JavaScript.</p>
</section>
</section>
<section data-background="#000">
<p>When developers argue about Static vs Dynamic Typing.</p>
<video src="./img/wwe-fight.mp4" autoplay loop width="500"></video>
</section>
<section>
<h3>Should I use a type checker?</h3>
<ul>
<li class="fragment visible" data-fragment-index="0"><a target="_blank" href="http://danluu.com/empirical-pl/">there seems to be little or no impact on productivity</a>
</li><li class="fragment visible" data-fragment-index="1">initial effort to introduce a checker is low
</li><li class="fragment visible" data-fragment-index="2">but: <span class="fragment visible" data-fragment-index="3">a type system is a complex thing</span>
</li></ul>
</section>
<section>
<h3>My recommendation</h3>
<ul>
<li class="fragment visible" data-fragment-index="1">if your project does not live for long: <em class="fragment visible" data-fragment-index="2"><strong>no</strong></em>
</li><li class="fragment visible" data-fragment-index="3">if your project is really simple: <em class="fragment visible" data-fragment-index="4"><strong>no</strong></em>
</li><li class="fragment visible" data-fragment-index="5">if there is a chance you will need to refactor the thing: <em class="fragment visible" data-fragment-index="6"><strong>yes</strong></em>
</li><li class="fragment visible" data-fragment-index="7">if your system is very important or even crucial for the success of your company: <em class="fragment visible" data-fragment-index="8"><strong>yes</strong></em>
</li><li class="fragment visible" data-fragment-index="9">if people enter or leave your team frequently: <em class="fragment visible" data-fragment-index="10"><strong>yes</strong></em>
</li>
</ul>
</section>
<section id="questions">
<h3>Questions?</h3>
<img class="" src="./img/cats-staring.jpg" width="500" />
</section>
<section id="end">
<h2>Thank You!</h2>
<table>
<tbody>
<tr>
<td><img class="no-border" src="./img/email.png" style="width:70px"></td>
<td style="vertical-align:middle"> <a href="mailto:denis@newventuresoftware.com?Subject=Hello" target="_blank">denis@newventuresoftware.com</a></td>
</tr>
<tr>
<td><img class="no-border" src="./img/github.png" width="70"></td>
<td style="vertical-align:middle"> <a href="https://github.com/deniskyashif" target="_blank">github.com/deniskyashif</a></td>
</tr>
<tr>
<td><img class="no-border" src="./img/twitter.png" width="70"></td>
<td style="vertical-align:middle"><a href="https://twitter.com/deniskyashif" target="_blank">@deniskyashif</a></td>
</tr>
</tbody>
</table>
</section>
</div>
<section class="reveal-shared">
<div class="nvs-logo-container">
<a href="http://www.newventuresoftware.com/" target="_blank">
<img class="no-border" src="./img/nvs-logo.svg" width="150"/>
</a>
</div>
<div class="nvs-website-bar"><span class="nvs-website-text brackets">www.newventuresoftware.com</span></div>
</section>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
history: true,
progress: true,
touch: true,
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
],
slideNumber: 'c/t'
});
</script>
</body>
</html>