All posts

Reason mobile cross-compilation deep dive

January
23,
2018
android,
ios,
ocaml,
reason

I recently released a tool that will manage all of this stuff (see the accompanying blog post), but I figure it's good to document what I went through for future ocaml cross-compilation spelunkers.

7 minute read

Making a cross-platform mobile game in Reason/OCaml

January
13,
2018
android,
ios,
game,
reason

I launched the first cross-platform mobile native game written in Reason a few weeks ago 馃帀, to the Android and iOS app stores, with a free web version and a macos desktop bundle (source code all on github).

Getting there required lots of fiddling with cross-compilers and build systems, and so I made a tool that will take away much of the pain involved, so you can get started immediately and get your game into the world. NB: This is still super experimental but I'm really excited about it and want to get y'all in on the fun.

4 minute read

Building async/await in Reason

December
30,
2017
await,
ocaml,
reason

Lots of people have come into the discord channel asking about how to elegantly deal with async things. We've got Promise.then_ and good old callbacks, but having a syntax like async/await can really make things nicer when you have a lot of async going on. So far in the web clients I've made, there hasn't been enough asynchrony to really feel that pain, but I thought it would be an interesting challenge to tackle anyway.

7 minute read

Advanced ReasonReact: Higher Order Components

November
12,
2017
react,
reason

After jumping into ReasonReact, I soon came to the question "How do I do higher-order components?" I had some duplicated logic in several components regarding data fetching, and I wanted to use this familiar React tool to refactor.

To illustrate, we'll be making a "fetches something from the network" wrapper component. We'll start with a "mixed component" that we'll then try to refactor.

5 minute read

A ReasonReact Tutorial

July
5,
2017
react,
tutorial,
ocaml,
reason

Are you a big fan of React, and want to know more about Reason/OCaml? I made this for you!

This tutorial was updated on Nov 8, 2017 for the new "v3" syntax of Reason.

Reason is a project that adds a JavaScript-style syntax and a bunch of conventions and tooling to OCaml. The goal is to make this awesome language, with its powerful type system and robust multi-platform compiler, accessible to a broader audience. It's backed by the good folks at Facebook who invented and built React, and so naturally having best-in-class React interop has been a high priority.

This tutorial aims to give you a nice introduction to the syntax and type system of Reason, through the ReasonReact library. We'll be building a simple Todo list application.

Read more

When will ReasonML be ready?

June
23,
2017
ocaml,
reason

Someone came into our discord channel a few days ago asking "Is Reason suitable for migrating a large production JavaScript codebase incrementally?" I answered "Yes, but wait 6 months."

What's the current status? At the moment, we're mostly in the realm of "enthusiasts who are OK with being on the bleeding edge, and want to help build out the foundation in their spare time."

4 minute read

Template-based macros in Reason/OCaml

June
20,
2017
macros,
ocaml,
reason

A couple of people have shown up in the discord channel asking whether Reason has macros, and the answer is "sort of." I think we can do better.

6 minute read

Your first native Reason/OCaml project

June
17,
2017
tutorial,
ocaml,
reason

I just wrote my first Reason project that compiled to native, and you can too! Luckily for you, my first native project was a cli tool to help people get started with native Reason development 馃檶.

5 minute read

Getting Started with Reason and BuckleScript

June
3,
2017
ocaml,
reason,
javascript

A couple of people have asked me how to get up and running recently, so I thought I'd put something together. If you're looking for a "just clone this repo & go", here's a very simple boilerplate I put together for this post, or you can check out the reason-react-example repository.

3 minute read

JavaScript Interop with Reason and BuckleScript

June
3,
2017
tutorial,
ocaml,
reason,
javascript

So you're all ready to write some Reason but you need to call a JavaScript function? Or maybe you can't figure out how to write something in OCaml-land and wish you could just bail for a minute & write it in JavaScript? Fortunately, both of those are fairly easy to pull off.

8 minute read

Detecting unused styles in JavaScript with `babel-traverse`

April
8,
2017
tooling,
babel,
javascript

Last week, my coworker Charlie asked what it would take to automatically detect and purge unused aphrodite styles in our codebase.

If asked 2 years ago, I probably would have gone with a regex and a string-munging python script, but I'd just spent the past few nights messing with babel plugins, and figured I could probably get pretty far with relatively little work. As it happened, I was impressed by how easy it was using the tools that babel provides.

As a bonus, it also works with React Native because they have the same API, and it could probably be extended to other libraries without too much work.

7 minute read

What Holds Me Back From Clojurescript

November
26,
2015
javascript,
clojurescript,
clojure

I've expressed multiple times that I really want to get into clojurescript, but I keep running into barriers.

My background: I'm an experienced JS dev, and for my personal projects I use the latest & greatest of React, Flow, Babel, and Webpack, which makes for a pretty rocking experience. Given my background, lots of my hesitation could just be the fact that staying in my comfort zone of javascript is easy, though it may be far less simple than the experience provided by clojurescript.

By the end of this post, I hope I will have convinced myself to face my fears and dive into clojurescript anyway :D

10 minute read

Visualizing Reactive Streams: Hot and Cold Observables

March
6,
2015
react,
rxjs,
javascript

Reactive Programming is getting a lot of attention these days, and it promises to reduce frustration, bugs, and greenhouse gas emissions. Unfortunately, there's a sizeable learning curve involved while you try and get your head to think in streams instead of imperative sequential processes.

5 minute read

Rust compiling rust: adventures with librustc

November
22,
2014
notablemind,
compiler,
rust

For the web-based everything notebook that I'm working on, I've been writing backend hookups to various programming REPLs, including IPython and Gorilla. I wanted to be able to evaluate rust code as well in this notebook environment, and so I set about writing a simple server that would compile up a string in rust when asked. This proved do have a couple of gotchas, so I thought I'd air my thoughts here.

4 minute read

Switching from Ghost to Hexo

July
26,
2014
blog

My blog used to use Hyde, a python clone of the popular jekyll platform. When Ghost came out, I quickly switched over, due in main part to the great editor and beautiful themes. I used buster to serialize the blog so that I could still serve it as a static site. I had two main regrets, though. 1) using buster to scrape ghost was a hack. 2) My posts were locked in an sqlite db, where git could only do a binary diff.

0 minute read

The Hexo static blogging engine gets an admin UI

July
26,
2014
blog,
announce,
react,
javascript

I recently switched from ghost to hexo, and the biggest thing missing for me was the editor interface. So I made one. Currently, it's mostly a clone of the Ghost interface, but I have some ideas for making it even more awesome.

1 minute read

Rust vs Go

March
22,
2014
golang,
rust

Go and Rust seem like natural competitors. They are both trying the role of a C-like low-level language with modern affordances, safety, and nice, clean concurrency. And they're each backed by a major player in the browser race - go by Google, rust by Mozilla.

5 minute read

First Impressions of Rust

March
20,
2014
simulation,
art,
rust

A while ago, I made a cellular automata simulator in Go, inspired by this video about a "rock, paper, scissors" simulation, where there are three "species" of cells which consume each other.

Last week I rewrote this in Rust

1 minute read

The Noble Perceptron

January
29,
2014
tutorial,
machine learning,
javascript

The perceptron is one of the most primitive learners, and is also of the easier ones to understand intuitively. I'll first give some background, and then an animation in javascript with 2D data, and an implementation in python, with graphs of it running on some traditional datasets.

6 minute read

Photon Ray Tracing

January
20,
2014
announce,
javascript,
art

A few months ago I saw @scanlime's "Zen Photon Garden" on hacker news, and was really impressed. In short, you draw walls/mirrors with your mouse, and it ray-traces light from a central source. Very beautiful and "zen". However, as a programmer, drawing lines by hand was far too inaccurate. So I forked it and added a scriptable interface for adding walls.

0 minute read