POV-Ray : Newsgroups : povray.off-topic : Learning C# : Re: Learning C# Server Time
29 Jul 2024 06:18:22 EDT (-0400)
  Re: Learning C#  
From: Darren New
Date: 29 Sep 2012 19:40:47
Message: <506786ff@news.povray.org>
On 9/29/2012 12:44, Warp wrote:
> Darren New<dne### [at] sanrrcom>  wrote:
>> Well, C++'s target platforms include things that C# isn't targeted at. If
>> you're trying to fit your code into a credit card terminal, you're going to
>> be worried about C++ template code bloat and the features of C#'s execution
>> model won't even enter the conversation.
>
> "Template code bloat" is a myth with little to no actual evidence.

I said you'd be worried about it. I didn't necessarily say the worries were 
justified. :-)

> If you need the same code to handle more than one type, you have to do that
> somehow. Either you duplicate the code for each type, or you use runtime
> polymorphism, or alternatively you use some really contrived code full of
> conditionals that checks the actual type of the data when it tries to use it.

I think if you have the code for several different pointer types, and you 
deal with them all the same way, you might have multiple copies of the same 
code getting compiled, right?

I mean, if you instantiate it over int* and float* and MyClass* and 
YourClass* and ThisWidget* and ThatWidget*, you're going to wind up with six 
copies of that code, right? And if your linker is stupid enough, you're 
going to wind up with copies in every place you use that code.

>> The reason C++ makes more code is that it actually does stuff like inline
>> the right calls, doing type-specific generic expansions.
>
> Inlining can actually *reduce* the size of the binary in some cases (because
> of the subsequent compile-time optimizations).

I'm saying that if you have a collection class instantiated for multiple 
types of pointers, C++ has no choice but to expand each, because you don't 
declare the type in the template. The compiler and linker would need to be 
fairly smart, I'd think, to recognize that myblah.implement(&myBlah) and 
yourblah.implement(yourBlah) both generate identical code because the 
"implement" function doesn't do anything type-specific with the blahs.

-- 
Darren New, San Diego CA, USA (PST)
   "They're the 1-800-#-GORILA of the telecom business."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.