Inherent code performance advantages of D over C?

Walter Bright newshound2 at digitalmars.com
Sat Dec 14 11:33:49 PST 2013


On 12/14/2013 9:37 AM, Paulo Pinto wrote:
> On Saturday, 14 December 2013 at 17:12:16 UTC, bearophile wrote:
>> Dicebot:
>>
>>
>>
>>> @safe is a joke for barebone, you almost never be able to apply it :)
>>
>> I think you can have some safe functions in C-style code too :-)
>
> Yes, given my experience in Turbo Pascal and Oberon, there are lots of places in
> C-style code that code be safe as well.
>
> For example, there are very few places where dark magic pointer tricks are
> really essential.
>
> Only those code sections really need to be unsafe.

Pretty much all use of pointers in C is unsafe because C cannot statically (or 
dynamically) verify that the pointers point to valid data, or that arithmetic on 
those pointers will result in pointers to valid data.

This is the huge advantage that D's dynamic arrays have.

You can write safe code in C, but you cannot mechanically verify it as safe.


More information about the Digitalmars-d mailing list