The Hilarious Misadventures

Of Being a Platform Downstream From Your Language

With your host

@MylesBorins

NordicJS 2017

Hej!

My Name is Myles

itsa me!

I am gainfully employed by Google as a Developer Advocate

Focusing on the Node.js ecosystem and GCP

Google Cloud Platform
The opinions expressed in this talk are solely my own

once upon a time in

Brendan Eich

created the language

mocha

in 10 days

Four months later

it was renamed

LiveScript

Two months later

it was renamed

JavaScript

Over the next two years

The language was standardized

as ECMASCript

At ECMA International

European Computer Manufacturers Association

Wait is it actually called ECMAScript?

classic dank meme

Does that make JavaScript

ECMAScript's Monster?

ECMAScript is the standard

JavaScript is an implementation

*cough* so was ActionScript 3 *cough*

Today we have many implementations

In Chrome

There is V8

In Edge

There is Chakra

In WebKit (Safari)

There is JavaScriptCore

In Firefox

There is SpiderMonkey

They are all implementation of

ECMA-262

The ECMAScript® 2017 Language Specification

Let's talk about Node

It was created by Ryan Dahl

First presented at JSConf.eu 2009

Node.js has never implemented JavaScript

It inherited it

It was bootstrapped by embedding

The V8 engine

We get the language features

Of the embedded version of V8

This was one of the contentious point in the io.js fork

We are now actively updating V8

Which in turn

Updates the language features offered in Node.js

A Practical Example

In Node.js v7.7.0

We updated V8 to 5.5

With it came async / await

­čÄë

This in turn made it clear

We needed better promise support

Which in turn

Lead to util.promisify

in 8.0.0

Which in turn required massive refactoring

To Domains

Which are technically are deprecated

but we don't have a better solution

It also resulted in problems with

Post mortem debugging

For uncaught exceptions

Because Node.js has made a lot of assumptions

Regarding Callbacks

As the language evolves

We have to keep up

Taking a step back

how is language babby formed

The Spec is

ECMA-262

The Committee who implements it is

logo for tc39

The committee meets

every other month

At locations around the world

The participants include

Can Anyone Join?

What is a Member?

What is a Delegate?

How does a feature get developed?

Consensus

The Stages

  • Stage 0: strawman
  • Stage 1: proposal
  • Stage 2: draft
  • Stage 3: candidate
  • Stage 4: finished
  • test262

    A feature can only move

    one stage per meeting

    Every year

    A new version of the specification is published

    Although some people like to think of the github repo

    As a living specification

    similar to how the HTML specification works

    spec definition of null
    spec definition of isArray

    JavaScript Engines

    Implement the Specification

    BUT

    Think of the spec as another implementation

    Does that make ECMAScript

    JavaScript's Monster?

    logo for tc39
    ecma262
    twitter bot

    V8 has a C++ API

    Used by Node and Native Module Authors

    The compiled code relies on an

    Application Binary Interface

    Semver Minor Changes

    To the V8 API

    Can Create Semver Major Changes

    To the compiled ABI

    This means updating V8

    Is Semver Major

    Which limits us to 2 upgrades a year

    This also means that code compiled with one major version of node

    Will not work

    With another major version

    This is independant of tracking changes in the V8 API

    Which could break all the native modules

    At an implementation level

    The initial attempt to solve this was

    NAN

    Native Abstractions for Node

    NAN offers an intermediate API to write against

    So that changes to the V8 Api

    Don't break your code

    This didn't solve the ABI Problem

    Enter the N-API

    The N-API is an ABI stable abstraction

    Meaning updates to the V8 ABI

    Don't break your native code

    If the ABI is stable

    other engines can shim against it

    Now you can use any engine in node

    N-API is shipping as experimental in 8.x

    There are a lot of moving parts

    We are trying to build abstractions

    so you do not need to understand everything

    We do this work so you can focus on your product

    rather than getting lost in the tools

    Thank You

    a surfing puppy

    @MylesBorins