AI Writes the Code. Why Hasn't the Syntax Changed? · 02
If I write in English, will the computer understand?
In the previous episode, I decided to build FlowScript, a language that reads more like English. But as soon as I tried to design its syntax, I ran into a problem: a sentence that feels natural to a person isn't necessarily unambiguous to a computer.
Consider Set the user age to 20. A person understands it instantly. A computer has to know whether the is part of the grammar, whether user age is a single variable name, and where to separates the name from its value.
I wanted a language as free as natural English. The first thing I had to do was invent rules that restricted that freedom.
I opened a Python textbook and started rewriting its table of contents
I didn't begin with a formal language specification. I brainstormed freely, then opened a beginner's Python book: variables, expressions, conditionals, loops, functions. For each familiar concept, I asked, “How would a person say this?”
First, variables:
Set price to 100.
Print price.
It's longer than price = 100, but the intention is easy to guess. Set describes the action, while to marks the boundary between the name and the value. I could have imagined something like Let price be 100, too. What mattered was that the sentence read naturally and its parts had clear roles.
Then came conditionals:
When price is greater than 50:
Print "Expensive".
If is an English word, of course, but When felt closer to “when this condition holds, do the following.” A loop such as For each item in items also seemed to explain itself. Slowly, the Python textbook's headings were turning into FlowScript sentences.
At this point, designing syntax still felt like a fun word puzzle.
The words that make English sound natural don't always do anything
I kept noticing words like the, So, and Then. They can make a sentence flow, even when they don't change what the program should do.
Set the price to 100.
Then Print the price.
The article the shouldn't suddenly refer to a different variable. And Then simply connects one instruction to the next. What if the language could ignore such words during interpretation?
There was a trade-off. Every word the language treats specially could collide with a variable name or another expression. Still, I figured few people would insist on naming a variable Then. During the planning stage, the gain in readability seemed worth it.
Capitalization raised a similar question. A human reads Print, print, and PRINT as the same instruction. Why make them memorize a distinction? I wanted people to read the sentences, not study punctuation rules.
Wait—what happens when variable names contain spaces?
The problem became more interesting with a sentence like this:
Set total price to item price times item quantity.
A person can infer the intent: multiply item price by item quantity and store the result in total price. But how does the computer know where each name ends and an operator begins?
I could make the problem disappear by requiring one-word names: totalPrice, itemPrice, itemQuantity. But then I would be moving away from the very reason I started this project.
So I considered three possibilities:
Set `total price` to `item price` times `item quantity`.
Set "total price" to "item price" times "item quantity".
Set total price to item price times item quantity.
Backticks clearly mark boundaries, but they look awkward. Quotation marks are familiar, but then how should the language distinguish a variable name from a string? No markers at all look the most natural—and leave the computer with the hardest job.
I initially thought this was a small stylistic choice. In reality, it could determine how the entire language reads sentences. I wasn't ready to choose yet.
Even the rules that seem obvious have to be specified
Variable names weren't the only problem. If I wrote Set result to 2 + 3 * 4., should the answer be 14 or 20? Operator precedence feels obvious to someone who knows arithmetic, but my language would still need an explicit rule.
And how should multiple lines form a block?
When user age is greater than 18:
Print "Welcome".
Print "You can enter".
Print "Done".
A person sees the indentation and understands that only the first two print statements belong to the condition. The computer needs rules for where that block begins and ends. Even tabs and spaces become part of the design.
In everyday English, context can resolve ambiguity. In a programming language, the same statement must mean the same thing every time it runs. A sentence that's easy to read isn't automatically a sentence that's impossible to misunderstand.
How strict should a natural language be?
My ideas changed repeatedly. Making a sentence more natural could introduce ambiguity; eliminating ambiguity could bring back the symbols and constraints I wanted to avoid.
The goal gradually became clearer: sentences that read naturally to humans but have exactly one meaning to the computer.
I didn't settle every decision during planning. Multiword variable names, especially, remained an open question: backticks, quotes, or no delimiters at all? I didn't yet know how much that decision could reshape the implementation.
Next, I had to make these sentences actually run. But before that came a more basic question:
How does a computer even read the English sentences I write?