‘Iacta alea est’
One of the themes that I’ve been trying to articulate on this blog is that we shouldn’t always assume that something has to be complex. And that this perceived complexity sometimes limits us, even if only in our own minds, from solving problems ourselves. We prefer to outsource the thought work without realising that adopting the thinking of another we end up thinking more than we would have thought if we had done the thinking ourselves.
One of the contributing factors in this sorry dance is that we are not well acquainted enough with the primitives that act as the building blocks for simpler solutions.
The author of the framework has two posts on the Crank website. One details the inception and rationale behind the framework and the other builds the framework step-by-step from scratch.
That the whole framework can be reproduced within the contraints of a blog post gives an indication of the simplicity that is at play.
What’s most interesting to me is the honest confession at the beginning of the first post, one with which I can strongly identify.
I will be honest. Before embarking on this project, I never considered myself capable of making a “web framework.” —Introducing Crank
In our minds we separate the authors of frameworks from ourselves, defaulting to the (understandable) assumption that if someone has written a framework they then belong in another, more premier league.
Then there comes a moment at which the Emperor is no longer wearing any clothes, and all it takes is a moment of lucidity to realise it, and then the courage to call it out.
over time, I grew increasingly alienated by what I perceived to be the more general direction of React … each new API felt exciting, but I disliked how opaque and error-prone the concrete code written with these APIs seemed
Rather than thinking critically about each new feature, these libraries seemed eager to mimic them for purposes of compatibility … it was the API itself that needed fixing.
The author then goes into detail about how React’s Suspense API made no sense to him after diving into the details. This prompted him to relise that one of React’s fundamental assumptions, that rendering should always be ‘pure’, was in fact the source of a lot of complexity.
He then did some experiments on his own, without this dogmatic assertion, lifting that constraint. And then came the epiphany.
The entire React lifecycle, all of the
componentDidWhatmethods, everything which React was trying to do with classes and hooks and state and refs, all of it could be expressed within a single async generator function.
And the key is that:
There is a sense of inevitability. That the solution is not designed but unearthed. A greater attention has been applied to the primitives, together with a critical return to the original goals.
This is a good example of arriving at simplicity in the wild.
—Monday 3rd March 2021.