1583 posts
Location
Germany
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_
1522 posts
Location
The Netherlands
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/>
7083 posts
Location
Tasmania (AU)
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.
997 posts
Location
Wellington, New Zealand
Posted 28 May 2013 - 08:20 PM
504 posts
Location
Seattle, WA
Posted 28 May 2013 - 08:32 PM