On Saturday, October 22, 2011 01:20:05 Sean Silva wrote: > == Quote from Trass3r (u...@known.com)'s article > > > Am 20.10.2011, 00:06 Uhr, schrieb Sean Silva > > <chisophu...@gmail.com>: > > > == Quote from Jesse Phillips (jessekphillip...@gmail.com)'s > > article > > > >> Right now D isn't ready to be used in this fashion > > > > > > It looks there's a more-or-less functional kernel written in D > > (and > > > > pretty well documented too): > > > http://wiki.xomb.org/index.php?title=Main_Page > > > > "You do not need the Tango standard library to compile XOmB as it > > contains > > > its own standard calls and runtime." > > that was my point ... that it seems that D *is* "ready to be used in > this fashion" ;)
You _can_ use D with no to minimal GC, but you have to be very careful. A good chunk of the standard library would be completely unusable without the GC (primarily anything which might allocate or append to an array), you have to be very careful when using arrays (since appending to them wouldn't work, and you have to worry about who owns an array so that slices don't result in memory leaks or you using a slice which has already be freed), and there are some cases where something might allocate using the GC when you don't expect. For instance. int[3] a = [1, 2, 3]; currently allocates a dynamic array which is the copied into the static array. It shouldn't allocate like that, and it _will_ be fixed so that it doesn't, but for now it does. Generally, I'd say that the best way to deal with D is to just not worry about the GC until you profile your code and see that it's a problem. If don't need inheritance and so are using primarily structs rather than classes, you often don't need to allocate much on the heap. If you're not doing a lot with classes, the primary thing on the heap would be arrays (including strings). But if you're smart about avoiding unnecessary allocations, the abilities that the GC gives you with arrays (such as concatenation and the ability to use slices without worrying about how many references to it there are) are well worth it. Essentially, as long as you avoid constantly allocating stuff on the heap, the GC shouldn't cause you much trouble. - Jonathan M Davis