www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Rust style memory management in D?

reply "Walter Gray" <walter.r.gray gmail.com> writes:
I've been looking into alternatives to C++ and have been 
following D since back in the D1 Tango/Phobos days, and recently 
started digging in again.  I'm quite impressed with the progress, 
and I've started a simple toy game project to test out some of 
the language features.  One thing that really bothers me as 
someone who works on applications where responsiveness is 
critical and even 50ms delays can cause problems is the GC though 
- It seems to be that the only really good answer is to to just 
use malloc & free from the standard library, but that seems 
really awful for such an elegant language.  Every area but memory 
management is beautiful and can do what you like, but trying to 
avoid the GC is downright painful and forces you to ditch much of 
the safety D provides. Given that it is designed to be a systems 
programming language & in such applications memory management is 
so important, this seems like a tremendous oversight.

In my searching, I ran across Rust, which is relatively new and 
takes a rather different approach to a lot of things, including 
memory management - making unique shared pointers(~ is used to 
denote them) a language feature along side garbage collection so 
that the compiler can enforce ownership rules. One of the main 
language developers has noted that the unique pointer with 
ownership transfer rules is used so much more than the GC option 
that he's trying to get GC removed from the language and placed 
in the standard library.

Given D's target domain of high performance systems programming, 
this memory management model seems like a radically better fit 
than "screw it, we'll GC everything". I've seen a few other 
people talk about this issue, and the difficulty of avoiding the 
GC seems to be THE argument against D that I wind up seeing. Has 
such a model been considered, and is there a reason (besides the 
fact that the entire standard library would probably have to be 
rewritten) that it isn't used?
Jan 12 2014
parent "Rikki Cattermole" <alphaglosined gmail.com> writes:
Please post on[0] regarding better memory management. As 
currently work is being done on rewriting the GC (which really 
was needed).

[0] http://forum.dlang.org/post/lao9fn$1d70$1 digitalmars.com
Jan 12 2014