Google announced plans to implement Go 1.5 Bootstrap. The author of the relevant documents is Go core developer Russ Cox, who has been working on the Go language for nearly 6 years. According to Russ, Google has been brewing for a year on "how to remove all C programs from the Go source tree." (Recommended learning: go)
Bootstrapping is the process of "writing the compiler (or assembler) of the target programming language to be compiled."
Generally speaking, bootstrapping has several advantages, such as:
is used to test the language being bootstrapped;
supports the use of usually more Write compilers for higher-level languages that provide more high-level abstractions;
compilers can also benefit from any improvements at the language level.
As mentioned above, Google has previously begun efforts to remove C code from the Go source tree. The conversion plan is divided into 5 steps:
First Stage - Develop a translator from C language to Go language, and translate the existing C compiler into Go language. This stage takes advantage of the fact that the original compiler did not make extensive use of some features that are difficult to port to the Go language, such as macros, unions, and pointer arithmetic.
Stage 2 - Convert the source code tree of the compiler to get a Go language compiler, but it is relatively primitive and in C style.
Phase 3 - Convert the previously obtained compiler into a program that conforms to Go language habits, mainly by identifying packages, adding documentation and unit testing.
Phase 4 - Optimize the compiler, solve the memory usage problems of the compiler and CPU, and may introduce parallelization.
Additionally, an attempt is made to introduce a new intermediate representation between the architecture-independent unordered trees (Node*s) used today and the architecture-dependent ordered lists (Prog*s), with the aim of improving compilation Optimization of the processor in eliminating redundant nil checks and boundary checks
The above is the detailed content of What is golang written in?. For more information, please follow other related articles on the PHP Chinese website!