Moving the compiler
The compiler was written in Dart because Dart is what my work has been built in for the last few years. It was the obvious place to start, and the plan was to leave it there until the language stopped changing.
That plan has changed.
What changed it
I asked how I would actually write Nilo, day to day. The answer was a text editor on one side and the live page on the other. And I had to be honest: I only really write code when the editor understands the language. Words that complete. Errors under the line as I type. Without that I do not sit down and write, I put it off.
So for all the talk of coding by hand, I have not written a full piece in Nilo by hand yet. That is the biggest hole in the project, and an editor is what fills it.
I want two things:
- Nilo understood by the editors I already use.
- An editor of its own in the browser, with the code beside the art, that works on a phone.
Both need the compiler to run in new places. Inside an editor, answering between keystrokes. Inside a web page. And if anyone else is ever to use it, on their machine, without a morning spent installing things.
Why Go
I want the compiler to be fast and I want it to travel. Go gives one program file with nothing to install beside it. It can be built for every kind of computer from one machine. Editors can launch it. It can be built to run in a page.
It will not be much faster. The Dart program is already quick, and the slow part of a full build is the search for the smallest output, which is slow in any language. The gain is where it can go.
The order
- Finish the words that are in progress: curves, gradients, groups.
- Stop adding to the language.
- Rewrite the compiler in Go, as a single job.
- Carry on with the language from there.
- Then the editor support, then the editor.
Doing it now is cheaper than doing it later. Every new feature added in Dart is one more thing to carry across.
How I will know it worked
This is where the byte comparison earns its keep. The new compiler has to produce the same 180 builds as the old one, byte for byte, and pass the same 470 checks. Not close. The same.
A rewrite is normally an act of faith. This one can be proven, and the old compiler stays until it is.
What could go wrong
- Numbers. The two languages print them in slightly different ways, and every number in a shipped file has to come out identical.
- Order. Go deliberately shuffles the order of some of its collections, so a careless port would give a different file each time it ran. For work that goes on chain, that is not acceptable.
- Time. My guess is a few days. I do not trust the guess.
The editor waits until this is done. I would sooner build it once, on the compiler it will live on.