Java > Scala

Regan Heath regan at netmail.co.nz
Thu Dec 1 07:31:11 PST 2011


On Thu, 01 Dec 2011 12:24:13 -0000, Jacob Carlborg <doob at me.com> wrote:

> On 2011-12-01 12:26, Regan Heath wrote:
>> On Wed, 30 Nov 2011 22:04:13 -0000, Timon Gehr <timon.gehr at gmx.ch>  
>> wrote:
>>
>>> The quite common claim that you cannot use Phobos without cluttering
>>> up all your code with allocations is just not true. Phobos is not an
>>> Object-oriented class library. There are seldom hidden allocations,
>>> and it is almost always obvious when allocations must happen. The most
>>> useful high-level features of D are compile time features that do not
>>> harm performance (on the contrary).
>>
>> But, it is true you cannot use the ~ operator on strings without
>> involving the GC, right?
>>
>> Maybe this isn't a problem for people who want to manually manage memory
>> for performance reasons but it is right at the very lowest levels of
>> "what is D" and it seems like something where it should be possible to
>> choose how the memory for a string is allocated etc.
>>
>> R
>>
>
> You can replace the garbage collector with your own implementation.

True, and any serious game dev or similar workshop using for performance  
critical code probably will.  And, I realise improving the existing GC and  
writing several more different GC implementations to make swap-in-out as  
easy as a compile time switch is still low on the priority list, for good  
reason.

But, it does mean that writing code in D without the GC is not trivial and  
the problems are sometimes subtle.  Problems that can be glossed over by a  
statement saying you can manually manage memory in D - which while  
technically true is not actually true in any meaningful way.  Ideally, and  
I'm sure we'll get there eventually, we should be able to turn the GC on  
and off with a flag at compile time, and no other code changes (WRT how  
phobos and druntime handle memory).  Which probably means that memory  
allocated within phobos/druntime needs a 'delete' or similar statement  
which is a no-op in the presence of GC, and a 'free' otherwise.  Or some  
similar construct.

Regan

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d mailing list