D vs. C#

Dave Dave_member at pathlink.com
Mon Oct 22 07:22:19 PDT 2007


"Christopher Wright" <dhasenan at gmail.com> wrote in message 
news:ffi6lh$1cn5$1 at digitalmars.com...
> Dave wrote:
>>
>> "Robert Fraser" <fraserofthenight at gmail.com> wrote in message 
>> news:ffh727$1trc$1 at digitalmars.com...
>>> Walter Bright Wrote:
>>>
>>>> Jussi Jumppanen wrote:
>>>> > I think Microsoft's longer term vision is to have .NET everywhere
>>>> > and I mean everywhere.
>>>>
>>>>
>>>> I've never been able to discover what the fundamental advantage of a VM 
>>>> is.
>>>
>>> I'm sure there are a lot of advantages, but here's one I can think of 
>>> off the top of my head: say you're designing an application for mobile 
>>> devices/smartphones. There are a lot of different phones out there, 
>>> probably all with different APIs (or no native API accessible outside 
>>> the company that made the phone), but if your software is running in a 
>>> VM it'll run the same everywhere. Now say you're a cell phone 
>>> manufacturer introducing a new smartphone -- adding the VM makes all the 
>>> software written to use that platform instantly compatible with your 
>>> device.
>>>
>>
>> Other than some runtime reflection that can be done with a VM (and not a 
>> static binary), I think the only concrete advantage is to compile one set 
>> of bytecode for all platforms instead of one binary for each platform. 
>> But then bytecode can be more easily "decompiled" and copied too.
>>
>> Either way someone has to develop either a VM or a compiler for each 
>> platform. API's are really more a function of a library than a VM, IMO.
>>
>> Runtime reflection aside, I can't think of anything a VM can do that a 
>> static compiler couldn't with the possible (but largely unproven) 
>> exception of sometimes generating better code because of access to 
>> runtime info. For example, static compilers / libraries can do most of 
>> that too if needed (and they can do it w/o the extra runtime overhead of 
>> profiling and re-compiling) by compiling some heuristics right in to the 
>> binary.
>>
>
> One possibility is to do profiling while the application is running and do 
> further optimizations based on that. The questions are, is the VM 
> performance hit worse than the optimizations, and is there a compelling 
> reason not to do those optimizations always?

That's what Sun Hotspot does, but I've rarely seen where the results are 
better than what a static compiler w/ the "-O2" switch can do and often seen 
where they are worse. IIRC (for example) the Jet "Ahead of Time" Java 
compiler can often outperform the Sun VM.

Not that all this really matters for *most* code however, where just 
compiling to native code is a big enough win. But I have seen the old 80-20 
rule at work -- cases where 80% of the time is spent on 20% of the code 
trying to make it run faster -- so it's not a moot point either.




More information about the Digitalmars-d mailing list