TIL that generics and/or templates can cause a measurable code bloat at scale. We are talking tens and possibly hundreds of megabytes, depending how many classes you have. I operated under an assumption that even for a big project you'd only loose a meg or two, and storage is measured in terabytes anyway. But even in the world of 100GbE senselessly large binaries cause issues when you have to deploy to thousands of nodes.
@pro Yeah, because in C++ it's basically cutting and pasting the code, and stamping the object that is in the <>'s into place. No code sharing between instances of that object, so if you have a template that compiles out to a megabyte of code, and you use it for 100 different object types, then that's 100 megabytes of code used by that class.
But also yeah, we have enough storage where it's not the problem that it used to be, but it was why I didn't use templates on my code when I had only 2 megabytes of flash storage on the devices I was writing for.
But also yeah, we have enough storage where it's not the problem that it used to be, but it was why I didn't use templates on my code when I had only 2 megabytes of flash storage on the devices I was writing for.
- replies
- 0
- announces
- 0
- likes
- 0