OSNews article about C++09 degenerates into C++ vs. D discussion

John Reimer terminal.node at gmail.com
Fri Nov 24 11:52:20 PST 2006


On Thu, 23 Nov 2006 13:25:29 -0800, Steve Horne  
<stephenwantshornenospam100 at aol.com> wrote:

> On Wed, 22 Nov 2006 09:20:17 +0000 (UTC), Boris Kolar
> <boris.kolar at globera.com> wrote:
>
>> == Quote from Steve Horne (stephenwantshornenospam100 at aol.com)'s article
>>> Most real world code has a mix of
>>> high-level and low-level.
>>
>> True. It feels so liberating when you at least have an option to
>> cast reference to int, mirror internal structure of another class,
>> or mess with stack frames. Those are all ugly hacks, but ability to
>> use them makes programming much more fun.
>>
>> The ideal solution would be to have a safe language with optional
>> unsafe features, so hacks like that would have to be explicitly marked
>> as unsafe. Maybe that's a good idea for D 2.0 :) If D's popularity
>> keeps rising, there will be eventually people who will want Java or
>> .NET backend. With unsafe features, you can really put a lot of extra
>> power in the language (opAssign, opIdentity,...) that may work or may
>> not work as intended - but it's programmer's error if it doesn't
>> (intimate knowledge of compiler internals is assumed).
>
> Hmmm
>
> C# does that safe vs. unsafe thing, doesn't it. My reaction was
> basically that I never used the 'unsafe' stuff at all. I learned it,
> but for anything that would need 'unsafe' I avoided .NET altogether.
>
> Why?
>
> Well, what I didn't learn is exactly what impact it has on users. As
> soon as I realised there is an impact on users, I felt very nervous.
>
> If code could be marked as unsafe, and then be allowed to use some
> subset of unsafe features, I'd say that could be a good thing. But it
> should be an issue for developers to deal with, not users.
>
> D is in a good position for this, since basically unsafe blocks should
> be highlighted in generated documentation (to ensure they get more
> attention in code reviews etc).
>
> Also, possibly there should be a white-list of unsafe blocks to be
> allowed during compilation - something that each developer can hack
> for his own testing builds, but for the main build comes from some
> central source. Unsafe modules that aren't on the list should trigger
> either errors or warnings, depending on compiler options.
>


I think one problem with labeling things "unsafe" is that it could imply  
"buggy" or something else perhaps.  It's an unkown and the implication  
might /not/ be a popular one in large software projects.  I'm not quite  
sure how to express that thought completely, though.  I just wonder if  
developers might look at "unsafe" code section and think "why is it even  
here if it's unsafe?".  Would NASA like to have "unsafe" code in their  
projects? What does it really mean?  Does it have different meanings for  
different language?  I know Modula 3 went that route and obviously thought  
it was a good idea; but, then again, Modula 3 didn't catch on.

Another issue: C# is designed to be a VM-based language, while D is  
designed to be a both a general purpose language and a systems programming  
language.  It seems to me that an "unsafe" keyword has different  
implications on each language platform, given their different focus. While  
I understand the idea of "unsafe", I wonder at how such a term might  
affect D's representation as a system programming language.  What might  
work well for a VM-based language, might not be very good for D. Or it may  
be the other way around.  Either way, I don't think comparing C# and D can  
be done on the same level in this regard.

D likely has to work out these ideas on it's own merit, given the domain  
it's creating for itself.

-JJR



More information about the Digitalmars-d mailing list