Jump to content




How does an interpreter works?


  • You cannot reply to this topic
4 replies to this topic

#1 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 28 May 2013 - 03: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_

#2 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 28 May 2013 - 03: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

#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 28 May 2013 - 06: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.

#4 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 28 May 2013 - 07:20 PM

See my reply here: computercraft.info/forums2/index.php?/topic/10947-how-do-programming-languages-work/

#5 Grim Reaper

  • Members
  • 503 posts
  • LocationSeattle, WA

Posted 28 May 2013 - 07:32 PM

http://en.wikipedia....preted_language





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users