Inherent code performance advantages of D over C?

Rainer Schuetze r.sagitario at gmx.de
Fri Dec 13 05:07:30 PST 2013



On 12.12.2013 19:46, Adam D. Ruppe wrote:
> On Thursday, 12 December 2013 at 17:56:12 UTC, Walter Bright wrote:
>> 5. thread local storage
>
> I think this is a negative. D's TLS has caused me more problems than it
> has fixed: for example, if you write an in-process COM server in Windows
> XP, it will crash the host application if you hit almost any druntime
> call. Why? Because the TLS stuff isn't set up properly when the dll is
> loaded.
>
> Windows Vista managed to fix this, but there's a lot of people who use
> XP, and this is a big problem.

Implicite TLS in XP-DLLs has a workaround in druntime for a few years 
now (emulating it for the system). IIRC Denis has even found a solution 
how to unload these DLLs later.

It's great to have thread local data easily available, but I'm not 
completely sold on thread-local by default, too. One disadvantage is 
that both memory and initialization code affect any thread, even if it 
does not use TLS at all. This doesn't scale for large programs.

Usually you should not create a lot of global variables, and if I do, I 
mostly want them shared. But coming from C++ I often tend to forget to 
add the modifier. I remember a few years ago, almost every occurrence of 
TLS in phobos was converted to shared or immutable...


More information about the Digitalmars-d mailing list