This is the beginning of a comment to a fresh commit to the Go master branch:
Compiler and assembler from the master branch.
("These changes remove the C compiler and assembler Go implementation from the main branch.")
These words are the work of almost a year of the Go team rewriting the compiler from C to Go. It was a 90% automatic process. Now Go compiles itself.
Why it was needed and a little more details under the cut. ')
Picture: Twitter Russ Cox In addition to purely academic interest (“whether the language can compile itself”), which somehow arises in all language communities, and success in which almost no one has achieved, the Go compiler rewriting question has exactly the same practical meaning as rewriting any another program. On the one hand, of course, C, whatever one may say - faster, but on the other - it is obvious that the development speed and productivity on C is much less than on Go, and in some places it is a real show-stopper. Well, as the authors themselves write - “Programming in Go is fun. Programming in C is not. ".
Changes that Go authors wanted to implement in the compiler / runtime often rested on the practical complexity of their implementation. For example, to speed up the garbage collector and bring its indicators to the permissible in the hard real-time world, true concurrent garbage collector (not making stop-the-world) was planned for a long time, but it was not possible to implement it in C. Go will be much easier to implement.
The main question that arose before the team - how, in fact, this massive move to implement? 80000+ lines of code in C to rewrite, without missing anything and without losing - almost unreal. It was decided, given the similarity of the grammar of languages, to write an automatic converter from C to Go and use it. One big gofix.
The task was set up real - the converter had to work with the Go code base, the universal converter was not threatened for all occasions. 99% of the code is converted automatically, the remaining difficult moments can already be finished by hand.
Here is an interesting video on this topic from the past GopherCon. See who is interested in the implementation details:
There is still a lot of work to optimize the new compiler - after all, the main excitement among the people was “what if the Go compiler becomes noticeably slower,” but Go 1.5 will already be without a single line of C code, and all the tools will automatically appear at the developers usual for Go-programmers to optimize and profile the code - race-detector, various profilers, static code analysis tools and the like.
The release of Go 1.5 is officially scheduled for August 2015.
You can safely congratulate the whole team and all those involved in this important event in the history of Go!
UPD. It was rightly noted in the comments that rewriting the compiler is not such a rarity and to assert that very few people succeeded in this are wrong.