5 ms·
I consider that the Go compiler is pretty fast, how big has to be the project to make it noticeable enough?
by luibelgo 10y ago
I consider that the Go compiler is pretty fast, how big has to be the project to make it noticeable enough?
- smarterclayton 10y agoAs a concrete example, Kubernetes (0.5M first party lines of code, ~0.7M libraries) can take about 2-3 minutes to compile on a 2013 MBP on Go 1.7. So probably around 200-300kloc you'd start to say "this feels slow".
- oelmekki 10y agoBefore golang, my experience with compilation was about building softwares as an user in gentoo, and a few LFS. Speed of compilation was the first thing that stroke me with golang. But then again, it was the first time I was actually writing code to be compiled. Is it that usual C/C++ opensource projects are very big, or am I correct to assume golang compiler processing go code is indeed really faster than gcc processing C/C++ ?
- petters 10y agoCompiling C++ is usually pretty slow. Go and C would be significantly faster.
- Twirrim 10y agoOne of the focuses with Go's compilation design was trying to avoid all the extra work that happens in C compilation that could be avoided by some careful language design. There's a good write up here: https://talks.golang.org/2012/splash.article https://talks.golang.org/2012/splash.article, but particularly starting at point 5 on that page.
- pjmlp 10y agoC and C++ are slow to compile due to their compilation model based on text expansion instead of actual modules. Since the 70's that Go like compilation times are possible in module based languages.
- candiodari 10y agoThe 10.000 foot view is that C code is optimized more, but compiles slower. Historically this was always seen as a good tradeoff. You only compile once, but code runs thousands of times or more. Therefore a large slowdown in compilation is seen as a good tradeoff for better runtime speed. Go follows the turbo pascal type compilers in that 1) the language is limited in several ways to make compilation faster (e.g. it is given as an argument against generics) 2) the compiler just doesn't try a whole range of optimizations Unfortunately this is not really what you're seeing. What you're seeing in this case is a massive difference in the size of the projects you're compiling. Go has been written with the explicit purpose of making writing large programs somewhere between tedious and impossible. By contrast, many C/C++ programs are huge. Tens to hundreds of megabytes of source code, and when compiling Gentoo, I bet you're compiling more than a gigabyte total.
- oelmekki 10y agoVery insightful. Thanks!
- dguaraglia 10y agoBut that should be just for the first compilation, right? Aren't compiled libraries cached for future use?
- d0vs 10y agoPackages are only rebuilt when their source or their dependencies change