-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
362 lines (327 loc) · 18.8 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="bower_components/reveal.js/css/reveal.css">
<link rel="stylesheet" href="bower_components/reveal.js/css/theme/black.css">
<link rel="stylesheet" href="bower_components/highlightjs/styles/agate.css">
<link rel="stylesheet" href="css/site.css">
<title>Lua</title>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<img src="img/lua.gif" class="lua-logo left-image"/>
<h1>Lua</h1>
<h2>A Fun Little Language</h2>
</section>
<section>
<h2>What, exactly, is Lua?</h2>
</section>
<section data-background="img/1429102209_PUCRio.jpg">
<p class="background-caption">Created 1993 by Tecgraf of PUC-Rio</p>
</section>
<section data-background="img/947px-FullMoon2010.jpg">
<p class="background-caption">Portuguese for “moon”</p>
</section>
<section>
<h2>Why should I care?</h2>
</section>
<section>
<p>There's no shortage of scripting languages available...</p>
<iframe src="assets/wikipedia_category_scripting_languages.html" width="100%" height="500px">
</iframe>
<a href="https://en.wikipedia.org/wiki/Category:Scripting_languages">https://en.wikipedia.org/wiki/Category:Scripting_languages</a>
</section>
<section>
<p>Lua is…</p>
<ul>
<li>Fast</li>
<li>Small</li>
<li><em>Really</em> easy to embed</li>
</ul>
</section>
<section>
<h2>Application and Service Scripting</h2>
</section>
<section>
<p>Some applications using Lua:</p>
<div class="narrow logos">
<div><img src="img/logos/v4_LR_icon-cropped.png"/><div class="caption">Adobe Lightroom</div></div>
<div><img src="img/logos/PuTTY_icon-2bgpv7l.png"/><div class="caption">ExtraPuTTY</div></div>
<div><img src="img/logos/logo_haproxy.com.png"/><div class="caption">HAProxy</div></div>
<div><img src="img/logos/Lighttpd_logo.svg.png"/><div class="caption">Lighttpd</div></div>
<div><img src="img/logos/mediawikiwiki.png"/><div class="caption">MediaWiki</div></div>
<div><img src="img/logos/MySQL-workbench.png"/><div class="caption">MySQL Workbench</div></div>
<div><img src="img/logos/nmap-logo-256x256.png"/><div class="caption">Nmap</div></div>
<div><img src="img/logos/nginx.png"/><div class="caption">Nginx</div></div>
<div><img src="img/logos/redis-lua-medium.png"/><div class="caption">Redis</div></div>
<div><img src="img/logos/Vimlogo.png"/><div class="caption">Vim</div></div>
<div><img src="img/logos/cone_altglass.png"/><div class="caption">VLC</div></div>
<div><img src="img/logos/Wireshark_Icon.png"/><div class="caption">Wireshark</div></div>
</div>
</section>
<section>
<p>Even viruses use Lua!</p>
<img src="img/Flame-virus.png"/>
<p class="credit">Flame virus screenshot from Kaspersky Lab</p>
</section>
<section>
<p>Example: CloudFlare</p>
<img class="plain" src="img/cloudflare.png">
<p>From Nginx + C modules to OpenResty (Nginx + LuaJIT)</p>
<p class="credit">Further reading:
<a href="https://blog.cloudflare.com/pushing-nginx-to-its-limit-with-lua/">1</a>,
<a href="https://blog.cloudflare.com/cloudflares-new-waf-compiling-to-lua/">2</a>,
<a href="http://www.slideshare.net/jgrahamc/lua-the-worlds-most-infuriating-language">3</a>,
<a href="https://www.scalescale.com/scaling-cloudflares-massive-waf/">4</a>
</p>
</section>
<section data-background="img/wow-subscriber-counts-drops-considerably.jpg">
<div class="background-caption caption-top fragment">
<h2>Games</h2>
<dl>
<dt>2003</dt><dd>Most popular scripting language (GameDev.net)</dd>
<dt>2011</dt><dd>Front Line Award winner (<i>Game Developer</i>)</p>
</dl>
</div>
</section>
<section>
<p>Just a few of the games made using Lua…</p>
<div class="logos">
<div><img src="img/logos/Angry_Birds_promo_art.png" title="Angry Birds"/></div>
<div><img src="img/logos/Baldur's_Gate_box.png" title="Baldur's Gate"/></div>
<div><img src="img/logos/CIVILIZATION-V-FRONT-OF-BOX.png" title="Civilization V"/></div>
<div><img src="img/logos/Crysis_Cover.png" title="Crysis"/></div>
<div><img src="img/logos/GarrysMod.png" title="Garry's Mod"/></div>
<div><img src="img/logos/Grim_Fandango_artwork.png" title="Grim Fandango"/></div>
<div><img src="img/logos/Homeworld_2_box_art.png" title="Homeworld 2"/></div>
<div><img src="img/logos/LegoUniverse.png" title="Lego Universe"/></div>
<div><img src="img/logos/Payday.jpg" title="Payday"/></div>
<div><img src="img/logos/Saints_Row_2_Game_Cover.png" title="Saint's Row 2"/></div>
<div><img src="img/logos/SimCity_4_cover.png" title="SimCity 4"/></div>
<div><img src="img/logos/StarWarsBattlefront2_PC.png" title="Star Wars Battlefront 2"/></div>
<div><img src="img/logos/supcom1.jpg" title="Supreme Commander"/></div>
<div><img src="img/logos/The_Witcher_EU_box.png" title="The Witcher"/></div>
<div><img src="img/logos/Warhammer_40,000_Dawn_of_War_II.png" title="Warhammer 40,000: Dawn of War II"/></div>
</div>
</section>
<section>
<p>Lua-powered game engines:</p>
<div class="logos">
<div><img src="img/logos/coronaicon.png"/><div class="caption">Corona SDK</div></div>
<div><img src="img/logos/Cocos2dx.png"/><div class="caption">Cocos 2d-x</div></div>
<div><img src="img/logos/CryEngine.png"/><div class="caption">CryEngine</div></div>
<div><img src="img/logos/Defold-logo-text-below.png"/><div class="caption">Defold</div></div>
<div><img src="img/logos/Love.png"/><div class="caption">LÖVE</div></div>
<div><img src="img/logos/Lumberyard.png"/><div class="caption">Lumberyard</div></div>
<div><img src="img/logos/Moai.png"/><div class="caption">Moai</div></div>
<div><img src="img/logos/te4-logo.png"/><div class="caption">T-Engine 4</div></div>
</div>
<p>See <a href="http://stackoverflow.com/q/5053134">stackoverflow.com/q/5053134</a> for more.</p>
</section>
<section>
<h2>How do I write Lua?</h2>
</section>
<section>
<img src="img/pil.jpg" title="Programming in Lua" class="plain left-image"/>
<p>
<i>Programming in Lua</i><br/>
<a href="http://www.lua.org/pil/">www.lua.org/pil/</a>
</p>
<p>
Lua 5.3 Reference Manual<br/>
<a href="http://www.lua.org/manual/5.3/">www.lua.org/manual/5.3/</a>
</p>
<p>
Lua Tutorial<br/>
<a href="http://lua-users.org/wiki/LuaTutorial">lua-users.org/wiki/LuaTutorial</a>
</p>
</section>
<section>
<img id="stopwatch" src="img/stopwatch.jpg" class="plain left-image fragment"/>
<p>
Learn Lua in 15 Minutes
<a href="http://tylerneylon.com/a/learn-lua/">tylerneylon.com/a/learn-lua/</a>
</p>
</section>
<section data-background="img/JavaScript.png">
<div class="background-caption" style="margin-top: 510px">
<h3>What are Lua's bad parts?</h3>
</div>
</section>
<section>
<h4>1-based indexing</h4>
<pre><code class="lua">names = { 'Alice', 'Bob', 'Charlie' }
print names[1]
-- prints 'Alice'
names[0] = 'Phil'
-- This is legal, but table.sort, #names, etc. will be confused</code></pre>
</section>
<section>
<p>Edsger Dijkstra, <a href="https://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF">“Why numbering should start at 0,”</a> 1982</p>
<embed src="https://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF#page=1&zoom=125" width="1000" height="500">
</section>
<section>
<blockquote>
So: the technical reason we started counting arrays at zero is that in the mid-1960’s, you could shave a few cycles off of a program’s compilation time on an IBM 7094. The social reason is that we had to save every cycle we could, because if the job didn’t finish fast it might not finish at all and you never know when you’re getting bumped off the hardware because the President of IBM just called and #$@&% your thesis, it’s yacht-racing time.
</blockquote>
<p>—Mike Hoye, <a href="http://exple.tive.org/blarg/2013/10/22/citation-needed/">“Citation Needed”</a></p>
</section>
<section>
<h4>1-based indexing</h4>
<p>Who cares? Use an iterator:</p>
<pre><code class="lua">names = { 'Alice', 'Bob', 'Charlie' }
for i, v in ipairs(names)
print v
end</code></pre>
</section>
<section>
<h4>Small standard library</h4>
<p>Some of the functionality I miss in Lua:</p>
<ul class="long-list">
<li>Filesystem</li>
<li>Regexes</li>
<li>Networking</li>
<li>JSON</li>
<li>string.startsWith</li>
<li>string.endsWith</li>
<li>string.trim</li>
<li>Case conversions</li>
<li>Class creation</li>
<li>math.round</li>
<li>Pretty-printing tables</li>
<li>table.clone</li>
<li>Deep equality</li>
<li>Extract a table's values…</li>
<li>…or keys</li>
</ul>
</section>
<section>
<p>Comparison: Python</p>
<img class="plain" src="img/python_dlls.png"/>
<img class="plain" src="img/python_lib.png"/>
</section>
<section>
<p>It's not all bad...</p>
<pre><code class="lua">-- Pattern matching from <a href=http://www.lua.org/pil/20.2.html">http://www.lua.org/pil/20.2.html</a>
-- Not as powerful as regexes, but still nice.
s = "Deadline is 30/05/1999, firm"
date = "%d%d/%d%d/%d%d%d%d"
print(string.sub(s, string.find(s, date)))
-- outputs "30/05/1999"
-- Search-and-replace: Replace all non-letters
print(string.gsub("hello, up-down!", "%A", "."))
-- outputs "hello..up.down. 4"</code></pre>
<pre class="fragment"><code class="lua">-- printf-style string formatting
val = 1
print(("%3i"):format(val))
-- outputs " 1"
<span class="fragment">-- Take THAT, JavaScript!</span></code></pre>
</section>
<section>
<h4>Incompatible implementations</h4>
<p>Lua 5.3 (and 5.2)</p>
<ul class="code-list">
<li class="fragment" data-fragment-index="1">Integers
<pre class="fragment fade-out" data-fragment-index="2"><code class="lua">i = 3 -- Integer
n = 2.0 -- Float
print(type(i)) -- "number"
print(type(n)) -- "number"
print(i/n) -- "1.5"
print(i//n) -- "1"</code></pre>
</li>
<li class="fragment" data-fragment-index="2">Bitwise operators</li>
<li class="fragment" data-fragment-index="3">UTF-8 support ("\u" string literals, "utf8" module)</li>
<li class="fragment" data-fragment-index="4">"goto" statement
<pre class="fragment fade-out" data-fragment-index="5"><code class="lua">for z=1,10 do
for y=1,10 do
for x=1,10 do
if x^2 + y^2 == z^2 then
print('found a Pythagorean triple:', x, y, z)
print('now trying next z...')
goto zcontinue
end
end end ::zcontinue:: end</code></pre>
</li>
<li class="fragment" data-fragment-index="5">Finalizers</li>
</ul>
</section>
<section>
<h4>Incompatible Implementations</h4>
<p>LuaJIT</p>
<ul class="code-list">
<li class="fragment">Fast</li>
<li class="fragment">Really fast</li>
<li class="fragment">You just won't believe how vastly, hugely, mind-bogglingly fast it is.</li>
<li class="fragment">I mean, you may think that V8 is fast, but that's just peanuts to LuaJIT. <span class="fragment">(with apologies to Douglas Adams)</span></li>
</ul>
</section>
<section>
<h2>What tools should I know about?</h2>
</section>
<section>
<h3>Resources</h3>
<ul>
<li>
FAQs<br>
<a href="http://lua-users.org/wiki/">lua-users wiki</a><br>
<a href="http://www.luafaq.org/gotchas.html">Lua Gotchas</a>
</li>
<li class="fragment">
Online REPL (Read-Evaluate-Print Loop)<br>
<a href="https://repl.it/">repl.it</a>
</li>
<li class="fragment">
Package manager<br>
<a href="https://luarocks.org/">LuaRocks</a>
</li>
<li class="fragment">
IDE<br>
<a href="https://studio.zerobrane.com/">ZeroBrane Studio</a>
</li>
<li class="fragment">
Alternative languages<br>
<a href="http://moonscript.org/">MoonScript</a>
</li>
</ul>
</section>
<section>
<h3>Image credits</h3>
<ul class="credit">
<li><a href="https://ligadonafacul.com.br/saiba-mais-sobre-os-cursos-online-e-gratuitos-da-puc-rio/">PUC-Rio campus building - Ligado Na Facul</a></li>
<li><a href="https://commons.wikimedia.org/w/index.php?curid=11901243">Moon - by Gregory H. Revera, own work</a></li>
<li><a href="https://securelist.com/blog/incidents/34344/the-flame-questions-and-answers-51/">Flame virus screenshot - Kaspersky Lab</a></li>
<li><a href="http://games-macdownload.com/world-of-warcraft-mac-download/wow-subscriber-counts-drops-considerably/">World of Warcraft screenshot - Games-pc-download.com</a></li>
<li><a href="https://www.flickr.com/photos/mrlerone/508091819/in/photolist-LU6ZM-CTvd9-8esu9R-6cyvEr-5FnsNq-bopgYj-cX8f9y-3w2hL-iLxovd-4V92Su-6ZpvD-ihux5T-64euRJ-6g4eby-4nSYYn-eh7TYt-f86ro1-i9NnnB-8HmCDA-wmwLoT-r55uzA-gmD3Ge-5mfH6-iyQpBa-75m8Sb-3ERSv4-bRnUkx-fJVySg-cizMFU-5Qu5AP-5rDomB-oWRqrL-wBwq6-6KZcb7-6KZcaE-9Vwuzc-8Qm8QP-csysU5-9VwtJK-nFvkp7-9sJtdA-dFYHwE-b1kU4Z-bkqPDP-gtaKNf-epZ7tB-6KV4B8-62F2mE-fEgaqw-9pQ6mz">Stopwatch - by Troy Bradbury, Flickr</a></li>
</ul>
<p class="credit">All logos and trademarks are copyright of their respective holders.</p>
</section>
<section>
<h2>End</h2>
</section>
</div>
</div>
<script src="bower_components/reveal.js/lib/js/head.min.js"></script>
<script src="bower_components/reveal.js/js/reveal.js"></script>
<script>
Reveal.initialize({
controls: true,
progress: true,
history: true,
transition: 'slide',
transitionSpeed: 'fast',
dependencies: [
{ src: 'bower_components/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
//{ src: 'bower_components/reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'bower_components/reveal.js/plugin/markdown/marked.js' },
{ src: 'bower_components/reveal.js/plugin/markdown/markdown.js' },
{ src: 'bower_components/reveal.js/plugin/zoom-js/zoom.js', async: true },
{ src: 'bower_components/highlightjs/highlight.pack.js' },
{ src: 'js/reveal-code-focus.js', callback: function() { RevealCodeFocus(true); } }
]
});
</script>
</body>
</html>