safety model in D

Leandro Lucarella llucax at gmail.com
Thu Nov 5 19:39:14 PST 2009


dsimcha, el  6 de noviembre a las 02:13 me escribiste:
> == Quote from Leandro Lucarella (llucax at gmail.com)'s article
> > Andrei Alexandrescu, el  5 de noviembre a las 09:57 me escribiste:
> > > Leandro Lucarella wrote:
> > > >Andrei Alexandrescu, el  5 de noviembre a las 08:48 me escribiste:
> > > >>First off: _all_ languages except C, C++, and assembler are or at
> > > >>least claim to be safe. All. I mean ALL. Did I mention all? If that
> > > >>was some ideology that is not realistic, is extremely difficult to
> > > >>achieve, and ends up too painful to use, then such theories would be
> > > >>difficult to corroborate with "ALL". Walter and I are in agreement
> > > >>that safety is not difficult to achieve in D and that it would allow
> > > >>a great many good programs to be written.
> > > >
> > > >I think the problem is the cost. The cost for the programmer (the subset
> > > >of language features it can use is reduced) and the cost for the compiler
> > > >(to increase the subset of language features that can be used, the
> > > >compiler has to be much smarter).
> > > >
> > > >Most languages have a lot of developers, and can afford making the
> > > >compiler smarter to allow safety with a low cost for the programmer (at
> > > >least when writing code, that cost might be higher performance-wise).
> > >
> > > D is already a rich superset of Java. So the cost of making the
> > > language safe and useful was already absorbed.
> > That's an unfair comparison. Java has a very efficient GC (partially
> > because of safety), so using D as it were Java yields very inefficient
> > programs (using classes and new all over the places).
> 
> Why does safety have to do w/ Java's GC quality?

Because you don't have unions and other things that prevents the GC from
being fully precise.

> IMHO it's more a language maturity and money thing.

That's another reason, but the Boehm GC is probably one of the more
advanced and state of the art GCs and I don't think it's close to what the
Java GC can do (I didn't see recent benchmarks though, so I might be
completely wrong :)

> The only major constraint on D GC is unions and even in that case, all
> we need is one bit that says that stuff in unions needs to be pinned.
> I think we already agree that storing the only pointer to GC allocated
> memory in non-pointer types, xor linked lists involving GC allocated
> memory, etc.  are undefined behavior.  Other than that and lack of
> manpower, what prevents a really, really good GC from being implemented
> in D?

Having a precise stack and registers. Java has a VM that provides all that
information. Maybe the distance between a good Java GC and a good D GC can
be narrowed a lot, but I don't think D could ever match Java (or other
languages with full precise scanning).

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
I always get the feeling that when lesbians look at me, they're thinking,
'*That's* why I'm not a heterosexual.'
	-- George Constanza



More information about the Digitalmars-d mailing list