D, Java? To D or not to D?

Sean Kelly sean at f4.ca
Fri Jan 5 15:10:21 PST 2007


Frits van Bommel wrote:
> Walter Bright wrote:
>> TPJ wrote:
>>> 1) In order to run a program written in D I have to compile it on the 
>>> target OS.
>>
>> I haven't talked about this much, but it is technically feasible to 
>> create a D runtime that enables "compile once, run everywhere". It is 
>> not necessary to have a VM to do it.
> 
> How would you implement a garbage collector in an 
> architecture-independent way?

I don't think you would.  Rather, I think you'd have a separate runtime 
library for each platform that handled all the necessary back-end tasks, 
but which then called through to the same user-level D program.  This 
would allow you to deal with platform-specific startup requirements, 
memory allocation scheme, executable file layout, etc.  So long as the 
ABI or whatever were sufficiently strict regarding how exception 
handling occurs and a few other details, I think the compiled user code 
would be portable across OSes.  But I'm not sure how this would interact 
with things like calling C libraries built by other compilers.  For 
example, DMD/Linux appears to pad doubles differently than DMD/Win32, so 
how would the D user code know what to do re: pushing the values onto 
the stack?


Sean



More information about the Digitalmars-d mailing list