💾 Archived View for freeshell.de › gemlog › 2022-05-03_Whitespace.gmi captured on 2023-11-14 at 08:10:40. Gemini links have been rewritten to link to archived content
View Raw
More Information
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
Whitespace ⬜
Years ago, I read about the Whitespace language. The only significant characters are space, tab and line feed. Everything else is a comment. On Saturday it crossed my mind again, so I read the tutorial and thought "Seems like a do-able thing." So I wrote a Whitespace interpreter.
Wikipedia article
How did I get on?
- The documentation is ambiguous, but that's even admitted at the top of the page.
- I can't install the Glasgow Haskell Compiler, which I wanted so I could try the canonical version. I think it didn't work because I have Cygwin and that interfered with the MinGW it installed. I have a Linux VM, but not of a flavour supported by GHC.
- The interpreter wasn't so hard to write. There's a stack, a heap, and 24 instructions. Arbitrarily large integers was a surprise, but now I can calculate 100,000 factorial. I tried a million, but it took over 6 minutes and the result didn't fit into my 9000 line screen buffer.
- Writing code in Whitespace is hard, and only partly because it's all white space. Mostly it's hard because it's machine code for a 24-instruction processor. I had to write it out assembler-style so that I could reason about what it would do without worrying about the daft encoding, then put in the actual instructions later. I may have been cheating though, because I used an editor that lets me display tabs and spaces.
- If I have to write in assembler, hand-coding that to actual Whitespace is kind of annoying. But if I wrote an assembler program to generate Whitespace, I've abstracted away the fact that it's weirdly encoded, and that makes the whole thing a bit pointless.
What's missing in Whitespace
- A language with no file I/O is annoying. Instructions could be added to the I/O Instruction Modification Parameter, [Tab][LF], to open, close, read and write a file.
- There's no way to pass parameters to a Whitespace program.
- There's no way to call into any other code outside the current program, so you can't use any kind of library.
So writing a Gemini client in Whitespace would be tricky.
Did I enjoy myself?
I found that when I was doing other things, my mind strayed back to this all weekend. It was a fun excercise.
#Whitespace
#programming
back to gemlog