Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

About C++ templates and Delphi generics and code bloat..

25 views
Skip to first unread message

amin...@gmail.com

unread,
Feb 26, 2020, 12:19:35 PM2/26/20
to
Hello,


About C++ templates and Delphi generics and code bloat..

I have just read the following webpage about Delphi generics(that are like templates of C++) and code bloat:

https://boyet.com/blog/delphi-oriented-generics-or-what-a-dog/


I think Julian M Bucknall is way too pessimistic about Delphi, because
what that means is: if you have Unit1.pas and Unit2.pas and both are using TList<Integer> both Unit1.dcu and Unit2.dcu have the binary code for TList<Integer> compiled in, but only when compiling your binary the linker will remove duplicates. So i think Delphi is the same as C++, because notice that C++ also has code bloat with templates:

So read in the following it says:

"In C++ code bloat occurs because compilers generate code for all templated functions in each translation unit that use them. Back in the day the duplicate code was not consolidated resulting in "code bloat". These days the duplicate code can be removed at link time."

Read here:

https://stackoverflow.com/questions/24333345/how-does-template-cause-the-code-bloat-in-c


Thank you,
Amine Moulay Ramdane.

Bonita Montero

unread,
Feb 26, 2020, 1:06:34 PM2/26/20
to
> "In C++ code bloat occurs because compilers generate code for all templated functions in each translation unit that use them. Back in the day the duplicate code was not consolidated resulting in "code bloat". These days the duplicate code can be removed at link time."

"These days" - it has never been different !
0 new messages