3 ms·
> "monomorphize everything" approach can explode your code size surprisingly fast. It can in the naive implementation. Early C++ was famous for code bloat and
by SomeCallMeTim 5y ago
> "monomorphize everything" approach can explode your code size surprisingly fast.
It can in the naive implementation. Early C++ was famous for code bloat and (apparently) hasn't shaken that outdated impression.
In practice, monomorphization of templates hasn't been a serious issue in C++ for a long time. The compiler and linker technologies have advanced significantly.
- asdfasgasdgasdg 5y ago> Early C++ was famous for code bloat and (apparently) hasn't shaken that outdated impression. It's not an outdated impression. C++ generics can and do interact very poorly with inlining and other language features to cause extremely large binary sizes, especially if you do anything complex inside them. They also harm compilation performance since each copy of the generic code needs to be optimized. Generics in C++ are reasonably efficient when there is relatively little code generated per generic, but when this is not true, they can be a problem.
- titzer 5y ago> The compiler and linker technologies have advanced significantly. AFAICT the linker de-duplicates identical pieces of machine code. You still can get multi-megabyte object files for every source file. I used to work on V8. Almost every .o is 3+MB. Times hundreds, plus bigger ones, it's more than a gigabyte of object files for a single build. That's absurd. Not V8's fault--stupid C++ compilation and linking model.