What makes Go's compiler so FAST!?
Table of contents
No headings in the article.
Go's the lightning-fast compiler is one of Go's biggest selling points.
However, what exactly did the Go team do to achieve this?
Why is Go's compiler so performant?
Here are the reasons…
1. Go is simple.
Go only has 20 something keywords in the language.
Compared to Java in the 60s and close to 100 for C++, for example.
This helps with shortening the compilation time.
2. No unused components.
You can't compile with unused components like variables or imports.
Your IDE or code editor will also constantly complain during your development.
This helps reduce unnecessary instructions to compile at the end.
3. No symbol table when parsing.
A symbol table is a data structure for storing entities like variable/function names.
Parsing in languages like C/C++ requires the symbol table.
Note that the symbol table is still used for full compilation, just not during parsing in Go, which reduces part of compilation time.
4. No header files.
C/C++ uses header files to connect the different components.
These header files take extra time to load, parse then compile.
Go, on the other hand, doesn't use header files.
5. Prioritization.
Fast compilation speed has been the priority since the birth of Go.
As a result, other features of Go have to be designed with fast compilation in mind.
Such prioritization makes a difference, especially over time.
The list can go on, but these are some of the major factors.
Hope this helps you get some ideas on this subject!