Categories
Backend JavaScript Node.js

Node.js 8: async/await Goes Native

Node.js 8 is shipping with full async/await support natively, no Babel required. This is the culmination of a multi-year journey from callback hell through Promises to finally having sane async code. But shipping async/await doesn't mean Node.js codebases suddenly become clean—migration is the hard part.

What's New

Node.js 8 includes V8 5.8, which supports async/await from ES2017. You can write this code without any build step:

const fs = require('fs-promise');

async function readConfig() {
  try {
    const data = await fs.readFile('config.json', 'utf8');
    return JSON.parse(data);
  } catch (error) {
    console.error('Failed to read config:', error);
    throw error;
  }
}

async function main() {
  const config = await readConfig();
  console.log('Config loaded:', config);
}

main().catch(console.error);

This is dramatically cleaner than callbacks or even raw Promises. The code reads top-to-bottom, errors propagate naturally, and debugging actually works.

Categories
Async Programming JavaScript RxJS

Observables: The Async Evolution Beyond Promises

Observables are at Stage 1 in TC39's standardization process, meaning they might become part of JavaScript eventually. RxJS implements them now, and Angular 2 adopted them for HTTP and events. The question is whether Observables are genuinely better than Promises or just more complex.

After using RxJS with Angular 2, I think the answer is: both.

What Observables Are

Categories
Async Programming JavaScript Language Features

async/await: The Async Revolution Coming to JavaScript

async/await reached Stage 4 this month, meaning it's officially part of the next ECMAScript version (ES2017). After years of callbacks and promise chains, JavaScript finally gets syntax for asynchronous code that reads like synchronous code.

This isn't hyperbole—async/await is the most significant JavaScript language feature since Promises.

The Problem async/await Solves