What do interpreters do, and how are they different than compilers? Are compilers and interpreters used in Java? I've never heard of an interpreter in any other language, do other languages use them?
What are interpreters?
Started by Sionofdarkness, Jul 21 2006 11:34 AM
6 replies to this topic
#1
Posted 21 July 2006 - 11:34 AM
|
|
|
#2
Posted 21 July 2006 - 01:56 PM
When you write a program, you have instructions that are meant to be read by a human. Your computer doesn't know what they mean. To have your computer do something useful with them, you have three options:
1) compile the program to machine code. This is understood by the computer and can be run. (C, C++, Delphi, and many other languages use this option)
2) compile the program to byte code. This can be understood by a virtual machine that acts as to translate the code into instructions. (Java does this)
3) run the code through an interpreter. This is a special program that knows how to read the code and it executes the code for you. This is similar to using a virtual machine, but you can't hide what your code does from other humans. (scripting languages use this option)
1) compile the program to machine code. This is understood by the computer and can be run. (C, C++, Delphi, and many other languages use this option)
2) compile the program to byte code. This can be understood by a virtual machine that acts as to translate the code into instructions. (Java does this)
3) run the code through an interpreter. This is a special program that knows how to read the code and it executes the code for you. This is similar to using a virtual machine, but you can't hide what your code does from other humans. (scripting languages use this option)
#3
Posted 22 July 2006 - 08:32 AM
Alright, but how is that different from a compiler? They still both sound like the same thing.
#4
Posted 23 July 2006 - 06:46 AM
C++: to run the program foo.cpp you must compile it to foo.exe and run it. If you change foo.cpp you must recompile before you can see the effect of your changes.
Perl: to run the program bar.prl you simply double-click on it, and the Perl interpreter runs your program. If you change bar.prl the changes will be seen the next time you double-click it with no additional action on your part.
Perl: to run the program bar.prl you simply double-click on it, and the Perl interpreter runs your program. If you change bar.prl the changes will be seen the next time you double-click it with no additional action on your part.
#5
Posted 29 July 2006 - 09:10 AM
Oooooh, the compiler changes it to an executable file but an interpreter can run it as it is. I wish you'd given me that example at first.
#6
Posted 29 July 2006 - 11:49 AM
I've had a number of students who wished I'd start with examples before definitions. I've also seen what happens when you start with examples... no clue what I'm talking about.
Keep asking questions, we'll get you through all these ideas :)
Keep asking questions, we'll get you through all these ideas :)
#7
Posted 21 August 2006 - 11:19 AM
Well I'm down with what an interpreter is, don't have any more problems with that.


Sign In
Create Account


Back to top









