Remember the Vasa! by Bjarne Stroustrup

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue May 29 21:06:52 UTC 2018


On Wednesday, May 30, 2018 08:43:33 rikki cattermole via Digitalmars-d 
wrote:
> On 30/05/2018 8:37 AM, Tony wrote:
> > On Tuesday, 29 May 2018 at 20:19:09 UTC, bachmeier wrote:
> >> I don't think it's difficult to do that yourself. There's no need to
> >> have a formal split. One example is that it's really nice to have the
> >> GC available for part of the program and avoid it for another part.
> >> @nogc gives you a guarantee. Different variants of the language are a
> >> special case of this that is equivalent to annotating the entire
> >> program to restrict behavior. That's rarely desirable.
> >
> > What would be an example of a type of application (or maybe that should
> > be "which type of domain" or "which type of developer") where you would
> > want part of it to do garbage collection and the rest of it do not do
> > garbage collection?
>
> GUI's, audio systems, language tooling, games, I'm sure somebody can
> come up with a much more longer list.

Basically, stuff that can't afford to have the GC pause the program for more
than a millisecond or two has to be careful with the GC, but your average
program is going to be perfectly fine with it, and in many cases, it's just
part of the program that can't afford the pause - e.g. a thread for an audio
or video pipeline. The rest of the program can likely afford it just fine,
but that thread or group of threads has to be at least close to realtime, so
it can't use the GC. It's kind of like @safe vs @system. It's not uncommon
for most of your program to be able to be @safe just fine, but certain stuff
just can't be. However, that's not necessarily a good reason to make it so
that the entire program is @system. So, you make that piece @sytem and use
@trusted appropriately. With the GC, you typically use it and then turn it
off or avoid it in select pieces of code that can't afford it. In most
cases, it should not be necessary to avoid it entirely even if you can't
afford it in part of your program (though as with pretty much everything,
there are bound to be exceptions).

- Jonathan M Davis



More information about the Digitalmars-d mailing list