Questions tagged [interpreter]

An interpreter is a program that executes, i.e. performs, instructions written in a programming language. The tag [interpreter] should be applied to questions concerning the programming of interpreters or for questions about the detailed inner workings of interpreters. Use [interpreter-pattern] (possibly with this tag) for questions about the Gang of Four design pattern.

An interpreter is a program that executes, i.e. performs, instructions written in a programming language.

An interpreter may be a program that either

  1. executes the source code directly
  2. translates source code into some efficient intermediate representation (code) and immediately executes this
  3. explicitly executes stored precompiled code1 made by a compiler which is part of the interpreter system

From wikipedia

2265 questions
23
votes
4 answers

VM Design: More opcodes or less opcodes? What is better?

Don't be shocked. This is a lot of text but I'm afraid without giving some detailed information I cannot really show what this is all about (and might get a lot of answers that don't really address my question). And this definitely not an assignment…
Mecki
  • 125,244
  • 33
  • 244
  • 253
23
votes
10 answers

What is the difference between implementing a compiler and an interpreter?

I've read the whole Dragon Book recently (just for fun, I'm not really planning to implement an actual compiler), and I was left with this big question dangling in my head. What is different between implementing a compiler and an interpreter? To me…
Daniel Magliola
  • 30,898
  • 61
  • 164
  • 243
23
votes
3 answers

How can I implement my own basic unix shell in C?

I'm a newbie to process and thread management. My Shell should understand PATH environment variable. It can be set and modified. It runs in two ways -interactive & batch mode. Shell is capable of taking more than one job like ls;ps;wc file;cal. I…
Alex Xander
  • 3,903
  • 14
  • 36
  • 43
22
votes
3 answers

Compile and execute Scala code at runtime

Is is possible to compile and execute scala code as a string at runtime either in Scala or in Java? My idea is to build a DSL using Scala then let Java programmers use the DSL inside Java. I heard that the class scala.tools.nsc.Interpreter can do…
Peter
  • 509
  • 1
  • 3
  • 10
22
votes
3 answers

How would I go about writing an interpreter in C?

I'd love some references, or tips, possibly an e-book or two. I'm not looking to write a compiler, just looking for a tutorial I could follow along and modify as I go. Thank you for being understanding! BTW: It must be C. Any more replies would be…
tekknolagi
  • 10,663
  • 24
  • 75
  • 119
22
votes
1 answer

Why are Ruby method calls particularly slow (in comparison to other languages)?

I'm trying to read about Ruby performance, and came across this SO thread, where one of the answers mentions that "method calls, one of the most common operations in Ruby, are particularly slow." Another thread mentions that "It does "late lookup"…
grautur
  • 29,955
  • 34
  • 93
  • 128
22
votes
4 answers

Is there any Ruby or Python interpreter for Lego Mindstorm?

I want to start coding in Python or Ruby. Since I own a Lego Midstorms kit I thought it would be nice to program against it. Are there any good translators / interpeters for the Mindstorms brick?
nojevive
  • 3,518
  • 3
  • 22
  • 18
21
votes
3 answers

Powershell online interpreter?

Is there online Powershell interpreter available on the Internet? I mean like trypython for Python programming language.
jrara
  • 16,239
  • 33
  • 89
  • 120
21
votes
7 answers

Tab-completion in Python interpreter in OS X Terminal

Several months ago, I wrote a blog post detailing how to achieve tab-completion in the standard Python interactive interpreter--a feature I once thought only available in IPython. I've found it tremendously handy given that I sometimes have to…
gotgenes
  • 38,661
  • 28
  • 100
  • 128
21
votes
8 answers

Pseudocode interpreter?

Like lots of you guys on SO, I often write in several languages. And when it comes to planning stuff, (or even answering some SO questions), I actually think and write in some unspecified hybrid language. Although I used to be taught to do this…
21
votes
4 answers

Alan Kay's Eval/Apply Einstein Moment

Alan Kay said that reading the code closely and finding the 1 and only bug in the code on page 13 of the Lisp 1.5 manual, helped him understand Computer Science by a factor of 100 better. The code in question is the 1st release of eval & apply that…
GlassGhost
  • 16,906
  • 5
  • 32
  • 45
21
votes
3 answers

Python 3.2 - GIL - good/bad?

Python 3.2 ALPHA is out. From the Change Log, it appears the GIL has been entirely rewritten. A few questions: Is having a GIL good or bad? (and why). Is the new GIL better? If so, how? UPDATE: I'm fairly new to Python. So all of this is new to my…
JerryK
  • 357
  • 1
  • 4
  • 8
21
votes
3 answers

Printing Unicode from Scala interpreter

When using the scala interpreter (i.e. running the command 'scala' on the commandline), I am not able to print unicode characters correctly. Of course a-z, A-Z, etc. are printed correctly, but for example € or ƒ is printed as a…
Martin Sturm
  • 728
  • 1
  • 4
  • 14
21
votes
2 answers

Implementing a language interpreter in Haskell

I want to implement an imperative language interpreter in Haskell (for educational purposes). But it's difficult for me to create right architecture for my interpreter: How should I store variables? How can I implement nested function calls? How…
sergeyz
  • 1,308
  • 2
  • 14
  • 23
21
votes
2 answers

Avoiding the infamous "eval(parse())" construct

Ok, so I'm running some loops to process data stored in list objects. Ever mindful of the infamous fortune admonishment not to use eval(parse(mystring)), I came up with this: Rgames> bar $foo $foo$fast [1] 1 2 3 4 5 $foo$slow [1] 6 7 8 9…
Carl Witthoft
  • 20,573
  • 9
  • 43
  • 73