On 12/11/11 9:14 AM, Chad J wrote:
On 12/11/2011 08:15 AM, maarten van damme wrote:
...

I was only trying it "for the fun of it", not to be used seriously. D
should always have it's GC support built-in and have some functions to
control it's behaviour (core.memory). But I think that D, beeing a
systems programming language, should also be able to be used without GC.
I don't mean phobos to be writtin without a GC in mind but druntime
should be compilable with something like a -nogc flag that make it
usable without GC.

There are a lot of users out there who think that a GC produces terribly
slow programs, big hangs while collecting,... (thank java for that.
Right now the java GC has been improved and it's extremely good but the
memory stays :p)
Letting them know that D can be run without GC can be a good point. If
they don't like it, they can turn it off.

I think one thing that could would be (optional) reference counting for
transitively atomic types.  Of course, this is just another kind of
garbage collection, but it is /deterministic/ and parallelizes well, and
I bet this would open up a large amount of Phobos while the
stop-the-world collector is offline, and with little or no code change.

I think the language has enough (in theory) and nearly enough (in practice) expressiveness to implement reference counted classes in a library, virtually transparently. I mean one could define a template RefCounted (an extended version of what's now in std) such that this pattern is possible:

// client code
class WidgetImpl {
  ...
}

alias RefCounted!WidgetImpl Widget;

Aside from using WidgetImpl in type relationships, using Widget would transparently insert the appropriate reference counting without otherwise interfering with normal WidgetImpl semantics.


Andrei

Reply via email to