Read a file with promises in TypeScript on Node

import * as fs from “fs”; import { promisify } from “util”; const content: Promise<string> = promisify(fs.readFile)(“path/to/the/file”, { encoding: “UTF-8” }) I am tired of looking that up over and over every time I want to read a file into a promise in Node using TypeScript, so here it is. Next time, bring me here, Google. The promisify call turns fs.readFile from a callback-based method to a promise-based one. promisify accepts …

Read moreRead a file with promises in TypeScript on Node

In defense of rationality and dynamic programming

Karl Popper defines rationality as: basing beliefs on logical arguments and evidence. Irrationality is everything else. He also defines comprehensive rationality as: only logical arguments and evidence are valid basis for belief. But this belief itself can only be accepted by choice or faith, so comprehensive rationality is self-contradictory. It also excludes a lot of …

Read moreIn defense of rationality and dynamic programming

Systems and context at THAT Conference

It’s all that THAT Conference is not THOSE conferences. It’s about the developer as more than a single unit: this year, in multiple ways. I talked about our team as a system — more than a system, a symmathesy. Cory House said that if you want to change your life, change your systems. As humans, our greatest power …

Read moreSystems and context at THAT Conference

Understanding Promises in JavaScript (with yarn and Legos)

TL;DR: creating a Promise splits off another path of execution, and the Promise object represents the end of that path. Calling .then adds code to the end of that path. You can think of your program’s execution as following a piece of yarn. this video illustrates the difference between a synchronous program and the same program …

Read moreUnderstanding Promises in JavaScript (with yarn and Legos)

Functional principles come together in GraphQL at React Rally

Sometimes multiple pieces of the industry converge on an idea fromdifferent directions. This is a sign the idea is important. Yesterday I spoke at React Rally (video coming later) about theconfluence of React and Flux in the front end with functionalprogramming in the back end. Both embody principles of composition, declarativestyle, isolation, and unidirectional flow …

Read moreFunctional principles come together in GraphQL at React Rally

An Opening Example of Elm: building HTML by parsing parameters

I never enjoyed front-end development, until I found Elm. JavaScript with its `undefined`, its untyped functions, its widely scoped mutable variables. It’s like Play-Doh, it’s so malleable. And when I try to make a sculpture, the arms fall off. It takes a lot of skill to make Play-Doh look good. Then Richard talked me into …

Read moreAn Opening Example of Elm: building HTML by parsing parameters

Left to right, top to bottom

TL;DR – Clojure’s threading macro keeps code in a legible order, and it’s more extensible than methods. When we create methods in classes, we like that we’re grouping operations with related data. It’s a useful organizational scheme. There’s another reason to like methods: they put the code in an order that’s easy to read. In …

Read moreLeft to right, top to bottom