The Post JavaScript Apocalypse by Douglas Crockford
Some thoughts about the direction of JavaScript, specifically how to remove redundant constructs of today’s javascript from the language and leave ourselves with fewer methods of expression. You might think having fewer methods of expression would be a bad thing, but he argues that fewer is actually better because it lowers the cognitive dissonance you encounter when running into two things that are mostly similar but not identical, which you then have to expend mental energy differentiating (he illustrated this with an analogy to purging your life of things, which I thought was interesting). It’s a parallel for Garrett’s law, which goes something like this: if two things are similar, either 1) accentuate the differences and make them more different, or 2) eliminate the differences and make them identical.
Here are some examples of changes the speaker recommended:
- Tabs vs. Spaces
- Get rid of tabs. Not because spaces is “better” but because we have two things doing the same thing. Let’s simplify. And since we can’t get rid of spaces, tabs has to go.
- Double Quote
"vs. Single Quote'- Get rid of single quotes (as it’s already overload in use as an apostrophe) to do things like encapsulate strings and use double quotes exclusively.
nullvsundefined- Get rid of
nullas an empty pointer and useundefinedsolely (he recommends leveragingnullin the future as an empty object).
- Get rid of
He goes into depth on other idiosyncrasies of JavaScript and how he would fix them. Things like what 0 / 0 should equal and why (0.1 + 0.2 === 0.3) returns false. It was an interesting talk and I found the metaphor for removing clutter from your life an interesting parallel to the argument for removing redundancies from the langauage of JavaScript. Obviously you can’t just remove them now, but from a perspective of personal code writing, it’s an interesting argument I may try out in practice.