Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The Book Nerd's Guide to JavaScript
Search
Angus Croll
November 17, 2014
Technology
14
4.1k
The Book Nerd's Guide to JavaScript
Given at DotJS, Paris on 17th November 2014
Angus Croll
November 17, 2014
Tweet
Share
More Decks by Angus Croll
See All by Angus Croll
Stop being Perfect
anguscroll
11
1.4k
ES6 Uncensored
anguscroll
72
12k
Learning to Fly — Twitter Flight and Mixins
anguscroll
23
4.4k
JavaScript is Literature is JavaScript
anguscroll
21
3.3k
The Politics of JavaScript
anguscroll
122
23k
Parlez-Vous JavaScript
anguscroll
33
6.3k
Break all the Rulez
anguscroll
42
15k
How we Learned to Stop Worrying and Love JavaScript
anguscroll
90
21k
Other Decks in Technology
See All in Technology
リファクタリングへの耐性が高いモデルベースの統合テストの紹介 / Model-Base Integration Test for Refactoring
yuitosato
5
1.5k
インシデント対応の 実践と品質文化の醸成
____rina____
2
1.5k
内製化によるシステムモダナイゼーションの実践
kazokmr
3
530
Aurora_BlueGreenDeploymentsやってみた
tsukasa_ishimaru
1
120
失敗しないOpenJDKの非互換調査
tabatad
0
230
わたしとトラックポイント / TrackPoint tips
masahirokawahara
1
200
日経ビジュアルデータにおける スクロールテリングと地図/nikkei-tech-talk-26
nikkei_engineer_recruiting
0
160
バクラクにおける可観測性向上の取り組み
yuu26
2
230
TinyMLの技術動向
kyotomon
2
260
AWS SAW(AWS Support Automation Workflows)をもっと広めたい
kazzpapa3
2
170
キーワードの再整理のススメ ~テストタイプ/テストレベルで最適化!~/20241025 Midori Inada
shift_evolve
0
120
Kubernetes Summit 2024 Keynote:104 在 GitOps 大規模實踐中的甜蜜與苦澀
yaosiang
0
270
Featured
See All Featured
Speed Design
sergeychernyshev
24
560
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
280
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
Code Review Best Practice
trishagee
64
17k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
A Modern Web Designer's Workflow
chriscoyier
692
190k
Building Better People: How to give real-time feedback that sticks.
wjessup
363
19k
The Power of CSS Pseudo Elements
geoffreycrofte
72
5.3k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Docker and Python
trallard
40
3k
Designing the Hi-DPI Web
ddemaree
280
34k
Transcript
A Book Nerd’s Guide to JavaScript @angustweets
None
Practical, Useful, Mind Numbingly Boring Nonsensical Work of Genius
What can Literature teach us about Programming?
Great literature is the creation of open minds As programmers
our focus can be very narrow
We’re encouraged to follow only one style…
Actual excerpts from: Google Style Guide AirBnb Style Guide JavaScript
Garden
None
None
We’re left with only one way to get from A
to B :(
None
None
Literature is about embracing the entire language
When programmers embrace the entire language we get choices…
None
None
"There are indeed many ways to do the same thing
in JS. That's one of the beauties of the language" - Peter van der Zee (@kuvos)
None
None
(at least until the JavaScript Police get here)
None
None
Perhaps most importantly…
…Open Minds keep JavaScript fun.
This one just follows The Good Parts These two learn
by experiment
As programmers we’re not encouraged to experiment
Yet experiment is what keeps JavaScript alive
“You need a lot of bad code to write good
code” - Substack (dotJS 2014)
‣ if(!!x) ‣ fn && fn() ‣ immediately invoked functions
‣ module pattern ‣ promises
None
I decided to take experiment to the next level…
None
Wait What?
Twenty Five Authors solving Five JavaScript Problems
Hemingway developed the Iceberg Theory
Here is Hemingway’s Iceberg Theory applied to JavaScript…
(weird shit) (Deceptively Familiar Syntax) (weird shit) JavaScript
(weird shit) JAVA!! (Deceptively Familiar Syntax) (weird shit) JavaScript
(weird shit) JAVA!! But Easier!! (Deceptively Familiar Syntax) (weird shit)
JavaScript
(weird shit) JAVA!! But Easier!! (Deceptively Familiar Syntax) (weird shit)
WTF? JavaScript
Generate Prime Numbers
None
// A succession of creatures mount the stairs;! // each
creature's stride exceeds that of its predecessor! var monstersAscendingAStaircase = function(numberOfSteps) {! var stairs = []; stepsUntrodden = [];! var largestGait = Math.sqrt(numberOfSteps);! for (var i = 2; i <= largestGait; i++) {! if (!stairs[i]) {! for (var j = i * i; j <= numberOfSteps; j += i) {! stairs[j] = 'stomp';! }! }! }! ! // Long-limbed monsters won't tread on prime numbered stairs.! for (var i = 2; i <= numberOfSteps; i++) {! if(!stairs[i]) {! stepsUntrodden.push(i);! }! }! ! // Here, then, is our answer.! return stepsUntrodden;! };!
1 2 3 4 5 6 7 8 9 10
11 12 13 14 2 3 Borges vs. Prime Numbers
None
function downTheRabbitHole(growThisBig) {! var theFullDeck = Array(growThisBig);! var theHatter =
Function('return this/4').call(2*2);! var theMarchHare = Boolean("The frumious Bandersnatch!");! ! var theVerdict = "the white rabbit".split(/the march hare/).slice(theHatter);! ! //into the pool of tears...! eval(theFullDeck.join("if (!theFullDeck[++theHatter]) {\! theMarchHare = 1;\! theVerdict.push(theHatter);\! " + theFullDeck.join("theFullDeck[++theMarchHare * theHatter]=true;") + "}")! );! ! return theVerdict;! }!
function downTheRabbitHole(growThisBig) {! var theFullDeck = Array(growThisBig);! var theHatter =
Function('return this/4').call(2*2);! var theMarchHare = Boolean("The frumious Bandersnatch!");! ! var theVerdict = "the white rabbit".split(/the march hare/).slice(theHatter);! ! //into the pool of tears...! eval(theFullDeck.join("if (!theFullDeck[++theHatter]) {\! theMarchHare = 1;\! theVerdict.push(theHatter);\! " + theFullDeck.join("theFullDeck[++theMarchHare * theHatter]=true;") + "}")! );! ! return theVerdict;! }!
function downTheRabbitHole(growThisBig) {! var theFullDeck = Array(growThisBig);! var theHatter =
Function('return this/4').call(2*2);! var theMarchHare = Boolean("The frumious Bandersnatch!");! ! var theVerdict = "the white rabbit".split(/the march hare/).slice(theHatter);! ! //into the pool of tears...! eval(theFullDeck.join("if (!theFullDeck[++theHatter]) {\! theMarchHare = 1;\! theVerdict.push(theHatter);\! " + theFullDeck.join("theFullDeck[++theMarchHare * theHatter]=true;") + "}")! );! ! return theVerdict;! }!
! new Array(5).join('A' + new Array(5).join('a'));! ! >! !
new Array(5).join("A" + new Array(5).join('a'));! ! > "AaaaaAaaaaAaaaaAaaaa"!
function downTheRabbitHole(growThisBig) {! var theFullDeck = Array(growThisBig);! var theHatter =
Function('return this/4').call(2*2);! var theMarchHare = Boolean("The frumious Bandersnatch!");! ! var theVerdict = "the white rabbit".split(/the march hare/).slice(theHatter);! ! //into the pool of tears...! eval(theFullDeck.join("if (!theFullDeck[++theHatter]) {\! theMarchHare = 1;\! theVerdict.push(theHatter);\! " + theFullDeck.join("theFullDeck[++theMarchHare * theHatter]=true;") + "}")! );! ! return theVerdict;! }!
eval(“if(!theFullDeck[++theHatter]){theMarchHare=1;theVerdict.push(theHatter);theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;}if(!theFullDeck[+ +theHatter]){theMarchHare=1;theVerdict.push(theHatter);theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;}if(!theFullDeck[+ +theHatter]){theMarchHare=1;theVerdict.push(theHatter);theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;theFullDeck[+
+theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;}if(!theFullDeck[+ +theHatter]){theMarchHare=1;theVerdict.push(theHatter);theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;}if(!theFullDeck[+ +theHatter]){theMarchHare=1;theVerdict.push(theHatter);theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;}if(!theFullDeck[+ +theHatter]){theMarchHare=1;theVerdict.push(theHatter);theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;theFullDeck[+ +theMarchHare*theHatter]=true;theFullDeck[++theMarchHare*theHatter]=true;}”);!
eval(“if (!theFullDeck[++theHatter]) {! theMarchHare = 1;! theVerdict.push(theHatter);! theFullDeck[++theMarchHare * theHatter]
= true;! theFullDeck[++theMarchHare * theHatter] = true;! theFullDeck[++theMarchHare * theHatter] = true;! theFullDeck[++theMarchHare * theHatter] = true;! theFullDeck[++theMarchHare * theHatter] = true;! theFullDeck[++theMarchHare * theHatter] = true;! }! if (!theFullDeck[++theHatter]) {! theMarchHare = 1;! theVerdict.push(theHatter);! theFullDeck[++theMarchHare * theHatter] = true;! theFullDeck[++theMarchHare * theHatter] = true;! theFullDeck[++theMarchHare * theHatter] = true;! theFullDeck[++theMarchHare * theHatter] = true;! theFullDeck[++theMarchHare * theHatter] = true;! theFullDeck[++theMarchHare * theHatter] = true;! }! if (!theFullDeck[++theHatter]) {! theMarchHare = 1;!
Alice in Prime Numberland
Alice in Prime Numberland
Alice in Prime Numberland
Alice in Prime Numberland
Alice in Prime Numberland
Alice in Prime Numberland
Alice in Prime Numberland
Alice in Prime Numberland
Alice in Prime Numberland
Alice in Prime Numberland
Alice in Prime Numberland
So what did we learn?
Playing is Learning
Self-taught programmers are often the best programmers because they get
to make mistakes
Experiment, Play, Have Fun and Keep an Open Mind.
Fin, merci! @angustweets anguscroll.com/hemingway
Books: http://pixgood.com/classic-book-spines.html/ Montparnasse Tower: http://allparisguides.com Eiffel Tower: Yellow Monster: http://content.mycutegraphics.com/
Green Monster: http://wondersofdisney2.yolasite.com/ White Rabbit: http://www.clker.com/ Mad Hatter, March Hare: http://wondersofdisney2.yolasite.com/ Cow, tree, office buildings: clipartpanda.com/ Grass: imgarcade.com/ Lion cubs: https://www.flickr.com/photos/mbiddulph/6947067048/ Cheetah cubs: http://www.bhmpics.com/view-cheetah_cubs_playing-1920x1080.html/ ! Image credits