top | item 5824514

(no title)

ralph | 12 years ago

That's not how the books say to do it, and you're right, given who created Go you'd think they'd know this stuff. :-)

Many generations of the compiler are created. Let's say the compiler-in-C is worked on until it compiles subset Gosub1 which is just enough to write compiler-in-Gosub1 that duplicates compiler-in-C's behaviour. From now, compiler-in-C atrophies. G-2 features are implemented in G-1's compiler, though nothing uses them yet. The compiler's source then uses these, making it G-2 source, only compilable by a G-2-grokking compiler.

Weeks later we have a G-40 where a bug is discovered, introduced in G-20. It wasn't in the compiler-in-C so that's not useful. Choices include fixing it at `head', which can sometimes be awkward as described earlier, or fixing the initial G-20 implementation and then rolling forward all changes from there assuming the fix doesn't break code that was depending on the errant behaviour.

discuss

order

pjmlp|12 years ago

> That's not how the books say to do it, and you're right, given who created Go you'd think they'd know this stuff. :-)

Given that compiler design was one of my three main focus on my CS degree, I read a few books along the way. :)

> Many generations of the compiler are created. Let's say the compiler-in-C is worked on until it compiles subset Gosub1 which is just enough to write compiler-in-Gosub1 that duplicates compiler-in-C's behaviour. From now, compiler-in-C atrophies. G-2 features are implemented in G-1's compiler, though nothing uses them yet. The compiler's source then uses these, making it G-2 source, only compilable by a G-2-grokking compiler.

It is not required to do this so fine grained.

The first version of the primitive language can already be good enough to offer the minimal set of features to compile itself.

Afterwards the full language compiler gets implemented in this minimal version and used for everything else.

There aren't thousand versions of the compiler, you just need to be restrictive of what is used in the base compiler.

> Weeks later we have a G-40 where a bug is discovered, introduced in G-20. It wasn't in the compiler-in-C so that's not useful. Choices include fixing it at `head', which can sometimes be awkward as described earlier, or fixing the initial G-20 implementation and then rolling forward all changes from there assuming the fix doesn't break code that was depending on the errant behaviour.

As I explained this is not required because you only have G-2 as starting point, which is able to compile whatever is the current version of the language.

Additionally you get the benefit to eat your own dog food and as compiler designer check if you are doing the right design decisions on how the language works.

ralph|12 years ago

Sorry, I don't understand. You seem to be saying there's only two versions of the compiler, one written in a foreign language, e.g. C, the other in a subset, e.g. Gosub, called G-2. But then there's "whatever is the current version of the language", which suggests to me incremental improvements, e.g. the language develops as experience is gained rather than being fully planned on day one. So doesn't G-2 undergo changes to implement these? You may keep calling it G-2 but there are many (I never said thousands) of versions of it.