News for hackers. Stuff that matters.
Re:Mugo, a toy compiler for a subset of Go that can compile ... by userbinator on Monday April 12, 2021 @09:26AM (#26779135)
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.

Re:Mugo, a toy compiler for a subset of Go that can compile ... by pjmlp on Monday April 12, 2021 @09:29AM (#26779162)
Most compiled languages are bootstraped, how come "we now have of C and Go" ?
Re:Mugo, a toy compiler for a subset of Go that can compile ... by userbinator on Monday April 12, 2021 @03:37PM (#26784103)
Can you point to any other languages' examples of minimal self-compiling compilers?
Re:Mugo, a toy compiler for a subset of Go that can compile ... by eat_veggies on Monday April 12, 2021 @04:11PM (#26784538)
Here's a (probably non exhaustive) list I found

https://en.wikipedia.org/wiki/Self-hosting_(compilers)#List_...