RCIRODERICK CONSULTINGTalk to an engineer
← Babel

Hello World in Inflexión, and What It Took

A bridge between the Inflexión article series and the Babel phase of the project. Voice in first person; a process or craft piece outside the series proper of nine articles, from Listening to Spanish Again through The Article Already Knows. The story of writing a Brainfuck interpreter in Inflexión, the runtime gaps the design paper had waved away, the choices of Spanish grammar that closed them, and the moment the Babel ↔ Inflexión loop closes, when Inflexión interprets the Brainfuck that Babel generates.

Not yet syndicated to LinkedIn.

Hello World!

That's the output of a Brainfuck interpreter, written in Inflexión, running through a public web playground at babel.roderickc.com. Twelve characters and a newline. The piece of code that produces them is a compact Inflexión program, twenty dense lines, about three thousand characters of Rioplatense Spanish prose that the parser turns into something the runtime can execute.

The interpreter is a small artifact. The journey to get those twelve characters on one line was longer than I expected, and most of what slowed me down was not engineering. It was discovering, by building, what the language needed before the interpreter could exist at all. The Inflexión design paper has a section called "Turing completeness" that promises this is possible. The paper's promise turned out to be aspirational. Building forced the specificity.

This is the story of what got added to Inflexión between the original paper and the moment Hello World! rendered on a single line. It is, more than anything else, a story about Spanish grammar carrying its own weight.

What the paper promised

Section 4.3 of the Inflexión white paper says, in essence: the language is Turing-complete because it has mientras, a while loop, and ser, immutable binding that can be self-referential and so gives recursion. That's the standard textbook formulation: looping plus recursion is enough. The paper points forward to a worked Brainfuck interpreter as the eventual witness.

When I sat down to write that witness, the runtime had shipped the six mappings the paper describes, grammatical on one side and semantic on the other: ser/estar, mood, aspect, clitics, diminutive, number. It was a real working language. It could compute a Fibonacci sequence on a list, perform numeric scaling through the diminutive system, run a Cuando ..., decí "listo" deferred binding, define functions through relative clauses. Everything the paper claimed about the six mappings was true.

It could not write Brainfuck.

What it didn't say

Brainfuck is, by design, almost not a language. It has eight instructions of one character each, a tape of cells you can increment, decrement, and dereference, an instruction pointer, and a pair of bracket characters that jump conditionally. To write an interpreter for it, you need:

  • A way to dispatch on the current instruction, an if over a character.
  • A way to update two pieces of state in one step, the instruction pointer and the tape pointer.
  • A way to call a helper function recursively, so it can find a matching bracket.
  • A way to read individual characters out of a string.
  • A way to read and write a single cell of a mutable list addressed by an integer that changes during the program's lifetime.
  • A way to emit a single byte on stdout without anything tagging along behind it.

The paper had said iteration plus recursion are enough. That is true in the textbook sense, in the same way a Turing machine is enough to do anything. It is not enough in the sense of Inflexión as a programming language a person can sit down and write code in. What the textbook leaves implicit, building makes explicit. The runtime as it then stood had none of those six things. So we added them.

The first five came together in a single round of work. The sixth, which is also the most interesting, came later on its own, because it took a while to notice that it was missing. I'll come back to it.

The Spanish grammar choices that emerged

Every gap had to be filled by a choice of Spanish grammar, because Inflexión is committed to that constraint: surface syntax has to flow from Rioplatense Spanish, not from invented keywords. Here is what we ended up with, briefly.

Conditional dispatch. Si la i es divisible por 15, decí "FizzBuzz"; sino, si la i es divisible por 3, decí "Fizz"; sino, decí la i. The verb es is indicative, since we are asserting the condition. The earlier form of deferred binding with cuando takes subjunctive esté, since it does not assert; the conditional form with si takes indicative, since it does. Both are forms a speaker of Spanish uses without thinking; the parser had to learn that the mood of the verb in the condition is what tells it which clause shape it is reading. Note also the article: la i, not el i. Letters of the alphabet are feminine in Spanish, la letra i, so variable names of a single letter take la. The compiler is silent on gender. The speakers of Spanish reading the code are not.

Recursion. La función fact, que toma una n, es si la n es 0, entonces 1; sino, la n por fact (la n menos 1). The parentheses are not Spanish punctuation exactly. They are closer to a typographic convention Spanish prose tolerates, and they were the simplest way to disambiguate where the recursive call's argument ends. Without them, the parser cannot tell whether fact la n menos 1 means fact applied to (la n menos 1) or (fact applied to la n) minus 1. The choice between the two readings is exactly the choice between recursion that terminates and recursion that doesn't.

Indexed list access. El i-ésimo de el colador. Spanish forms ordinals from cardinals by suffixing -ésimo. The fortieth is cuadragésimo, the hundredth is centésimo. We bent that productive morphology one step further: any variable name with -ésimo attached becomes a positional reference. El cinco-ésimo would be the fifth element. El i-ésimo uses whatever number is currently bound to i. The suffix carries the indexing; the noun before it carries the position. The Sieve of Eratosthenes program is canonically Criba de Eratóstenes in CS textbooks written in Spanish; colador, the kitchen colander, is the everyday domestic register the project leans into. Both are correct. Colador is what a speaker of Spanish actually has at home.

Articles and gender. The first version of the Brainfuck interpreter had el cinta and el celda everywhere, masculine articles attached to feminine nouns. Spanish would never read that way, and speakers of Spanish proofreading the code immediately flagged it. Cinta is the tape, later renamed to tira, the strip, the same move toward domestic register as colador. Celda is the cell, instrucción is the instruction, and all of these are feminine. The same was true of variable names of a single letter: i, j, n, a, b are letters, and letters in Spanish are feminine, la letra i, la letra n, so the article on every reference to a variable of a single letter had to flip from el to la as well. Function parameters declared with feminine nouns or single letters now use una instead of un. The compiler did not need any of it. The reader did.

Three composition surprises

Engineering has a name for the next class of discoveries: composability. A feature can work in one context and refuse to work in another, and the gap between them is rarely advertised.

Inflexión had three of these. Si worked as a statement at the top level, but not yet as the body of a Mientras loop, because the parser had only ever expected mutations in that position, and a conditional was a different shape entirely. Indexed list set, the form Hacé que el j-ésimo de el colador esté en 0, worked as a statement at the top level, but not as a clause inside a y que ... chain, because the parser segmented the chain expecting only plain mutations. Indexed list set worked inside a Si arm, but only when the Si arm was at the top level; nesting it inside a loop body required yet another dispatch.

None of these are deep semantic problems. They are all the same kind of bug: the language has a feature, and another feature, and combining the two requires a piece of plumbing that nobody wrote. Engineers know this lesson well. What's interesting about Inflexión is how sharply Spanish prose serving as syntax surfaces it. You write what feels like natural Spanish prose, you watch the parser reject it, and you discover that one corner of the grammar is wired through and another corner is not yet.

The last gap: decir and hablar

The Brainfuck interpreter ran. It produced output. The output was correct in content. It looked like this:

H
e
l
l
o

W
o
r
l
d
!

Each letter, one per line.

Inflexión has a vos imperative for output, decí, which is the imperative form of the verb decir, to say. Decí "hola" says hola. The way it implements saying is by writing the value followed by a newline. That fits the verb: when you say a sentence in Spanish, the sentence is finished; you commit to having said a thing. The newline is the period at the end. The implementation matched the meaning.

But Brainfuck's . operator emits a single byte, and the next . emits the next byte, and the bytes are meant to chain together into output that doesn't have a newline between each one. The Inflexión interpreter for Brainfuck had to invoke decí once per byte, and every call put a newline after it. Hello World came out vertical.

This was not, in any productive sense, a bug. Decí did what decí means. The language was missing the other half of a distinction Spanish already carries.

Spanish has two verbs that map to what English flattens into output. Decir, to say, is committed content, a terminated utterance: when you say something, you have said it. Hablar, to speak, is ongoing activity, sound by sound, with no inherent termination: when you speak, you can keep going, and the next sound joins the previous without a separator. The verbs differ on a single axis: whether what you produce is one finished thing or part of an ongoing act. Decí "hola" finishes. Hablá "h" does not. It expects there might be another sound coming.

We added hablá as a sibling of decí. Same place in the mood mapping, imperative and side effect. Same call shapes: name a binding, pass a literal, pass an expression. The only difference at runtime is that hablá does not append a newline. The grammatical distinction selects the axis of content versus activity; the implementation respects what the verb means.

The Brainfuck interpreter's . operator now uses hablá. Hello World! renders, on the live Playground, as one line.

The recursive loop closes

The Brainfuck interpreter sits, today, in the same tab as two other languages: BF-Vanilla and BF-Rioplatense, both of which are produced by Babel, the methodology paper's other artifact. Babel generates Brainfuck variants from parameter sheets; Inflexión interprets Brainfuck. The series' first artifact eats the series' second.

That recursion is the simplest part of the story to tell, and the least surprising. The interesting parts were the gaps the paper hadn't mentioned, the choices of Spanish grammar that filled them, and the moment when a verb pair we had not bothered to map became necessary.

What this whole thing is for

The white paper said the design is Turing-complete. The build said: yes, but not yet. The work between those two sentences is what made Inflexión into a language a person can write programs in, rather than a language that can be defended in principle. Most of that work, the suffix -ésimo, the pair decir and hablar, the concord pass on articles and nouns across the benchmark programs, was Spanish doing exactly what we built Inflexión to do, which is to carry its own meaning at the surface. The parser learned what speakers of Spanish already knew. The runtime followed.

Twelve characters and a newline.

Inflexión is an esoteric programming language built by hand, whose semantics flow from the grammatical features of Rioplatense Argentine Spanish. The full design paper is at roderickc.com/inflexion. The companion methodology paper, on Babel, the runtime that generates esoteric programming languages from parameter sheets, is at roderickc.com/babel.