Inherent code performance advantages of D over C?

Paulo Pinto pjmlp at progtools.org
Sun Dec 15 02:03:37 PST 2013


Am 14.12.2013 20:33, schrieb Walter Bright:
> 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.

Yes, similar to what is known as open arrays in those languages.

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

True, even with the help of static analysers, it all falls apart the 
moment you have third party code only available in binary format as 
libraries.

No way to validate them in C.

This is where safer languages like D have an edge over C as well.

--
Paulo


More information about the Digitalmars-d mailing list