Steven Schveighoffer:

>Also, however, C's malloc isn't as likely to explode memory usage because 
>items should be freed when they are no longer used.<

Of course , if we assume perfect programmers, then there's no need of many 
other kinds of safeties present in D code.


> Again, this can be done in the GC code itself, it does not need to be a  
> compiler-defined limit.  My preference is for the default to be unlimited,  
> since this is the most common case.

This is wrong; in the most common case you don't want a program to trash your 
virtual memory and crash your other programs. Only for special programs you 
want no limits.

I am now slowly starting to understand why new languages (Java, C# and all the 
ones created on dotnet and JVM) are designed the other way around compared to 
D: they start from a safe situation and then add (usually safe) optimizations 
to try to become faster. Because starting from C you have no hope of improving 
certain things (some of such things are limits in the brain of people used to 
C).

Thank you for your answers and explanations, I can see there's no use of the 
limit I was talking about. Better to put an external limit to the program, as 
Lars Kyllingstad has shown, or maybe to add a memory limit to the GC, that can 
defined at run-time.

--------------

Justin Johansson:

>Can you please explain why you think this is useful?<

To make D programs a bit safer. On Windows if you have 5 programs running, and 
one of them eats too much RAM, the system starts swapping, everything starts 
running very slowly, some other programs crash, etc. This is not nice. So if I 
write a small buggy program to process a large amount of genomic data I'd like 
a bug in my code to avoid that out of memory situation. But Steven 
Schveighoffer has just explained why my idea can't work in D. So sorry for all 
the noise :-)


>Assuming the idea is useful, why would you have to be a compiler option rather 
>than, say, a linker option?<

I don't care of linkers. They are an implementation detail that in a modern 
language I want to be able to ignore in most times, unless I'm doing something 
special (and the situation I am discussing here is not special at all, I think 
of it as the default one). To use a car designed in 2008 I don't want to do all 
the things you have to do to start a car designed in 1940 :-) I want it to work 
in a simpler way, even if inside it's probably more complex.

Bye,
bearophile

Reply via email to