The More JavaScript Changes...

..the more it stays the same.

It’s clear I love dynamic languages. I like metaprogramming. I like DRY code. I hate repeating myself (at least when I write code—I repeat myself a lot in person). Objective-C and JavaScript are both dynamic languages and those are the two langs I’ve written produced the most open source code with.

I also like reliable and fast languages. That’s why, although they’re dynamic, I don’t favor Ruby or Python. Python is the better of the two, but I still can’t justify creating the type of web services I write in Python.

That was all setup for the following: Just as Swift is less dynamic than Objective-C, new JavaScript is less dynamic than old JavaScript. Examples:

  • import|export syntax vs. CommonJS
  • More types and implementations of type systems

Static analysis in the language itself isn’t the only reason we’ve gotten less dynamic. Build time tools such as Browserify, static analysis via ESLint, type checking via Flow and several other tools have given us greater safety at the expense of the former wild west freedom.

While I strongly dislike giving up dynamism, I have a much stronger dislike for unDRY (WET?) code. There are a couple recent additions to JavaScript that require a little more thought up front but result in DRYer, safer (and after some re-training of your team) more expressive code. I’m talking about object shorthand syntax and computed property names. Technically computed property names have a duality between safety and danger, but that’s why I love JS.

Object shorthand syntax reduces errors and reader’s overhead by taken advantage of that fact keys and the variables assigned to them should be the same anyway. I’ve always done it that way and viewed variance from that as evidence of not having thoroughly evaluated the why and how of semantics in your application. This syntax is especially valuable in React components, where passing props is common:

({ dimensions, mappings }) =>


({ dimensionz, mappingz }) =>

No joke, I’ve seen plenty of code where the variables were just as arbitrarily named differently from the keys.

Computed property names allow one to (dangerous but powerful skill) dynamically create method names on an object while declaring the object or (safe skill) use constants to name your methods while declaring the object. We’ve always been able to do the following:

const mappings = { }
mappings[SOME_CONSTANT] = '<3'
mappings['time_' +] = new Date

but now we can do either of the following

['time_' +] : new Date

New safety, but also new power depending on which aspect of computed properties you focus on!

The more JavaScript changes, the more it stays the same I guess.

A Proven Cure for JavaScript Fatigue

As an ADHD-addled obsessive who’s been writing JavaScript since 1998, the drive to stay avante garde is nothing new to me. Whether it’s collecting the latest comic books, tech tomes or guitar effects pedals—I’ve always yearned to get my hands on the latest. From childhood on I’ve used a proven set of techniques and principles to guide the way I consume fresh information. The same techniques that helped me transition from a construction worker/dishwasher to a Netflix software architect are the same techniques I use today to upgrade from Babel 5 to Babel 6.

I'm not tired

Now on to JavaScript Fatigue specifically. JSF has relatively recently entered into the web developer’s lexicon. However it’s been a part of technical work for much longer. The difficulty of keeping up-to-date in our industry has been there for many years, but only recently has it become a social pressure. An in-depth exploration of the reasons for the rise of “JavaScript knowledge as fashion” are not in the scope of this article, but the drivers include:

  • Github’s socialization of code
  • Twitter being a key forum in which we examine our place in the industry
  • A rapid increase in salaries—and the subsequent gold rush of smaller-better-faster code jocks. This includes the me-first virus in our industry (see this)

Regardless of the causes, the following 6 principles are the cure for JavaScript fatigue that works for me:

  1. Automate, automate, automate. Any sites that you repeatedly visit for information should be automated as feeds via services like An example of doing this can be seen here.
  2. Eliminate all information inputs that are not essential to being the best programmer/manager/artist/human you can be. I follow something resembling an inverted Mad Max version of Pareto Principle here. If a Google Group, newsletter or Twitter user do not produce life-enhancing content to you at least 80% of the time, eliminate it. That Ruby on Rails user group that was really active in 2007 but it a shell of its former self? Unsubscribe. That high school buddy Bradley that was fun in 2003 but now posts 100% negative rants? Bye Bradley.
  3. Constantly replace your previous realms with new ones. If you’ve already covered following 100s of mobile development brothers on Twitter, try following some of the web development sisters. Learn about new areas of life from as many different types of people as possible! Default to saying yes, then revisit and say no aggressively. Say yes to trying new meetups, modules & software, but don’t stay too long if they’re not working for you after you’ve given it the ol’ college try.
  4. Ensure you’re constantly around experts in different but related fields. Contrary to popular wisdom, only associating with teammates that are focused on your realm can result in suboptimal performance as you will spend more time debating choices than making them and executing on them. On my team at Netflix, I’ve an author & former Digital Humanities Specialist from Stanford, a design-savvy D3 expert & a Data Scientist with a business degree around me at all times. We’re all multi-disciplinary and hold one another accountable, but defer to one another on the implementation details of our respective areas of expertise. I learn about new things—so do they—and we focus more energy on learning than arguing.
  5. Allow the wisdom of the crowd to lead you to treasure, but don’t let mob mentality dictate which gems you put in your rucksac to take back to camp. Crowd-sourced wisdom is o’plenty on the web and can be found at Product Hunt, by following key individuals on Twitter & by subscribing to the popularity feeds of Github.
  6. Never study when you’re fatigued unless you’re in-the-zone. Ensure your body and mind are primed to effectively take on new information. There’s no point in going through your info feeds when you’re too knackered to move any of the info into long-term memory. Physical health is deeply tied to mental health too—take walks in the sunshine frequently.

The Future of Editing JavaScript

I think the future lays in having an app like Visual Studio Code seamlessly integrate tools (Browserify, Travis et al) in an agile and open manner. This’d be much like what Slack did in combining Hubot-like hacker features to a user-friendly place. That’d bring the ease-of-use of something like Visual Studio, while also bringin the intelligent & agile hacker-friendly features from the Terminal.

Const(ant) Craving

“Humans avoid change unless they see immense and immediate personal benefit. const isn’t about personal benefit or immediate benefit. It’s about long term benefit to others—those that read your code.”

Prologue (before const)

While const has been available in both Chrome (20) & Firefox (13) since summer 2012, it didn’t become part of my core JS vocabulary until Mr. Schlueter announced Node v0.10 in the spring of 2013.
I’d seen const on MDN when I was still using Node v0.6, but:

  1. I wasn’t eager to fill my JS with the constraints I had when programming for iOS (types, static, private, et al)
  2. I was introduced to isomorphic JS early on and didn’t want to use transpilers for client-side code for what amounted to a minor readability aide

Why I Turned to const

In 2013 I started to not only use Node.js for important production apps, but I began preaching the good word of proper Node.js programming to Sony employees in both San Diego, USA and Tokyo, Japan. Being tasked with teaching, as well as producing modules that’d end up maintained by others, led me to reach for new levels of readability in my JavaScript code. My journey toward the ultimate readability lead to increased specificity in several areas of my code. Many of these were informed by things I read during my days as an iOS programmer. My colleagues at Sony had plenty of input as well. Examples include:

  1. Naming variables in such a way that, if entered into Google Translate, would make sense in another language. I was teaching Japanese developers that weren’t fluent in English, and this is just a good way to train yourself to write meaningful variables for folks that speak English as a first language as well!
  2. Always, always, always putting requires, constructors, prototype declarations, exports and other common statements in the same place in each module
  3. Taking (what I would call) full advantage of linters and style tools
  4. Endeavoring to unite approaches between client and server. This led to several new practices, but Browserify was perhaps the most important of those
  5. Creating or consuming documented modules for all repeated tasks. From checking if something is an Array, to connecting to a CouchDB instance, let’s keep things DRY, sharable & effortlessly learnable
  6. Most importantly, an overall guiding principle. That is, always side with code decisions that lead communicate more information over code decisions that decrease typing effort or simply impress others in their syntactic athleticism

Make Nostradamuses Out of Your Team (or how to write predictable code)

Nostradamus Yodamus
Number 6 above is where const comes in. Quite simply, var makes code harder to read (harder to predict) than const does. JavaScript developers have (unfortunately) often misused var by re-using pointers like it’s 1982 and they need to hoard them like Qualudes in Jordan Belfort’s basement. The result is, when you see foo somewhere, it’s pretty tough to know if it’s what it was when var foo = 'FOO' or something else it got assigned to somewhere else in your app’s codebase. With const, that’s not true. While that is a seemingly minor change, the culmination of using const everywhere that it’s appropriate is that your entire app is more predictable. It is, in part, for this same reason that using immutable data structures makes code more readable.

The Little Revolt (against constants in JavaScript)

Most JavaScript developers, even those at the top of our industry, have been using var exclusively for a long time. Thus, my practice of using const has met some resitance. And hey, it’s natural. Humans avoid change unless they see immense and immediate personal benefit. const isn’t about personal benefit or immediate benefit. It’s about long term benefit to others—those that read your code. Anyway, I’ve consistently heard a small set of arguments against using const. They are:

  1. What if I want to change the value later? I want my pointers to stay flexible
  2. const doesn’t freeze the object. That’s confusing!
  3. const is harder to type than var
  4. Won’t const fail on most browsers?

The Rebuttal

Each of those arguments / questions are unbelievably easy to address. In order:

  1. a) We don’t program for “just in case” b) You can create a new pointer or change const to let later
  2. That’s a fundamental misunderstanding of computer science / how memory works. Ignorance of the law is not an excuse ;)
  3. Really? If you will never have your code read by someone else, then feel free to save yourself 2 chars a line :)
  4. This is the most valid question. If you’re programming for Node, just use it. It works at least as far back as v0.6. Any remotely recent version of FF or Chrome supports it, but IE didn’t support it until 11. Now if you’re using any ESNext|ES6 features via Babel or related tools, you can certainly use const as well


Strict mode

It’s important to note that, in some JavaScript engines, you need 'use strict' to be off to use const, in some engines you need 'use strict' to be on! The good news is, your chosen JS engine will loudly let you know when this is the case either way.

To SyntaxError is to be human

In most engines const initially didn’t throw a SyntaxError when you attempted to reassign to the pointer! The assignment statement would return the value you attempted to assign as if it worked, but when you accessed the value the const actually points to, it’d be the original value.

(As)sign on the line

It’s specified that a const statement must contain an actual assignment, unlike let and var statements, which can be empty. In earlier implementations of Firefox’s Spidermonkey (and perhaps other engines?), an error was not raised when a const declaration didn’t end with a value assignment.

Hopefully this has explained why I have Constant Craving!
K.D. Lang

Falcor & why you should care about your Bithound score

Falcor has been extremely successful.

Falcor core was immediately considered one of the main JavaScript modules and it’s sister modules are well-liked as well. As part of helping Falcor be as successful as possible, I want to raise awareness of Bithound scores (which are already being used by the Falcor project), and point out why they matter.

What influences your Bithound score?

  • The security of packages used
  • Adherance to semver (Falcor doesn’t adhere)
  • (Up|Out)dated packages
  • Adherance to consistent style
  • Whether or not issues are addressed within a timely matter

  • Most everyone knows the above are important to the success of an open source module.

Weaknesses of the Bithound score (Falcor’s score should be higher)

While all of the above are important, they are less important (by far) for devDependencies than for dependencies proper. While Falcor locks down the few deps it has (this is shockingly rare but good on the Falcor team), dev deps are with the caret and some of the modules used are way out of date. In other words, I think the Falcor score should be higher than it is.

We should still improve the little things that matter

In terms of adherence to Node & NPM best practices however, Falcor core can improve. A quick comparison using Bithound.

Falcor Path Utils (another falcor project)

KeyKey (an insignificant project of my own)

Falcor core

Size is part of this, and stats aren’t everything. However, in my modules I’ve found a strong correlation between my maintenance of them and what the Bithound score ends up being.

I’m going to open some issues & PRs to address this, and I encourage other, both inside of Netflix and without, to do so as well.


A Better Source View in Chrome

JSONView has been one of the first things I ensure is installed in Chrome for years now. It adds interactivity and highlighting whenever you navigate to a JSON resource.
I wanted the same for JS, CSS et al and Sight fit the bill for that. Both extensions add CSS to JSON resources and they were initially conflicting. It turns out that
you can edit the CSS styling for JSONView (and the themes of Sight). By doing so I was able to get them to play nicely with one another.

Failure to Componentize (plus Stylescope & ModCSS)

Back in Aug 26 2015 I posted hopefully about the future of web components in Netflix’s Digital Supply Chain. Since then, all fans of the open web have sided with expediency (and therefore React). You can’t stop the mob’s forward march :). Seeing this coming a year ago, I offered Reactive Elements as the virtually cost-free way to bridge the gap ‘tween React and WC, but interop be damned I guess. The group recently had the joy of bringin’ on Tim Branyen from Bocoup—I hope he’ll help folks “see the light”.

Scoped CSS

As a side note, I’m developing an answer to one of the main open questions. It’s tentatively called Stylescope and serves as a more traditional (but versatile) companion to ModCSS.


ModCSS assists in modularizing styles by enabling CommonJS-like system to pull in Stylus or CSS files as JSON. The primary use so far in Netlix has been assigning to style in JSX.


Stylescope assists in modularizing styles by enabling one to reliably assign style information to an HTMLElement with 100% security that style won’t affect other elements. The pain of an Enterprise front-end developer attempting to add their own flair to a large CSS cascade is traumatizing and I’m here to prevent others from experiencing the same fate :)

Stylescope is early alpha, but it already works well for one-deep style trees in its Mochify tests. For next steps, I plan to demonstrate distributing and sharing styles via ModCSS and then consuming them in a Web Component via Stylescope. I’ll need to locate a module containing all viable HTML tags to implement parent-child style relationships in Stylescope…

Hello Japan

We changed a few things at to prepare for our new Japanese friends:

  • Image-Based Subtitles to support vertical text, furigana (rubies), bouten (emphasis). This also sets us up for subtitles in other languages that don’t use a Latin script
  • On-Screen Keyboard for Darwin (user selects kana, yielding kanji suggestions)
  • Search tokenizes input (no spaces in Japanese), normalize to two possible search scripts
  • Typographic differences (bold and italic not used)
  • Multi-Language box art
  • Metadata length
  • First / last name order in sign up
  • Studio Copyright attribution

Points written by Joubert Nel

Weberize ALL the components

Some folks in Netflix’s Digital Supply Chain have agreed that Web Components are a good interop container. I also (perhaps controversially) believe people should also use WCs whenever effective as it’s simply native to the web. Telling someone to not use WCs is like telling someone not to use document.querySelector or Array::forEach. The war against React zealots is treacherous and ongoing.

Asynchronous communication

I was at a company called Amco a few years ago. It was my first Senior position outside of running my own company. The VP of Engineering there (Jason King) taught us something he called “asynchronous communication”. It’s the concept that sharing information globally and digitally is more efficient than individually & physically. By sharing with more people, and in a way that they can respond as convenient to them, you optimize the quality and quantity of feedback you can receive. When everyone does this, it make everyone better. It definitely made me better and I think Netflix will get better if we all start practicing asynchronous communication. Ways we can do this are:

  • Remote pair programming tools that support multiple people
  • Google Docs
  • Frequent pull requests