This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
H4X0RZ's profile picture

How does an interpreter works?

Started by H4X0RZ, 28 May 2013 - 02:25 PM
H4X0RZ #1
Posted 28 May 2013 - 04:25 PM
Hello all,
I saw the BF interpreter from BIT (I think it was BIT) a few days ago.
Now I have a question:
How does an interpreter "runs" the code?

_Freack100_
Engineer #2
Posted 28 May 2013 - 04:52 PM
It was GravityScore who made the brainfuck interpreter. Well, basically an interpretar translates the code in lua and runs that. I think that is pretty descriptive :P/>
Bomb Bloke #3
Posted 28 May 2013 - 07:10 PM
Very loosely speaking, it compares the commands you give it to actual executable commands in a lookup table, and runs those. The table can be expanded by defining additional functions in your code.

Interpreted languages are somewhat inefficient in that the interpretor must be running at the same time as your programs in order for them to function. Java is another example of an interpreted language - you pre-compile your code to class files, but these aren't natively executable on any given processor. The Java Runtime Environment (JRE) has to be actively running on the machine to interpret your classes to executable code the computer can actually run.

JavaScript is yet another example - your web browser is the interpretor, in that case.

Because different processors have different instruction sets, interpreted languages make coding a fair bit easier for developers in that they can distribute one version of their code and have it run on anything for which an interpretor is available. Compare this to non-interpreted languages, where the code must be re-written into a separate executable file before you can run it (that is to say, it must be "compiled"), meaning that developers must distribute one executable version of their code for every type of system they want it to work on. A benefit to compiled languages are that they're far more efficient when they do run.
immibis #4
Posted 28 May 2013 - 08:20 PM
See my reply here: computercraft.info/forums2/index.php?/topic/10947-how-do-programming-languages-work/
Grim Reaper #5
Posted 28 May 2013 - 08:32 PM
http://en.wikipedia.org/wiki/Interpreted_language