;
==
“I’m not sure how our community got so
religious and fact-disoriented, but it has
got to stop”
“I am sorry that, instead of
educating you, the leaders in
this language community
have given you lies and fear.”
“That is insanely stupid code. Fix it
now. Learn to use semicolons”
Slide 11
Slide 11 text
Paternalism
Slide 12
Slide 12 text
“JavaScript is Hard”
Slide 13
Slide 13 text
We can either learn it...
Slide 14
Slide 14 text
...or we can hide from it
Slide 15
Slide 15 text
“Please don’t do this”
Every tech forum. Ever.
“The subset I carved out is vastly
superior to the language as a whole”
Douglas Crockford - The Good Parts
Slide 16
Slide 16 text
Q: “Why avoid increment (++)
and decrement (--) operators in
JavaScript?”
Slide 17
Slide 17 text
A: “Part of me wonders if it has more
to do with a lack of experience
(perceived or actual) with javascript
coders. I can see how someone just
hacking away at some sample code
could make an innocent mistake with
++ and --, but I don't see why an
experienced professional would avoid
them.”
Slide 18
Slide 18 text
Excessive constraint limits
innovation
Slide 19
Slide 19 text
If you want preditcable,
try Java...
Slide 20
Slide 20 text
...or Canberra
Slide 21
Slide 21 text
because somebody once
redefined undefined now we are
all stupid :)
Slide 22
Slide 22 text
No content
Slide 23
Slide 23 text
function(x) {
if (typeof x === 'undefined') {
return;
}
//...
}
“We need constraints because
most people don't know
JavaScript well”
Slide 28
Slide 28 text
“The body of a for in should be
wrapped in an if statement to filter
unwanted properties from the
prototype”—JS Lint
“hasOwnProperty [is] essential
when iterating over the properties
of any object ”—JS Garden
Slide 29
Slide 29 text
No content
Slide 30
Slide 30 text
No content
Slide 31
Slide 31 text
Don’t buy the code for the dumbest
ideology, it negates our
responsibility to educate ourseleves,
and our team.
It holds us back and holds the
language back.
Slide 32
Slide 32 text
The Cult of Machines
Slide 33
Slide 33 text
The Traffic Light Paradox
Slide 34
Slide 34 text
Drachten, Netherlands 2000
Slide 35
Slide 35 text
Drachten, Netherlands 2001
Slide 36
Slide 36 text
Removed all traffic lights and signs
from the town's centre
Two years after the system was
introduced, average travel times
lowered significantly and yearly
accidents were reduced from 8 to 1.
Drachten, Netherlands 2000-2001
Slide 37
Slide 37 text
“Accidents, as well as congestion, are
reduced when motorists show greater
individual responsibility, rather than
mentally switching off to behave like
automata”
Slide 38
Slide 38 text
Case in Point...
Slide 39
Slide 39 text
function natcompare(a,b) {
var ca, cb;
while (true) {
ca = a.charAt(ia++); cb = b.charAt(ib++);
//(some zero checking goes here)
if (ca == 0 && cb == 0) {
//The strings compare the same.
return 0;
}
if (ca < cb) {return -1;}
if (ca > cb) {return +1;}
}
}
Slide 40
Slide 40 text
function natcompare(a,b) {
var ca, cb;
while (true) {
ca = a.charAt(ia++); cb = b.charAt(ib++);
//(some zero checking goes here)
if (ca === 0 && cb === 0) {
//The strings compare the same.
return 0;
}
if (ca < cb) {return -1;}
if (ca > cb) {return +1;}
}
}
Slide 41
Slide 41 text
function natcompare(a,b) {
var ca, cb;
while (true) {
ca = a.charAt(ia++); cb = b.charAt(ib++);
//(some zero checking goes here)
if (ca === 0 && cb === 0) {
//YOU ARE DOOMED!.
return 0;
}
if (ca < cb) {return -1;}
if (ca > cb) {return +1;}
}
}
Slide 42
Slide 42 text
Linters are great for catching
trailing commas
Slide 43
Slide 43 text
But they suck at nuance
Slide 44
Slide 44 text
“Consistency is the hobgoblin of
little minds”
Ralph Waldo Emerson
Dichotomy is attractive,
a simple choice between right and wrong.
Slide 102
Slide 102 text
The One True Way!
JavaScript vs CoffeeScript
OOP vs Functional
Callbacks vs Promises
comma-first vs comma-last
Slide 103
Slide 103 text
But JavaScript is not science.
We’re all just muddling along.
Slide 104
Slide 104 text
My Humble Style Guide
1. Use Brackets In Conditionals
2. Line Break after Function Signature
3. Space after //
Slide 105
Slide 105 text
My Humble Style Guide
1. Use Brackets In Conditionals
2. Line Break after Function Signature
3. Space after //
4. ALWAYS use ===
5. NEVER parseInt without a radix arg
6. You SUCK if you use new
Attn. Slide Viewers: this is a parody!!
Text
Slide 106
Slide 106 text
Guidelines mistaken for rules...
Slide 107
Slide 107 text
“No Globals Ever”
Globals are a feature too
Use with caution
Slide 108
Slide 108 text
“Always use feature detection”
Feature detect Object.defineProperty?
In IE 8? Really?
Slide 109
Slide 109 text
Each time we claim an absolute, some other
technique is discarded from the toolbelt
Slide 110
Slide 110 text
No content
Slide 111
Slide 111 text
Would you buy
“airplane controls, the good parts”?
Slide 112
Slide 112 text
Hope
Slide 113
Slide 113 text
"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
Slide 114
Slide 114 text
Learn one way and fight your
corner...
...or learn them all and be informed.
Slide 115
Slide 115 text
This doesn’t make good coders
Slide 116
Slide 116 text
This doesn’t make good coders
You can’t legislate against bad code
Slide 117
Slide 117 text
This makes good coders*
(*Thanks David Nolen)
Slide 118
Slide 118 text
We can rise above the
fearmongers, the ideologues and
the absolutists...
1) Master the fundamentals: this,
prototypes, coercion and scoping
2) Experiment, Play, Have Fun
and Keep an Open Mind.
Slide 119
Slide 119 text
The End
@angustweets
Slide 120
Slide 120 text
code credits
natural order comparator
Copyright (C) 2005 by SCK-CEN (Belgian Nucleair Research Centre)
Copyright (C) 2003 by Pierre-Luc Paour
Copyright (C) 2000 by Martin Pool