Preferred method of creating objects, structs, and arrays with deterministic memory management

2016-06-01 Thread Anthony Monterrosa via Digitalmars-d-learn
I've recently been trying to convince a friend of mine that D has 
at least the functionality of C++, and have been learning the 
language over C++ for a few months. Memory management is pretty 
important to him, and a subject I'm honestly curious about as 
well. I was wondering: what's the preferred method for 
deterministic memory management?


I don't know much about this topic relative to most (Java 
background), but this is what I've found:


 - Classes/Structs have constructors and destructors. I am 
unconfident with my knowledge as to how this works with malloc 
and free.


 - core.memory can be used to call malloc and its buddies. It 
allows determined management, but will still use the GC if 
something isn't collected (presumably for leaks).


- Many features and types use the GC such as exceptions, the new 
keyword, and all arrays except statics.


 - Allocators in "std.experimental.allocators" still use the GC, 
but give more control for class/struct objects.


 - std.container.array can be used for deterministic arrays, but 
has the issue of dangling pointers. There is probably a good 
solution to this, but I don't know it.


 - There seems to be no way to completely turn off the GC. That 
is, never have the runtime allocate the memory used by the GC.


 - Andreau had a discussion in 2009 about how this issue might be 
handled, but there didn't seem to be an obvious consensus 
(http://forum.dlang.org/thread/hafpjn$1cu8$1...@digitalmars.com?page=1)


This are the pieces I've gathered, but I don't really know what's 
true or how to use this knowledge. Some ideas I've gleaned may 
also be outdated. Does anyone know the "correct" way one would go 
about a non-GC program, and if a program can be ran without ever 
instantiating a GC? Has there been any progress on reducing the 
std library's usage of the GC?


Necessity of D Library (and/or Core Library)

2015-05-23 Thread Anthony Monterrosa via Digitalmars-d-learn
Does D require the standard library to function? Or to be 
more direct, does D as a language need its library, or core 
library, to function correctly?


I have become very interested in how programming languages do 
their magic; how they interact with the computer itself, and 
their inner mechanics. This eventually led me to resources that 
said the line between a language and its library differs between 
languages, and I was wondering where D stood on that line.


Note: since, I'm already here, does anyone know how D 
manipulates/uses standard streams to make its write/read 
functions as well? I can't find any resources telling me a 
non-abstracted way of this being completed.


P.S. I'm only a freshman computer science student, so if some of 
this should be basic, I simply don't know it yet.


Thanks in advance!