On Sat, Nov 14, 2020 at 2:54 AM kev kev <kevthemusic...@gmail.com> wrote:

> Oh right, I seem to not understand why golang is faster in that respect.
> If you can include the precompiled headers and or have an object file
>
>
The key point is that in C++, declarations in header files tend to be
leaky, especially in larger projects. That is, your class includes some
private declarations, but those are listed in the (public) header file.
This happens transitively/recursively through your whole header file import
hierarchy. This means the header file needs to pull in dependent header
files in order to satisfy declarations in the private area of the class, yet
since they are not publicly facing, this creates a need for parsing more
code for a given compilation, slowing down the compiler: you still have to
look at every byte to parse, and you can only throw information away once
you have analysed which parts you are actually using in the compilation
unit. To boot, C++ is a rather complex language to parse, where you may
need more than a single pass over the declarations in order to figure out
what is going on.

It also creates a situation where changing some of the foundational header
files in the project results in large recompilations of everything because
there is a potential for things to have changed.

The traditional way of solving this has been to cache heavily and only
recompile if need be. However, caching only helps you so much if you are
leaking in header files all over the place.

In contrast, Go's design plugs this hole.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAGrdgiWMSdGfZ1%3D%2Bh2%3D0%2BLBCwsVcmh1LVCbAD%2By%3DcN%3D5YPxbww%40mail.gmail.com.

Reply via email to