Safe mode in D?

Maxim Fomin maxim at maxim-fomin.ru
Sat Oct 19 03:39:25 PDT 2013


On Saturday, 19 October 2013 at 09:06:35 UTC, Max Samukha wrote:
> On Saturday, 19 October 2013 at 08:38:52 UTC, Maxim Fomin wrote:
>> On Saturday, 19 October 2013 at 08:21:18 UTC, Max Samukha 
>> wrote:
>>> On Saturday, 19 October 2013 at 07:39:36 UTC, Maxim Fomin 
>>> wrote:
>>>>
>>>> This is wrong. Compare safe D and C# in safe, checked mode 
>>>> (I suspect you tried to sell unchecked mode, unmanaged 
>>>> pointers and C++ code invocation as unsafe C# - there are 
>>>> also unsafe features like casts or unions in unsafe D, but 
>>>> this is irrelevant, we are comparing safe mode) and try to 
>>>> come up with examples of memory corruption in C#. At least I 
>>>> showed 4 cases of memory corruption, 4 cases of broken 
>>>> immutable, 2 cases of broken purity in safe D without casts, 
>>>> unions and unchekeced attributes of extern C (which is also 
>>>> hole in type system). So far, you provided only resentment 
>>>> that D was negatively compred with C#.
>>>
>>> I would agree if:
>>>
>>> 1. most of the cases you provided were not compiler bugs.
>>
>> Wrong. Most of cases presented are frontend bugs, since all 
>> three
>> known compilers share the same frontend, they are also buggy. 
>> In
>> any case, D is not in a position like C, where there are plenty
>> of compilers. Most are stack to dmd/gdc/ldc. So, there is no 
>> way
>> to escape from this "just compiler bugs". You can throw "it is
>> compiler bug, but not language issue" into the trash (please 
>> also
>> D butthurt).
>
> Note that you are making similar assumptions about the state of 
> my butt as I did about your dissatisfaction.
>

Right. This talks need to go away.

>>
>>> 2. C#'s safety didn't have a price.
>>
>> I didn't heard that C# would advertise itself as having speed
>> 'more than C' or any nonsense like D promises about its safety.
>
> I haven't heard D ever advertised itself as "faster than C". I 
> heard that immutability/purity provides an opportunity for 
> optimizations not possible in C, and those opportunities have 
> not been realized yet.

The point is shifted. The claim on D site pages are that it 
supports safe mode which disallows undefined behavior. Rebuttal 
are that this it not true - @safe is currently broken due to 1) 
basing on static type rather than runtime which limits 
significantly ability to query which things are right and which 
things are not safe 2) because there are particular cases which 
shows safety breakages. (Why this is still relevant to the 
language and not only to compilers was discussed). It is bad to 
promise something which you are not able to deliver.

In contrary (because C# was mentioned and thread engaged into 
comparison) C# when it claims to support safety, it actually 
support safety. Features which it cannot support, are not claimed 
to be supported. You mentioned performance, so I made a point 
that C# does not claim to be, for example, faster than C. Such 
claim does not make much sense, as much as claiming that D safe 
mode prevents from undefined behavior. It was used for 
comparison, not for claiming that D really claims to be faster 
than C.

>>
>>> 3. C# had immutable, pure, etc.
>>
>> But features which it does care to provide, are not bunch of
>> holes in type system. This is so opposite to D with strings,
>> shared, AAs, etc.
>
> What's wrong with D's strings?

Problem is that it uses char array of 1 byte to hold data which 
has size more than 1 byte. It was discussed in "Inconsistency" 
thread 
(http://forum.dlang.org/thread/hoopiiobddbapybbwwoc@forum.dlang.org).


More information about the Digitalmars-d mailing list