D vs. C#

0ffh spam at frankhirsch.net
Mon Oct 22 00:06:06 PDT 2007


Walter Bright wrote:
> I've never been able to discover what the fundamental advantage of a VM is.

I don't think there are any very fundamental advantages. But there sure 
seem to be a few things that make them attractive for some people.

The most convincing of these revolve around neither run-time nor 
compile-time, but around write-time issues.

In short: They try to make the language implementor's life easy.

We see: The exact opposite of what you're trying to achieve (using C++).

Regards, Frank

Appendix: "Reasons for having a VM"

1. They are a way to separate the compiler back-end from the rest of the 
compiler. Clearly you wouldn't have to implement the VM in this scenario.

2. As far as the oldest VM I know designed for a specific language to be 
executed in is concerned: "UCSD p-System began around 1977 as the idea of 
UCSD's Kenneth Bowles, who believed that the number of new computing 
platforms coming out at the time would make it difficult for new 
programming languages to gain acceptance." (or that's what Wikipedia says).

3. From hxxp://en.wikipedia.org/wiki/P-code_machine:
"a) For porting purposes. It is much easier to write a small (compared to 
the size of the compiler) p-code interpreter for a new machine, as opposed 
to changing a compiler to generate native code for the same machine.
  b) For quickly getting a compiler up and running. Generating machine code 
is one of the more complicated parts of writing a compiler. By comparison, 
generating p-code is much easier.
  c) Size constraints. Since p-code is based on an ideal virtual machine, 
many times the resulting p-code is much smaller than the same program 
translated to machine code.
  d) For debugging purposes. Since p-code is interpreted, the interpreter 
can apply many additional runtime checks that are harder to implement with 
native code."



More information about the Digitalmars-d mailing list