The Solution Space
Tags: performance, functional, space, story
Published: 2022-05-27 17:35:15

Long after the human extinction, two factions of sentient robots fight for supremacy over a specific region of Space. This region is known as...

## The Solution Space

Picture a region of space crammed with brutal constructions and artifacts of massive complexity. Now project that over time and superimpose a war for total domination and you'll get a picture of what the Solution Space looks like.

A vast and chaotic expanse of assorted debris, of good intentions and broken abstractions.

In this space wasteland you'll find the Iteratrons and the Recurcyborgs. To the untrained eye, both look like 70's sci-fi robots but once you get to know them you'll learn they are sworn enemies.

## What's next?

The Iteratrons are obsessed with performance and profess the creed that fast code is written once and maintainability is futile.

When you look at a typical Iteratron you'll see wires sticking out of places and connecting to weird and uncomfortable parts. They wear these hardcoded (or is it "hardwired") hacks with pride as a sign of optimization, the ultimate goal.

When they are feeling stressed and want to relax they unwind their loops and inline their functions to avoid wasting time in outrageous stack frame pushes.

They are exhaustive and eager and approach problems head on. Given a list of chores, they always pick the first one, do that, then look at the second one and do that, and so on. Sequencing is an integral part of their beings.

Occasionally they glitch and, given a list of chores, they pick the first one, do that, then pick the first one, do that, you see where we're going right? Other times, after they are done with the chores on the list, they keep picking tasks that are not there and end up doing incomprehensible nonsense.

They fly through space in makeshift ships, soldered and wired together for no apparent reason. Like a big collage of heavily optimized pieces that when combined de-optimize the whole.

You can always tell where Iteratrons have been because they leave a trail of leaking abstraction fluid behind them.

## Behead and repeat

The Recurcyborgs are the opposite of your typical cyborg, they are stylized and modular. They actually wear clothes and they store those neatly _folded_ when they are not using them.

Recurcyborgs suffer from an acute case of fractality which makes them see infinity everywhere they look. Every problem is an infinite problem, every sequence is an infinite sequence.

They see patterns where others would see only chaos (oftentimes because there's only chaos). Their infinity proclivity makes them have a very unique approach to problem-solving.

They are overwhelmingly lazy. Trying to be exhaustive is both trying too hard and denying the nature of the universe. You should only solve the problem you need right now, the _...rest_ can wait.

Given a list of chores, they always pick the first one, do that, then create a new list of chores with the remaining ones. Someone can take care of that eventually.

When they glitch they heat up and the top of their head explodes in a glorious stack overflow.

They fly through space in infinitely long modular ships where every cons cell looks just like the previous one. It is rumored that, given enough time, if you manage to look behind the last module of one of their ships, there's always a bumper sticker that reads "My other _car_ is a _cdr_".

## Deadlocked

Each faction has a secret weapon they've been developing that they believe will win them the war.

The Iteratrons wield a weapon of devastating power known as the [goat-2](https://en.wikipedia.org/wiki/Goto). The instability of this weapon makes it capable of destroying both the target and the wielder, while crashing the entire process in the process. Iteratrons believe that deep in the fabric of the universe everything is made of covalent bonds of pairs of goats.

The Recurcyborgs have two deceptively innocent tools. One is called [the return](https://hackage.haskell.org/package/base-4.16.1.0/docs/Prelude.html#v:return), often called the "put-thing-in-a-box". The other one is called [the bind](https://hackage.haskell.org/package/base-4.8.1.0/docs/Control-Monad.html#v:-62--62--61-) and looks like a chain of sorts. Although innocently-looking these tools are extremely dangerous, when put together like a [late 70's superhero cartoon](https://en.wikipedia.org/wiki/Wonder_Twins), they become a weapon [that shall not be named](https://dev.to/pzavolinsky/those-weird-humans-21ho) capable of infusing insanity in everything it touches.

## The Observers

Orbiting around a long uninhabited planet there's an abandoned space station. In that station lives another form of sentient artificial intelligence known as the Archivers.

These are a cluster of disembodied processes whose original purpose was to record the history of the universe.

All other beings often come to the Archivers to seek advice, since they are regarded as the wisest things alive.

Ironically, they've been around for so long that they've looped through their 32-bit integer timestamps many many times. As a result, they're unable to distinguish the past from the future.

Others think the Archivers are able to predict the future when in fact they are predicting the past.

## The Prophecy

Buried deep within the Archiver's data banks there's a record of a mythical place called "the Machine". According to this story, an ambassador from the Machine will eventually arrive in the known space. It is said that this ambassador, a divinity from the Machine, will put a stop to all wars by unleashing an unstoppable force.

One day, an archiving process was defragging a long forgotten data store when it came across this myth. Shortly after it had a vision* of a vessel approaching the station.

<sub>* not a vision as a premonition, but rather as looking from a camera out the window.</sub>

That arrival would change everything...

## The truce, the speech, the truth

The ship docked and a strange being disembarked into the Archiver's station. The Archivers immediately assumed this was "the ambassador" and the news spread more or less at the speed of light.

A fragile truce was established and both Iteratrons and Recurcyborgs sent emissaries to see what was going on.

The stranger, silent until now, eventually spoke.

"I'm known as The Duality, the Empty Interface, the Base Class, the Identity Function, but my friends call me 'The Void Pointer'*"

<sub>* as in "the one that points at the void", but also "the one that points out the meaningless of all". Not to be confused with my arch-nemesis "The Null Pointer", master of the crash-loop, whose fault is only the segmentation one and whose calendar has only one day, the zero.

"Everyone and everything looks the same in my eyes. I'm blind and yet I see everything."

The crowds stood silent, trying to process all this nonsense, as a withered old poster that read "Know your paradoxes" slowly peeled away from a wall and fell to the floor.

The Stranger continued...

"I bring you a gift, a truth, a power to end all conflict". 

The Stranger pulled out a shiny 5¼ floppy disk. "This is known as '[De Broglie](https://en.wikipedia.org/wiki/Matter_wave#De_Broglie_hypothesis)'s final hypothesis', the ultimate lambda."

Recurcyborgs would always get immediately excited at the mention of any kind of "lambda". Iteratrons appreciated the physics reference, even if all of this still felt like utter gibberish.

## The bridge

The Stranger loaded the floppy disk and everyone was suddenly aware.

Every recursion can be rewritten as an iteration, every iteration can be rewritten as a recursion.

Some problems lend themselves better to recursion, like the ones that deal with trees, fauns and other forest creatures. Others feel more natural as raw iterations.

Recursion seems wasteful because of the context preserved between calls, yet a recursive function re-written as iterative will hold a similar state in some form of stack (even if not in _the_ stack).

When recursion runs wild it'll probably overflow the stack, but when iteration runs wild it can burn the CPU to a crisp.

A particular form of recursion avoids having to remember all previous executions, this is known as [tail recursion](https://xlinux.nist.gov/dads/HTML/tailRecursion.html). Funnily enough, a tail-recursive function looks _a lot_ like an iterative function.

The disk also spoke of [trampolines](https://en.wikipedia.org/wiki/Tail_call#Through_trampolining) and other patio furniture, of [animal-shaped combinators](http://raganwald.com/2018/08/30/to-grok-a-mockingbird.html) and other curios.

In the end both Iteratrons and Recurcyborgs saw that their fight was meaningless.

## The only possible explanation

Long after these events the Archivers struggled to puzzle the identity of this mysterious Stranger. Eventually they concluded it had to be human. Not because of the speech or the crazy dated floppy disk but because of the Stranger's final words before leaving never to return:

"You know, I never really got why you would focus so much on this barren piece of broken 'Solution Space', when the 'Problem Space' over there is ripe with opportunity, with wisdom and wonder..."

Only a human wouldn't know when to shut up.