DEV Community

Discussion on: Why are C and C++ slow to build?

Collapse
 
atom3333 profile image
Thomas Ferrand

During the design of the Go language it has been a conscious decision to ensure compilation would be small.
The biggest problem wrt compilation time in C and C++ is the archaic dependency management system, text source inclusion which means that a lot of work have to be performed for each translation unit even if it has already been done in another.
Additionally, C++ library tend be template-heavy and template instantiation is a lot of work for the C++ compiler.
Finally, when dealing with with optimized builds, C and C++ compiler apply more optimizations (which makes the compilation slower) whereas the Go compiler only apply a subset of the optimizations.
For more details look at this stackoverflow.com/questions/297663...

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

WoW, perfect SO discussion.

Makes me think, why can't a language have both development compilation (i.e. fast, therefore, faster dev cycle, but not sacrificing developer's experience); and slow compilation (i.e. highly optimized)?

I realized that there might be multiple languages tried after C, but before Go; but for some reasons, Go is quite successful.

Collapse
 
atom3333 profile image
Thomas Ferrand • Edited

Makes me think, why can't a language have both development compilation (i.e. fast, therefore, faster dev cycle, but not sacrificing developer's experience); and slow compilation (i.e. highly optimized)?

I don't think there is a reason it wouldn't be possible, it just need to be done and might have already been. I haven't tried newer language like rust, zig and the like yet so maybe one of them offer this and I don't know