Design by manipulating mock code

You should build API writing mock code, and manipulate said code until it feels natural. When you don't have the contraints of the backend is when you can really be creative. Start from first principle and then elaborate. I can spend weeks going over and over details of API. And you should because every improvement you make to an API pays huge dividends.

Doing so you should Constantly share progress on your API code

Let us take the case of aesara and the looping primitive, Scan. The basic building block of aesara is the Op: an object that transforms variables into other variables. While it is tempting to copy JAX's interface we still want to make the Ops salient. So without worrying a second about how things were going to be implemented I just worried about what we would like to have and ended with:

import aesara

loop = aesara.while_loop(cond_fn, body_fn)
last_value, acc = loop(initial_value)

scan = aesara.scan(body_fn)
last_value, acc = scan(initial_val, sequence)

This should be done at the same time as implementing what is conceptually correct.

Links to this note