Smart pointers instead of GC?

Joseph Cassman jc7919 at outlook.com
Mon Feb 3 07:34:37 PST 2014


On Sunday, 2 February 2014 at 16:55:35 UTC, Andrei Alexandrescu 
wrote:
> I think of the following foci for the first half of 2014:
>
> 1. Add @nullable and provide a -nullable compiler flag to 
> verify it. The attribute is inferred locally and for white-box 
> functions (lambdas, templates), and required as annotation 
> otherwise. References not annotated with @nullable are 
> statically enforced to never be null.
>
> 2. Work on Phobos to see what can be done about avoiding 
> unnecessary allocation. Most likely we'll need to also add a 
> @nogc flag.
>
> 3. Work on adding tracing capabilities to allocators and see 
> how to integrate them with the language and Phobos.
>
> 4. Work on the core language and druntime to see how to 
> seamlessly accommodate alternate GC mechanisms such as 
> reference counting.
>
>
> Andrei

This is an excellent direction to take the language in the 
near-term. It seems that some who would like to use D are afraid 
of the GC. Others have legitimate use-cases where the effort of 
manually managing memory is warranted, such as a 
memory-constrained environment. Being able to accommodate both, 
provide an integrated approach to allocation, and allow for 
ref-counting as a viable alternative to GC is a home run. Also 
will be nice to see Phobos memory usage trimmed down. I feel that 
these items mentioned above combined will put D into a niche that 
other languages will find it difficult to compete with: 
end-to-end fine-grained memory control. Nice!

Just my 10 cents.

Joseph


More information about the Digitalmars-d mailing list