Posted on

Getting productive with selection and navigation in Emacs

This post is intended to primarily benefit people coming from other, so called “modern” editors to Emacs. Emacs veterans are likely to find most of the tips here very elementary.

I have observed that many programmers habituated to newer editors have many implicit assumptions about editing workflows which simply don’t hold true within Emacs environment and this prevents them from being productive to the fullest extent.

This post primarily focusses on how getting familiar with the concept of marks and regions in Emacs can result in productive workflows. These concepts, coupled with a few extensions can enable much more pleasurable code-editing workflows not easily achievable in more prevalent “modern” editors.

Continue reading Getting productive with selection and navigation in Emacs

Posted on

Javascript Async/Await with arbitrary Thenables

Usage of C# inspired async/await syntax (Now a stage 4 proposal) is now fairly mainstream in javascript, and native support is available in major browsers and Node.

Most of the times we await on promises (typically returned from async functions), however, it is relatively less well known that await works on arbitrary thenables. By thenables we mean any object with a then function member.

This post covers this usage, and explores some scenarios where it can be interesting.

Continue reading Javascript Async/Await with arbitrary Thenables

Posted on

Exposing slots in layout containers through shared refs in React

React refs are generally considered an anti-pattern as their usage typically encourages patterns which go against declarative compositon and top down flow of data.

This post explores a somewhat uncommon use case where refs can be used to expose layout slots in parent components to nested components.

Continue reading Exposing slots in layout containers through shared refs in React

Posted on

ReasonML vs TypeScript – First impressions

This post summarizes preliminary observations while comparing ReasonML and TypeScript during selection of a reasonably (pun-intended) type safe language for frontend development. The observations here are somewhat biased in favor of experienced javascript developers and focusses primarily on frontend development workflow and does not take into account the (primary) native backend of Reason.

While this post primarily compares Reason and TypeScript, much of what is outlined about TypeScript equally applies to flow as well.

Continue reading ReasonML vs TypeScript – First impressions

Posted on

Typescript and validations at runtime boundaries

Typescript team has explicitly stated that they don’t intend to extend typescript’s static type checking to the runtime.

Typescript Design Goals lists the following in the section on Non-goals:

Add or rely on run-time type information in programs, or emit different code based on the results of the type system. Instead, encourage programming patterns that do not require run-time metadata.

While on one hand this design goal is advantageous in that the output generated by typescript is very close to what hand written javascript would have looked like. And the runtime cost of typescript remains close to zero, therefore adoption of typescript does not alter performance characteristics of an application.

However, this also implies that for cases when static typing cannot help us we need to separately write validators using a validation library (eg. Joi) which has to be kept in sync with the typescript types.

This post outlines an approach to eliminate this redundancy using the io-ts library by Giulio Canti. This approach has also been adopted by some other libraries like MobX State Tree.

Continue reading Typescript and validations at runtime boundaries

Posted on

A Vagrant+Docker based workflow for clojure web development

This post outlines a container based development workflow using Vagrant and Docker.

Many common docker tutorials (eg. the official node tutorial) suggest a workflow where projects source is copied onto the image, which is then built and run through docker. This approach is not really practical for clojure development as normal clojure programming leans heavily on rapid prototyping and REPL driven development.

The setup below utilizes Vagrant and docker volumes to setup a development environment which ensures reproducibility and container isolation while retaining the short feedback cycle which clojure developers take pride in.

Continue reading A Vagrant+Docker based workflow for clojure web development

Posted on

Redux-loop: A better solution for managing asynchronous operations in redux

The lack of support for asynchronous operations in redux core has spawned a whole ecosystems for managing side-effects [1] in Redux.

This post argues that the redux-loop library (1.5 k ★ as of this writing) is a much better solution for this job than other more popular alternatives like redux-sagas (11.8 k ★) and redux-thunk (7.8 k ★).

As has always been prevalent in frontend ecosystem, popularity  does not necessarily translate to better suitability.

Continue reading Redux-loop: A better solution for managing asynchronous operations in redux

Posted on

Using helm to select tide completion candidates

Tide (TypeScript Interactive Development Environment for Emacs) uses a custom hydra-derived popup menu for prompting the user to select candidates when there are many completion options available.

However, this is jarring when the rest of your emacs environment is configured to use helm as the completion engine.

Fortunately, this is easy to fix by overriding the tide-popup-select-item implementation to use a custom helm source derived from the completion list.

Continue reading Using helm to select tide completion candidates