๐Ÿ‘คbenhoyt๐Ÿ•‘4y๐Ÿ”ผ180๐Ÿ—จ๏ธ49

(Replying to PARENT post)

This is so cool. I especially loved the Makefile, it's nice to see "bootstrapping" laid out so plainly. I remember finding the concept quite hard to wrap my head around when I was introduced to it. Seeing this would have made it a lot easier to understand!
๐Ÿ‘คchrfrasco๐Ÿ•‘4y๐Ÿ”ผ0๐Ÿ—จ๏ธ0

(Replying to PARENT post)

great post, this part

> For reference, a Python version of this same loop runs in 1 minute and 38 seconds โ€ฆ a dynamically-typed bytecode interpreter is not a good choice for heavy integer arithmetic.

made me wonder about other dynamic langs.

ruby (3.0.0) and lua (5.4.2) ran it in 1:30 and 1:03 respectively but node (12.22.0) ran it in 0:01. how is node so quick?

๐Ÿ‘คiovrthoughtthis๐Ÿ•‘4y๐Ÿ”ผ0๐Ÿ—จ๏ธ0

(Replying to PARENT post)

Being able to compile itself is actually a huge milestone, congratulations!
๐Ÿ‘คdvfjsdhgfv๐Ÿ•‘4y๐Ÿ”ผ0๐Ÿ—จ๏ธ0

(Replying to PARENT post)

Thatโ€™s amazing! Congrats. One question: why is var only supported for top level declarations? Iโ€™m not a compiler or programming language expert by any means, but I thought the general approach was to define a grammar and write a parser for it. Iโ€™m curious how global and local declarations diverged so significantly.
๐Ÿ‘คdimes๐Ÿ•‘4y๐Ÿ”ผ0๐Ÿ—จ๏ธ0

(Replying to PARENT post)

> whereas mine is 1600 lines of formatted Go.

I wonder how the whole thing compares with the newest Oberon (which should be at around 2900 lines of code or so). After all, if you drink enough beers, Oberon might look like "a subset of Go that can compile itself" to you.

๐Ÿ‘คjhgb๐Ÿ•‘4y๐Ÿ”ผ0๐Ÿ—จ๏ธ0

(Replying to PARENT post)

This is excellent! And a great way to understand what's the simplest a computer and a programming language can be. Students should puzzle their way through exercises built on systems like this.
๐Ÿ‘คjeffrallen๐Ÿ•‘4y๐Ÿ”ผ0๐Ÿ—จ๏ธ0

(Replying to PARENT post)

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.

๐Ÿ‘คuserbinator๐Ÿ•‘4y๐Ÿ”ผ0๐Ÿ—จ๏ธ0