December 11, 2011
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.

The big example in my mind is strings.  Strings are straight-up atomic.
 They can't have the reference cycles that would confuse a reference
counter.  And if we allowed them to be reference-counted, then all of
the string functions using copy-on-write would now work with the
stop-the-world collector disabled.

It's something I've been thinking of mentioning for a while, but I suspect there are higher priority things at the moment.
December 11, 2011
Actually this could be good idea, it is after all where
Objective-C (with ARC) and C++ on Windows (C++/CX) are
moving to.

But there can be some performance issues nonetheless. I
am no GC expert, but I think in most cases the overhead
imposed by increment/decrement operations looses against
most advanced GC in use today.

--
Paulo

Am 11.12.2011 16:14, schrieb Chad J:
> 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.
>
> The big example in my mind is strings.  Strings are straight-up atomic.
>   They can't have the reference cycles that would confuse a reference
> counter.  And if we allowed them to be reference-counted, then all of
> the string functions using copy-on-write would now work with the
> stop-the-world collector disabled.
>
> It's something I've been thinking of mentioning for a while, but I
> suspect there are higher priority things at the moment.

December 11, 2011
Paulo Pinto Wrote:

> Actually this could be good idea, it is after all where
> Objective-C (with ARC) and C++ on Windows (C++/CX) are
> moving to.
> 
> But there can be some performance issues nonetheless. I
> am no GC expert, but I think in most cases the overhead
> imposed by increment/decrement operations looses against
> most advanced GC in use today.

There is only one way to really settle pro/anti GC discussions, and that is optional compilation with  or without gc, refcounting etc. That is only way to get the facts how much does GC slows program down (or not :)

I am pro GC definitely for simple reason it increases productivity significantly.

But in systems world there will always be significant number of people with doubt in any GC implementation, or just with a desire to do their own memory management. I think that group of people is important and we should do what we can to attract them to D.

December 11, 2011
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
December 11, 2011
On Sun, 11 Dec 2011 18:12:29 +0200, Bane <branimir.milosavljevic@gmail.com> wrote:

> There is only one way to really settle pro/anti GC discussions, and that is optional compilation with  or without gc, refcounting etc. That is only way to get the facts how much does GC slows program down (or not :)
>
> I am pro GC definitely for simple reason it increases productivity significantly.
>
> But in systems world there will always be significant number of people with doubt in any GC implementation, or just with a desire to do their own memory management. I think that group of people is important and we should do what we can to attract them to D.

Yep, all the GC discussion i have seen people trying to divert it to a MM war.
In reality, that is if you ignore PL bigots, problem is so simple. GCs fail big time on some specific
tasks. (games are one of the best examples). Now if someone comes up with a GC that fulfills this need,
NO sane programmer would use MMM. There is no pro or anti on this issue. It is just the practical failure of GC implementations.
December 11, 2011
Really?

Tell that to all game studios developing games in Java/C#/Flash.

Do you know that many games in iPhone are done in Unity, which
makes use of C#/Boo/Javascript compiled to native code?


Am 11.12.2011 17:29, schrieb so:
> On Sun, 11 Dec 2011 18:12:29 +0200, Bane
> <branimir.milosavljevic@gmail.com> wrote:

> Yep, all the GC discussion i have seen people trying to divert it to a
> MM war.
> In reality, that is if you ignore PL bigots, problem is so simple. GCs
> fail big time on some specific
> tasks. (games are one of the best examples). Now if someone comes up
> with a GC that fulfills this need,
> NO sane programmer would use MMM. There is no pro or anti on this issue.
> It is just the practical failure of GC implementations.

December 11, 2011
Am 11.12.2011 17:12, schrieb Bane:
> Paulo Pinto Wrote:
> But in systems world there will always be significant number of people with doubt in any GC implementation, or just with a desire to do their own memory management. I think that group of people is important and we should do what we can to attract them to D.
>

Those people will eventually become irrelevant.

As I mentioned in a previous email, if I want to use a language without GC for systems programming I already have C, C++, Delphi, you name it. Why pick D then?

December 11, 2011
Would this then be the shared_ptr<>/weak_ptr<> in D?

Am 11.12.2011 17:21, schrieb Andrei Alexandrescu:
> 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

December 11, 2011
On 12/11/11 10:36 AM, Paulo Pinto wrote:
> Would this then be the shared_ptr<>/weak_ptr<> in D?

Better than those actually, because things can be arranged such that the user has no access to the native reference.

Andrei
December 11, 2011
On Sun, 11 Dec 2011 18:33:07 +0200, Paulo Pinto <pjmlp@progtools.org> wrote:

> Really?
>
> Tell that to all game studios developing games in Java/C#/Flash.
>
> Do you know that many games in iPhone are done in Unity, which
> makes use of C#/Boo/Javascript compiled to native code?

I don't understand sorry, are you arguing against the argument i made on GCs failure on some specific areas?