ReasonML and React

I’ve always loved programming. My first language was Basic on the Commodore 64. Later I picked up VBScript, VB, Javascript, ABAP, Ruby, and a bit of Java.

At Relay Graduate of Education, where I was CTO from 2013 to 2015, we used PHP, and specifically the Symfony framework. The conventions of Symfony coupled with its MVC pattern eliminate some, though not quite all, of the chaos and noise endemic to PHP.

I learned a lot at Relay. One important lesson I learned was that especially in smaller organizations like Relay CTOs really must allocate some of each week – I’d estimate 20% is about right – to hands-on development. CTOs shouldn’t expect they’ll be able to “out code” full time developers who spend all day coding. But for myriad reasons – not least of which is credibility – CTOs must be able to code in the languages and frameworks of the organizational tech stack.

I came to Relay right from Deloitte, and while my experience delivering large scale programs at Fortune 500 technology and media companies had taught me a lot, it had been a long time since I had done much hands-on development, and I had never developed in PHP anything but “Tinkertoy” practice projects. While reading our code, evaluating data structures, was never an issue, writing PHP code was not an area where I could lead by example. I was keenly aware of this deficiency. My team, I’m sure, picked up on my lack of sure footedness. I regretted this and I think I was a less effective leader as a result.

So after I left Relay, believing (as I do now) that those who will do best in this economy are those who are at once deep technologists AND deep strategists, I committed to filling what I thought were gaps in my formal computer science education.

Through my ongoing work in CS Education I had become aware of the popular CS50 MOOC from Harvard University offered through Coursera. But rather than take the free Coursera version, I elected to enroll directly through the Harvard University Extension School, which cost me a couple thousand dollars in tuition, but also earned me 4 graduate credits in CS and access to the professor and TAs like any other Harvard CS student. After successfully completing CS50 in May 2016, I decided to continue on and take CS61, a deep systems programming class in C and x64 Assembly in which I did projects like building my own shell and developing a virtual memory page allocation routine.

After CS61 I still had a taste for something more and decided to take CS51, “Abstraction and Design in Computation”, which probably could be just as aptly titled “Functional Programming in OCaml”. CS51 was a complete flip from CS61. CS61 was deep down in the guts of the computer, dealing with registers and low level I/O. CS51, by contrast, seemed in the ether of math and higher order functions. And OCaml presented a totally foreign syntax, at least at first.

But once I started to tune in, once I opened my mind to a new way of approaching coding, the combination of succinctness and expressiveness blew my socks off. Here, for example, is the idiomatic solution to Euclid’s algorithm in OCaml:

let rec gcd a = function
| 0 -> a
| b -> gcd b (a mod b);;

The essential idea in functional programming is that everything is an expression and expressions evaluate, via substitution rules in line with the Lambda calculus, to values. That made a ton of sense to me. So too did the did ideas like map, filter, reduce, immutable state, currying, etc. Perhaps most importantly my exposure to OCaml left me convinced that static typing is the way to go — as Yaron Minzky of Jane Street, the largest institutional user of OCaml (though Facebook is catching on fast) says, a whole class of errors just go out the window with a type system like OCaml’s.

Back to Relay for a moment – one of the last projects during my tenure was a bake off between the two most dominant Javascript frameworks, Angular and React. We ultimately chose Angular but I liked what I saw in React and kept abreast of it in the time since, developing some projects of my own using React. During that time React’s popularity has grown a ton.

So when as I was doing my final project in CS51, a meta-circular OCaml interpreter, and heard about ReasonML, “a new syntax and toolchain” for OCaml that makes OCaml a bit more accessible syntactically to developers coming from languages like Javascript, I was intrigued. But when I really got excited was when I learned it was some of the same team building ReasonML that work on React.  Thanks in large part to a transpiler from OCaml to Javascript developed at Bloomberg called Bucklescript, ReasonML is now a great way to build React applications as among numerous other benefits, ReasonML brings to React the full power of the OCaml type system. And as context, React was originally prototyped in a cousin and antecedent to OCaml, so this – React using OCaml (ReasonML) – is full circle and back to its roots for React.

There are numerous videos and tutorials out there about both ReasonML and using ReasonML with React (and React Native). If you’ve developed apps in React, I suggest you give it a try. There’s a learning curve at first for sure, but soon enough you’ll get the hang of it, and the OCaml type system coupled with capabilities like match (renamed “switch” in ReasonML) will make you a convert.

If you’re already pretty comfortable in FP, especially OCaml, and have some React in your bag, this YouTube video of a recent lecture by Jacob Bass is great. If you need a more gentle introduction, check out this ReasonReact tutorial by Jared Forsyth. Also check out the official ReasonML and ReasonReact documentation of course too. And the support from the ReasonML community on Discord is incredible.

ReasonML is still new and there are still rough spots here and there, especially when using it for production class systems. But it’s gaining momentum fast and has big companies behind it, along with a whole bunch of developers who know of course that Javascript is the lingua franca of the browser but would like to have an alternative with static typing for front end development in particular. ReasonML, which can be compiled down to Javascript via Bucklescript, is just that.

Here’s to Reason!

The Fierce Urgency of Now

Earlier today I attended a stakeholder and planning meeting for “The Campus”, the “first technology and wellness hub at a public housing site in the United States.”

Our meeting was at the Howard Houses in Brownsville, Brooklyn. It’s in the Howard Houses that The Campus operates. Brownsville and public housing projects like the Howard Houses have been largely left behind by the surge of investment (and gentrification) in Brooklyn in the last 15-20 years. Brownsville still suffers today from high levels of crime, violence, and poverty.

A key goal of “The Campus” is to provide opportunity to young people, especially young men and women of color who live in public housing. It is hoped that through technology, especially computer science, as well as programs in entrepreneurship and wellness, that we can provide youth the hope, confidence, and career skills with which to turn lives and communities around.

Tragically for one man our work came too late. About twenty minutes before the start of our meeting Rysheen Ervin, 28, still with a whole life ahead of him, was shot immediately outside our meeting room and only a few more feet from a public school. The man died of his wounds. The shooting was witnessed by my friend State Senator Jesse Hamilton, sponsor of The Campus. Senator Hamilton recorded this powerful video immediately after the shooting. This violence had a deep impact on everyone in attendance, including me.

At last week’s CSForAll Summit at The White House a key theme was broadening participation and making sure the “For All” in CSForAll is not just a platitude. On Thursday Mayor Bill De Blasio will give his one year update on New York City’s CSForAll initiative. During his speech we can expect to hear much about the city efforts to keep the “For All” in the forefront.

To complement and magnify CSForAll and the work of its foundation partner CSNYC, Borough President Eric L. Adams (also a sponsor of The Campus), his staff, myself, and a number of non-profit and private sector partners, put together CodeBrooklyn last year. The purpose of the CodeBrooklyn campaign is to champion the expansion of computer science and STEM in our schools, especially in communities like Brownsville, with the goal of establishing computer science in every Brooklyn school in 7 years — 3 years ahead of the city target. We’re still in the early days, but last year were able to help get over 80% of Brooklyn schools to participate in Hour of Code.

Senator Hamilton is a key supporter of CodeBrooklyn. Senator Hamilton held one of the first hackathons in Brownsville last year. Another supporter of CodeBrooklyn is City Councilmember Laurie Cumbo, who at a CEC 13 meeting in October 2014 literally jumped onto the stage at PS 307 to join CSNYC board chair Fred Wilson to give impromptu, moving testimony about the civil rights case for computer science.

The fight for civil rights brings to mind Dr. King. The death of this man, Mr. Ervin, literally before the eyes of those gathered to plan for The Campus, gave new relevance to these words of Dr. King:

“We are now faced with the fact, my friends, that tomorrow is today. We are confronted with the fierce urgency of now. In this unfolding conundrum of life and history, there is such a thing as being too late. Procrastination is still the thief of time. Life often leaves us standing bare, naked, and dejected with a lost opportunity. The tide in the affairs of men does not remain at flood — it ebbs. We may cry out desperately for time to pause in her passage, but time is adamant to every plea and rushes on. Over the bleached bones and jumbled residues of numerous civilizations are written the pathetic words, ‘Too late.'”

For the man murdered today,  and his murderer perhaps as well, we were “too late.”

Let me be clear – computer science education is not a panacea to all of our nation’s problems. The challenges in communities like Brownsville – or McDowell County in West Virginia – are a Gordian knot that can not be swept away with a couple lines of JavaScript. But our commitment to inclusion and participation in computer science education is a right and important first step in creating new opportunity for communities that the economy has left behind.

And so let us resolve to act, in the memory of this man killed today at the Howard Houses, with Dr. King’s “fierce urgency of now”. Let us never be “too late” again.

Code Syntax Compared

A friend of mine is getting into coding. He was asking me a bit about what language to learn and how they are different. He was curious about functions in particular.

To show him the differences I decided to write a very simple program to calculate the area of a triangle in 5 different languages. Each program is run at the command prompt. I tried to write the program in more or less the exact same way, somewhat ignoring a couple conventions in order to make each program as identical to the others as I could.

#run at command prompt with python

def triangle_area(base, height):
    area = (1.0/2) * base * height
    return area

a1 = triangle_area(10, 2)
print a1


#run at command prompt with ruby triangle.rb

def triangle_area(base, height)
   area = (1.0/2) * base * height
   return area

a1 = triangle_area(10, 2)
print a1

For all the Ruby (and Rails) vs. Python (and Django) debates, these two languages look nearly identical in these examples. That doesn’t hold true forever, though. The main difference is that Python starts the function definition (the inside of the “black box”) with a colon. The function ends when the code is no longer indented – white space matter a lot in Python compared with other languages. Ruby on the other hand does not use the colon and ends the function instead with “end”.


// triangle.js
// run at command line with a program such as node – e.g., node triangle.js

function triangleArea(base, height) {
   var area = (½) * base * height;
   return area;

var a1 = triangleArea (10, 2);

JavaScript, in part due to its history and orientation to the web, does printing to the prompt a bit differently.



// triangle.php
// run at command prompt with php triangle.php

function triangle_area($base, $height)
      $area = (½) * $base * $height;
      return $area;

$a1 = triangle_area(10, 2);
print $a1;
print “n”;


Many people think PHP is ugly. I think it’s the dollar signs and question marks. Somehow it feels cheap and uncertain.


Must be compiled first 
Run at command prompt javac
Then run java Triangle

class Triangle {

public static double triangleArea(double base, double height)
         /** Need 1.0 to get calculation to work right – indicates double **/
         double area = ((1.0/2) * base * height);
         return area;

public static void main(String args[]) {
      double a1 = triangleArea(10.0, 2.0);
      System.out.println(a1 + “n”);


This is the only example that needs to be compiled. Complied languages generally run faster and programming in languages that need to be compiled is sometimes seen as “harder core”, though that’s a somewhat outdated view. Remember – right tool for the job!

I’ll do this again soon .. maybe adding R to the mix.