I think the title is self explanatory.
-
26Do you mean, "What language is Google's compiler for the Go programming language written in"? Languages are not written in languages. Implementations are.– Thomas EdingJul 25, 2010 at 2:08
-
10Yes I apologize for the vagueness but I think we know the answer to that by the accepted answer which clarifies all of what you're saying anyway.– digiarnieJul 25, 2010 at 2:09
-
3Rather than being self explanatory, the title is conceptually confused.– Jim BalterJun 5, 2011 at 6:27
-
People arguing about semantics is so 2010 XD– RisingSunDec 12, 2021 at 21:02
4 Answers
Programming languages aren't programs, hence they're not "written" in any language. They are often described by formal grammars (e.g. BNF).
Interpreters and compilers for programming languages are programs and so must be written in some kind of programming language.
Go has at least two compilers, gc
and gccgo
. The former was written in C, but is now written in Go itself. While the latter is a gcc frontend written mainly in C++. Go's libraries are written in Go.
-
2Are they going to put out a compiler written in assembly? I know C is close to assembly, but from a performance standpoint, wouldn't completely writing it in assembly from the ground up be the best?– CocksureDec 11, 2014 at 12:14
-
17@Cocksure The added performance would not be worth the hit in maintanability. And any way, the only thing that would speed up is the compile time.– liteliteAug 19, 2015 at 19:59
-
5
-
11@mecampbellsoup this is not unusual. The
gcc
C compiler is written in C. Thejavac
Java compiler is written in Java. The very first C/Java/Go compilers had to be written in some other language, but once you have a compiler you can use it to compile subsequent versions of that compiler. If you want to port a compiler to a new architecture (like ARM or 64-bit Intel) your compiler needs to be able to cross-compile, but most mainstream compilers can do that.– ArteliusJul 7, 2019 at 6:53 -
@Cocksure the need for efficiency at the compiler level would not be as important as the efficiency of the output binary. Aug 4, 2019 at 11:57
Look at the source and C for yourself, if I may say.
EDIT The Go team announced in December 2013 that they will be transitioning the compiler to Go. As of February 2015, the compiler is exclusively self-hosting, as the C implementation was deleted. The new compiler shipped for the first time with Go 1.5.
-
11
It's written in C. The libraries are written in Go itself.
Edit: Now the compiler has been rewritten in Go, so it is fully self-hosting.
-
2I was really expecting it to be written in Go, after being compiled the first time.– cregoxAug 19, 2010 at 18:20
-
2@Cawas Compiled the first time by what? Before you can compile any program written in X, including a compiler for X, you must have a compiler for X written in some other language. In this case, that language was C. Given a compiler for Go written in C, why write another one in Go, especially when that compiler would have to be modified when the language is changed? Go is still an experimental, unstable, and incomplete language -- not good for a language to write compielrs in. Jun 5, 2011 at 6:33
-
@Jim what you mean by what? It's all as you said! You just answered your own question to me. But I didn't know Go was such a kid. I never used it and am simply an enthusiast of anything google.– cregoxJun 6, 2011 at 0:56
-
So, lets say I wanted to port Go to a new, non-x86, architecture, for which there currently exists only a C compiler and an assembler. How would I do that? Would I need to go an resurrect the old C version of the compiler and port that, and then bootstrap my self up from there?– ChrisGNZFeb 19, 2019 at 22:36
-
"go compiler written in go and little of assembly"
"but gccgo is written in c c++ and go"
Rob Pike
-
1how can a go-compiler be written in go?, this makes no sense to me Mar 26, 2020 at 15:57
-
1
-
Would you like to see a language whose compiler is built with another language compiler, and then a new compiler is built with its old compiler? All in 30 seconds? Go to vlang.io page– AhmedDec 18, 2020 at 1:19