
TIL WTF encoding is a thing

Ditto. And it is (of course) on purpose: https://news.ycombinator.com/item?id=9611710 (third comment)

Looks like PYPL may be more of an indication for how confusing a language is :)

Speaking of WTFs, here’s the Go runtime compiled to Racket via Wasm: https://gist.github.com/Bogdanp/de056f6c74e3614df8acf33b9e3f9e14

The input .wasm
is 2.2MB and the output .zo
(from running compile
on the data in the gist) is 22MB :smile:

I imagine that Go relies on system libraries being present, whereas Racket basically just compiles the whole runtime into the file. At a guess.

I haven’t dug in but I believe it’s mostly due the fact that my Wasm -> Racket compiler is really naïve and ends up generating a lot of code (the file in the gist is about 16MB), which itself expands into yet more code.
The WTF was meant to be self-deprecating and not related to the size thing, which I thought was just kind of interesting. Sorry for the confusion!
The Wasm format is optimized for low file sizes in a way that the .zo
format (I’m guessing) isn’t. To improve code size here, probably the best approach would be for me to add more re-sugaring steps to make the generated code look more like regular Racket and to extract more common patterns into other modules so that they may be reused.

If anybody has references to articles re. compiling code from a low-level language to a high-level one, I’d love to see them!

This might be of some relevance there: https://github.com/lifting-bits/remill (linked to from https://blog.trailofbits.com/2020/10/22/lets-build-a-high-performance-fuzzer-with-gpus/) - I heard it mentioned on a podcast the other day. To re-compile binaries for GPU execution, they lift the assembly to LLVM IR, and then run the backend on that for the new target.

The zo format is pretty space optimized but probably not for the patterns your code generates.

Made a blinking LED on RPi GPIO with Racket https://gist.github.com/samdphillips/4dd15ef89e5e4fff54cffd5be8af9d80

I overthought the SET and CLR logic so there is a nice bug for anyone trying that out with more than a couple pins.