downtherabbithole.js – how to stay sane in an insane ecosystem

29
DownTheRabbitHole.js How to Stay Sane in an Insane Ecosystem

Upload: fitc

Post on 15-Apr-2017

165 views

Category:

Internet


1 download

TRANSCRIPT

Page 1: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

DownTheRabbitHole.jsHow to Stay Sane in an Insane Ecosystem

Page 2: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Space Forensics• Government contract… • For an educational… • Lucas Arts style game… • For NASA!

Page 3: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

I feel like I’m taking crazy pills.

Page 4: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

First, a bit of history.

Page 5: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

In the beginning• 1995 - Over 10 days Brendan Eich of Netscape made Mocha

• Renamed to LiveScript

• And then JavaScript (licensing a ride on Java’s coattails…)

• 1997 - ECMAScript v1 (ECMA-262) standard defined

• 1998 - ECMAScript v2 - now an ISO standard (ISO/IEC 16262)

• 1999 - ECMAScript v3 - first “modern” javascript

Page 6: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Power Struggle• Plugins for non-trivial interactivity • Big fights over ECMAScript v4 • End result was v3.1 v5 in…

2009sigh.

Page 7: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

In the meantime…

• 2005 - AJAX white paper

• 2006 - jQuery, Mootools, Prototype, & Dojo

• Make working with the DOM easier

• Smooth over cross-platform issues

• Bring common patterns to JS (observables, promises, etc)

Page 8: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

node.js & npm• 2009 - node.js released

• Powered by Google’s v8 JS engine for Webkit

• Async I/O

• JS on the server anywhere!

• 2011 - npm released

• Package manager for JS

• Which results in…

Page 9: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

The Cambrian Javascript Explosion

Page 10: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

JavaScript Modules

• Easy to publish to npm

• Zero gatekeeping

• Massive overlap

• Quality varies wildly

• Lots, and lots of dodos

329,149modules on npm as of 9/22/2016

Page 11: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Wait… “modules”?

• No language support for modules!

• Work arounds it is!

• CommonJS (server)

• AMD (browser)

• Incompatible! Solution?

• MORE JAVASCRIPT!

Page 12: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

JavaScript Tooling• Scaffold

• Yeoman, Slush, etc.

• Transpile

• Coffeescript, TypeScript, Dart, Babel, Clojurescript, Elm, etc.

• Build

• Grunt, Gulp, Webpack, Brunch, etc.

Page 13: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

On the horizon• asm.js

• Strict subset of JavaScript that acts as a compiler target

• Compile C, C++, Lua, Ruby, Python, etc. to JS

• ECMAScript v6 (ES6) - Modules! Tons of new syntax!

• WebComponents - emerging standard (Polymer polyfill)

• HTTP/2 - everything you know about HTTP is wrong

Page 14: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Rein in the madness

Page 15: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

One size does not fit all

• What are you building?

• How big will the codebase be?

• Who is your audience?

• What does your team know?

• When is the project due?

• How long will your code last?

Page 16: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Not just a technical problem!

• Affects hiring

• Affects employee moral

• Affects internal training

Page 17: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Transpiled Languages

• Need to know JS too

• Matters less than discipline

• More complex tooling

• Longer ramp-up

• Just the “good parts”

• Strong typing

• Improved syntax

• Domain specificity

ConsPros

Page 18: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

ES6 via BabelOur choice:

Page 19: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Invest in great tooling• The best setups have the tightest feedback loops

• One-click is great, no clicks is better

• Automate all the things!

• Bootstrapping

• Building (including sourcemaps!)

• Testing

• Deploying

• Document your tools like crazy

Page 20: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Our choice:

webpack (right now) brunch (future projects)

Page 21: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Philosophy

• What’s the core idea?

• Can they explain it?

• What is their inspiration?

• Are they solving your problems?

• Does it play well with others?

Page 22: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Small vs. Big

• Monolithic = consistency

• Centralized documentation

• Reduced flexibility

• Larger mental load

Page 23: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Documentation

• Bad docs = bad software

• Unit tests

• Code coverage

• Read the docs! (Yes, all of them!)

• Read the code! (Yes, all of it!)

Page 24: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Functional Programming

• “Lisp in C’s Clothing”

• Prefer functions

• Immutability

• One-way data binding

• Chaining

• Reactive

Page 25: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Our choice (SPAs):

lodash + react + redux

Page 26: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Options from the “Big Boys”

• vue.js - view layer

• zepto - jQuery

• riot - react

• meteor - full stack!

Page 27: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Other great libraries

• d3 - data visualization

• rxjs - reactive programming

• jest - testing made easy

• moment - dates & times

• superagent - ajax

Page 28: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

You cannot stop swimming

• Picking a “winner” is a bad idea

• Find what works for you…

• But never stop searching for better

Page 29: DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem

Thank Youwww.automatastudios.com

@automatastudios

go.nasa.gov/spaceforensics

[email protected] @waxpraxis