

Go 1.5 Bootstrap Plan - Goranek
https://docs.google.com/document/d/1OaatvGhEAq7VseQ9kkavxKNAfepWy2yhPUBs96FGV28/edit

======
robbrown451
So you need 1.4 to build 1.5....can you then rebuild 1.5 from 1.5? Would it be
different? Would it make a difference if you then rebuilt 1.5 using 1.5 built
using 1.5 rather than 1.5 built using 1.4?

~~~
masklinn
> So you need 1.4 to build 1.5....can you then rebuild 1.5 from 1.5?

If the language is forward-compatible, yes. It could be different if new
optimisations have been added, or the code generator has changed.

> Would it make a difference if you then rebuilt 1.5 using 1.5 built using 1.5
> rather than 1.5 built using 1.4?

It should not, the 1.5 compiler should be stable and yield the same result
whether it was built using a 1.4 compiler or a 1.5 compiler.

That's actually a common technique to look for regressions and validate the
bootstrapped compiler. For instance to compile rustc you download a "stage 0"
compiler at Vx which compiles a "stage 1" compiler using Vy > Vx source. That
stage 1 compiler is then used to compile the stage 2 compiler from the same
source. Stage 1 and stage 2 may not be identical since stage 0 and stage 1 may
have different optimisations &al, so the stage 2 compiler is used to compile
rust a third time, and that compilation is checked against the original stage
2 (and should be a fixpoint).

------
jsherer
I'm curious, as the document doesn't mention it, what is the benefit of
bootstrapping? Is it primarily to allow future development to happen in the
bootstrapped language, instead of the lower-level language (C in this case)?
Or is there some other benefit I'm missing?

~~~
josteink
Microsoft found themselves unable to improve the C# language using a compiler
written in a lower level language like C/C++ so they've rewritten it in C# to
allow further language development and to support more sophisticated language
features.

It also has the benefit of the team implementing the language actually
dogfooding it, causing natural evolutionary improvements.

I suspect Google is doing this with go for the same reasons.

~~~
masklinn
> It also has the benefit of the team implementing the language actually
> dogfooding it, causing natural evolutionary improvements.

On the other hand, a big risk is that the language will evolve towards being
better at writing compilers, which is a highly idiosyncratic task.

~~~
rsc
Yes, that is a real risk. I have written about this before. It's much more of
a risk at the start, when there are no other sizable programs. Now there are
plenty of sizable Go programs, so I am not worried about overfitting to
compiler development.

------
binarycrusader
Ugh...this is going to make new ports such a pain. I can understand why
they're doing it, but this is going to make my life a lot more difficult.

If 1.4 is going to become the bootstrap toolset, that also suggests that 1.4
will essentially become "long-term supported", meaning that if new ports
require fixes to the bootstrap toolset (even in the cross-compilation)
scenario, hopefully they'll accept those changes upstream.

~~~
abtinf
I'm not sure I understand why this makes ports harder.

Shouldn't it be possible to port to a new system simply by porting Go 1.4 to
that system? Once that base version is ported, a script can build 1.4, then
build 1.5 and any succeeding base versions until the current version is
reached.

Of course, system-specific features would have to be added for each go release
beyond 1.4, but that would have to be done anyway.

What am I missing?

------
cheepin
I'm more surprised that the Go 1.4 compiler is written in C. Writing a
compiler in C sounds very unpleasant compared to a language like OCaml. Does
anyone know why they made this choice for the initial design?

~~~
enneff
Ken Thompson wrote it. He's pretty good at C.

~~~
smosher_
Did he? I was under the impression he wasn't approved to write C at Google
when Go was initially being developed.

[http://www.theregister.co.uk/2010/04/21/ken_thompson_take_ou...](http://www.theregister.co.uk/2010/04/21/ken_thompson_take_our_test/)

~~~
chubot
That article is misleading -- it's really about C++, not C, and isn't really
relevant to the Go compilers (which are written in C). I have Coders at Work
and I think Ken Thompson was exaggerating a bit for the humor of it.

There is a "readability" process for C++, which is the thing he says he never
got. Not much code is written in plain C -- the Go compilers would be an
exception.

If I recall correctly, the book Coders at Work also talks a bit how the some
of the Go/Plan 9 guys sat near to Bjarne while he was developing C++ at Bell
Labs. They are not really fans :)

------
choffee
Is this going to be tricky for distributions or will they just have to keep a
1.4 version of Go around just to build modern versions of Go?

~~~
enneff
It should be pretty easy for distributions, since they'll already have
packaged versions of Go 1.4.

------
ansible
Is this going to use the same C to Go conversion tool that helped with the Go
runtime conversion?

------
wowoc
Well, now I just hope that generics are extremely helpful in writing
compilers! :-)

------
barryallen22
If Go 1.5 relies on Go 1.4 which relies on C doesn't go 1.5 still rely on C? I
don't get why they're doing this. Also, will go 1.5 have generics?

~~~
mkohlmyr
The idea is not to not rely on C. The idea is to not have to do the compiler
development _in_ C.

