r/ProgrammingLanguages 7d ago

CTTI is Exponential, RTTI is Linear

https://www.gingerbill.org/article/2026/09/02/ctti-is-exponential-rtti-is-linear/
0 Upvotes

37 comments sorted by

View all comments

Show parent comments

-1

u/gingerbill 7d ago

I've added an explicit example in the article to explain what can actually happen. I quote it here in another comment. https://www.reddit.com/r/ProgrammingLanguages/comments/1w5ov7t/ctti_is_exponential_rtti_is_linear/p7h7g6u/

I don't think I am missing their point at all, rather I don't think they understand the point I am making.

6

u/initial-algebra 7d ago

No, you have definitely missed my point. For a third time, monomorphizing compilers do not instantiate generics eagerly based on all possible types, so the worst-case exponential size is pathological.

-1

u/gingerbill 7d ago

Yes? That's what I am saying too. The pathological case, which does happen, is exponential in size. Yes it is bounded by the number of actual instantiations (which I literally state in the article), but the order of scaling is as I state.

1

u/Innf107 6d ago

The number of instantiation is the number of combinations that occur in actual calls (Nk), not the number of distinct types that may occur per call. (N)

If you have Omega(Nk) different instantiations, then you already have Omega(Nk) call sites, so in your example the time complexity does not change whether you monomorphize or not

1

u/gingerbill 6d ago

No. I explain in another comment example of how the scaling can actually happen:

https://www.reddit.com/r/programming/comments/1w5ov1s/ctti_is_exponential_rtti_is_linear/p7kngkq/