D, Java? To D or not to D?

Sean Kelly sean at f4.ca
Fri Jan 5 20:00:36 PST 2007


Frits van Bommel wrote:
> Sean Kelly wrote:
>> Frits van Bommel wrote:
>>> Oh, I must've read it wrong. I thought this was about a runtime that 
>>> would automagically compile on any platform... <blush>
>>>
>>> That's different from "independent of OS" though, which seems to be 
>>> what you're thinking of. ("run everywhere" does not equal "run on any 
>>> x86". Not yet anyway ;) )
>>
>> True :)  But it still means quite a bit of portability.  And I could 
>> have misunderstood as well.  I simply couldn't imagine a binary app 
>> compiled for, say, x86 (one instruction set, big-endian) actually 
>> working on PPC (another instruction set, little-endian) without some 
>> sort of JIT compile step.
> 
> x86 is little-endian, PPC can IIRC be set to either, but is typically 
> (i.e. on PPC Macs) set to big-endian.

Oops, I had it backwards, you're right.  A bigger issue is 64 vs. 32-bit 
code.  At some point, the architectural differences are simply too great 
for binary portability of even user code.

>> The differences are probably in the executable startup code, the 
>> thread code, memory allocation, some portions of garbage collection, 
>> etc, all of which could theoretically be abstracted to a runtime 
>> library (in a sense, they already are: Phobos).  The issue would be 
>> figuring out how to go from the command prompt to running the proper 
>> version of everything.  Would a link step be required first?  Would 
>> the runtime library actually contain multiple versions of the code for 
>> different OSes and call the appropriate one dynamically?  Or perhaps 
>> the runtime could be in a dynamic lib that's loaded by some startup 
>> code linked into the app?  Note that none of these are Virtual Machine 
>> situations because the code is running natively in all cases.
> 
> Before you consider how the runtime is linked to the app, first consider 
> how the app starts in the first place. Let's say the bare minimum is x86 
> Linux and Windows compatibility.
> 
> I don't think there's currently any way to have it run directly on 
> Windows and Linux simply because there's AFAIK no executable format 
> that's supported by both OSs (ELF is supported on multiple OSs, but 
> Windows doesn't support it). Furthermore, all executable formats I know 
> of (except for plain binary, which AFAIK Linux doesn't support[1]) have 
> some (unique) signature in the first few bytes, so a file can't be 
> multiple of these formats at the same time.

Hrm, right.  So there would probably have to be either a configuration 
step before the initial run or some sort of translation or linking that 
took place.  I'll be curious to see what comes of this.  If Walter can 
sort it out in a nice clean manner, it would be a killer feature.


Sean



More information about the Digitalmars-d mailing list