[fpc-pascal] Generics vs templates
ryan at thealchemistguild.com
Tue Jan 9 02:29:02 CET 2018
> On Jan 9, 2018, at 3:30 AM, Graeme Geldenhuys <mailinglists at geldenhuys.co.uk> wrote:
> Recently I did a very simple test with Delphi XE3 using TList<Integer> and a stock TList. Adding 50,000 and 200,000 integer values to each list, and timing the creation of the list and population of the list. Then I also timed the destruction of the list. I was horified to find out how much slower Delphi's Generics were compared to TList and TObjectList. Destruction was 250x slower in many cases. Creation and population of the list was 5x-10x slower.
What does this have to do with generics exactly? If I understand correctly generics are “meta-programming” where they essentially just re-insert a generated class based on the template (c++’s naming scheme makes more sense imo) but they don’t actually add any runtime code.
More information about the fpc-pascal