Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

The developers of the Dart language tell that there is a virtual machine that executes statements written in Dart language. What is the difference between an interpreter and a virtual machine that executes a language?

Until now the virtual machines that I knew, like Java Virtual Machine, Common Language Runtime, and Dalvik all execute bytecode that has been previously compiled from a programming language.

How does it work a virual machine that executes directly a programming language?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

It probably works just as a normal Virtual Machine just instead of translating bytecode into machine code it translates the language into machine code. This might be different from an interpreter by having a JIT compiler which starts to compile the code into machine language and keeps this code to be run while an interpreter translates into machine code each time an instruction is executed.

share|improve this answer

And how do you think the bytecode got created? Most probably something read the statements written in a language and converted it to bytecode. For example Java and C# compilers both do this.

Dart VM just skips this step and reads the statements directly. It is actually quite common for interpreted languages to do that. For example JavaScript and PHP were both like this before it became necessary to improve performance, and add the bytecode-generation step into the runtime process.

share|improve this answer
    
Thank you for the answer. I have modified my question adding the comparison with an interpreter. How does such machine compare to an interpreter? –  Vitalij Zadneprovskij Nov 16 '13 at 7:25
1  
@VitalijZadneprovskij There is no difference. Interpreters are usually virtual machines. –  Euphoric Nov 16 '13 at 7:30

The 1K (not a typo) Basic for the earliest home computers, and their beefier descendents, worked by interpreting directly from the source code. Bill Gates was no slouch!

share|improve this answer
    
Not quite true. Atari BASIC, for example, internally stored statements in binary "tokenized" form. (I think GW-BASIC did too.) –  dan04 Nov 16 '13 at 19:39
    
CBM BASIC also stored a tokenized bytecode (of sorts). –  greyfade Nov 16 '13 at 20:13
    
+1 for the "historical" reference! :-) –  Vitalij Zadneprovskij Nov 18 '13 at 9:01
    
@dan04: I'd say you and ddyer are both right. The common microcomputer BASIC interpreters executed directly from source code which was stored in a slightly-compressed format. The fact that the code is slightly compressed doesn't make it "not source code", since the compressed form is the "official" editable version of the code. –  supercat Feb 16 at 22:42
    
One of my earliest memories of "they did what??" was with a pdp-8 basic, where the parser was clearly only using first letter plus length of keywords. print n could be written as plod on. –  ddyer Feb 17 at 23:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.