by arcticbull · 6y ago · 0 comments
It's like Tesla deciding that before they built a car, they'd have to pave a new highway from SF to LA. Someone's already done the paving, focus on what you bring to the table.
LLVM is clearly the future. Yes, it could be improved, but of course all the effort that went into resurrecting the geriatric Go compiler didn't go into improving LLVM. It went into re-implementing assemblers for various architectures as though that wasn't a solved problem 100 times over.
As for package management and vendoring, both are great, and should be table stakes, so credit where due on that one.
Something something shipped is better than perfect.
IMHO I'm quite glad they didn't drag the bloat of LLVM into the fray.
If you want to compile Go using LLVM, everything you need is there to make it happen. In fact, someone has already done a lot of the leg work for you[1]. And if GCC is more your thing[2]...
It was also conceived as suitable for web servers, crawlers, and indexers; there it has been successful inside and outside Google.
Why didn't it catch on for browsers, databases, OSes - while Rust did? I think it must be the GC primarily, but the lack of an advanced optimizing compiler is part of the story.
* https://awesome-go.com/#database
* https://github.com/rust-unofficial/awesome-rust#database
Rust was invented specifically to write a web browser, so that is a bit of an unfair comparison, but I would suggest that Go's lack of seamless inter-op with C is its biggest limiting factor in integrating into existing browser codebases as well as greenfield GUI applications. Additionally, Go's runtime is not well suited to OS development.
I doubt the lack of an advanced optimizing compiler ever crosses anyone's mind as by the time that might become an issue they have already ruled out Go for its many other limitations.
Is LLVM bigger? Yep. Slower? Probably. Is that because it's some wildly inefficient monstrosity? Nope. It does a lot more, with a lot more flexibly, and it does it a lot better than the Go toolchain. One day when Pike & Co get around to implementing all the optimization that LLVM has, it'll be just as big, and just as slow, mark my words.
Russ Cox took the time to explain why LLVM wasn't chosen: https://news.ycombinator.com/item?id=8817990
And while Go compiler may not be perfect, it works well enough.
It's faster because it does less, and it doesn't do it as well. You can always make LLVM faster by reducing the kinds and number of passes performed for debug builds, for instance, "cargo check".
Further, developers have much better machines than customers, and taking more time to release something smaller is almost always better.
> ...not depending on C++
I hate C++, but I could care less that LLVM was written in it. I don't refuse to use MySQL because it happens to be written in C++. The Go compiler could still be written in Go, and targeted at LLVM IR code, just as the Rust compiler is written in Rust.
> ...and we don't need a compiler monoculture
And we don't have one either way. There's GCC and LLVM. A boutique one-off compiler is in no danger of toppling the GCC/LLVM status quo.