2 ms·
Fabrice’s C compiler is implemented in 2048 bytes of obfuscated C, whereas mine is 1600 lines of formatted Go. "It can compile itself" is an interesting benchm
by userbinator 6y ago
Fabrice’s C compiler is implemented in 2048 bytes of obfuscated C, whereas mine is 1600 lines of formatted Go.
"It can compile itself" is an interesting benchmark of language complexity, and we now have of C and Go, so I wonder how the other common languages would compare. Of course you can "cheat" by choosing a subset that reduces the complexity of the whole.
As you can see, Mugo uses its own very inefficient ABI that’s nothing like the x86-64 ABI – the standard ABI puts the first six “cells” (64-bit values) in registers.
Considering that stacking args is the norm for 32-bit x86 and few other architectures, it's not that bad, especially since CPUs have special hardware to handle push/pop.
- pjmlp 6y agoMost compiled languages are bootstraped, how come "we now have of C and Go" ?
- userbinator 6y agoCan you point to any other languages' examples of minimal self-compiling compilers?
- eat_veggies 6y agoHere's a (probably non exhaustive) list I found https://en.wikipedia.org/wiki/Self-hosting_(compilers)#List_of_languages_having_self-hosting_compilers https://en.wikipedia.org/wiki/Self-hosting_(compilers)#List_...