Skip to content

Instantly share code, notes, and snippets.

@junosuarez
Created February 5, 2016 03:11
Show Gist options
  • Save junosuarez/17f7031116f929b5955f to your computer and use it in GitHub Desktop.
Save junosuarez/17f7031116f929b5955f to your computer and use it in GitHub Desktop.

One could imagine a version of Node built on a hypothetical JavaScript-sans-Arrays. In such a world, packages would have to invent array types for themselves. The lingua franca array would be a number-keyed object, and packages would have to downcast their interpretation of arrays down to number-keyed objects at their thresholds. If a package missed doing this, their definition of an array would leak into calling packages. What if contemporary arrays were introduced into this ecosystem? At some level, they're still just sugar for objects-with-numeric-keys; but they'd have the potential to give packages a global interchange datatype for arrays. At the very least users would start passing them between packages. They'd expect native Arrays to work. Eventually there would be pressure on core to adopt the native Array. Would we do it?

The result of the above hypothetical is not that arrays replace objects, it's that native Arrays replace ad-hoc definitions of arrays. Native Arrays standardize the interchange format. Similarly, exposing native Promises from core doesn't replace callbacks, it standardizes promises. Only core can do this, because core is the ultimate well from which asynchrony springs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment