I can't get out of my head, the idea that it would be cool if Mirth could target DOS, you know, as a platform.

But the only Mirth program is the Mirth compiler. So...

Sofia makes a self-hosting compiler for DOS.

A thread.
The main challenge is fitting all the operations of the compiler in a small amount of memory.

640 KB actually sounds like a lot . . .
Ok, I reserved a lot of big buffers in the compiler but they're mostly useless or empty.

The file buffer holds the whole file, but I really only need to look at it one character at a time, when I'm lexing.

So let's make it small, and read the file on demand.
Hmm... Lexical data (row & column data) sure takes up a lot of space that's only useful when there are errors/warnings to display.

I don't need to store the data. I can re-lex the file just to pick out the row & column data, if needed. Surely that's fast enough for errors.
Tokens are the next big thing. I could just try to pack them tightly and make the common cases super efficient... There's some limit here, but I don't know what it is.

(The true limit is Shannon's entropy. But the practical limit is Sofia's sanity, which has not been found.)
(I'll add more to this thread over time, if I don't abandon the idea of running Mirth on DOS.)
You can follow @typeswitch.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: