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

2046 questions
299
votes
12 answers

Compiled vs. Interpreted Languages

I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython…
141
votes
26 answers

How to repeat last command in python interpreter shell?

How do I repeat the last command? The usual keys: Up, Ctrl+Up, Alt-p don't work. They produce nonsensical characters. (ve)[kakarukeys@localhost ve]$ python Python 2.6.6 (r266:84292, Nov 15 2010, 21:48:32) [GCC 4.4.4 20100630 (Red Hat 4.4.4-10)] on…
kakarukeys
  • 16,427
  • 9
  • 28
  • 42
131
votes
9 answers

How do I add tab completion to the Python shell?

When starting a django application using python manage.py shell, I get an InteractiveConsole shell - I can use tab completion, etc. Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help",…
ashchristopher
  • 21,525
  • 16
  • 44
  • 49
111
votes
13 answers

Is there an interpreter for C?

I was wondering if there is something like an interpreter for C. That is, in a Linux terminal I can type in "python" and then code in that interpreter. (I'm not sure interpreter the right word). This is really helpful for testing different things…
devin
  • 5,927
  • 13
  • 46
  • 53
108
votes
2 answers

Python 3 Online Interpreter / Shell

Is there an online interpreter like http://codepad.org/ or http://www.trypython.org/ which uses Python 3? Answer Since the question is closed, I give another answer here. Wandbox offers online REPLs for many languages, including Python 2.x and 3.x,…
deamon
  • 78,414
  • 98
  • 279
  • 415
107
votes
2 answers

Does Python optimize away a variable that's only used as a return value?

Is there any ultimate difference between the following two code snippets? The first assigns a value to a variable in a function and then returns that variable. The second function just returns the value directly. Does Python turn them into…
Jayesh
  • 4,303
  • 4
  • 25
  • 56
97
votes
6 answers

Measure and Benchmark Time for Ruby Methods

How can i measure the time taken by a method and the individual statements in that method in Ruby. If you see the below method i want to measure the total time taken by the method and the time taken for database access and redis access. I do not…
Phani
  • 1,404
  • 2
  • 12
  • 17
90
votes
15 answers

Write a Haskell interpreter in Haskell

A classic programming exercise is to write a Lisp/Scheme interpreter in Lisp/Scheme. The power of the full language can be leveraged to produce an interpreter for a subset of the language. Is there a similar exercise for Haskell? I'd like to…
Barry Brown
  • 19,087
  • 14
  • 65
  • 102
85
votes
3 answers

Drop into interpreter during arbitrary scala code location

I come from a Python background, where at any point in my code I can add import pdb; pdb.set_trace() and at runtime I'll be dropped into an interactive interpreter at that spot. Is there an equivalent for scala, or is this not possible at runtime?
Lars Yencken
  • 2,798
  • 2
  • 18
  • 11
78
votes
3 answers

Load Scala file into interpreter to use functions?

I have some Scala functions defined in a file, not in a class, and I would like to use them in the Scala interpreter. I know I can say scala filename.scala to simply run the file and exit the interpreter, but I would like to run the file and then…
user550617
78
votes
8 answers

How does an interpreter/compiler work

How does an interpreter/compiler work? What is the difference between interpreter and compiler.
developer
  • 3,601
  • 7
  • 28
  • 34
73
votes
4 answers

How to use third party libraries with Scala REPL?

I've downloaded Algebird and I want to try out few things in the Scala interpreter using this library. How do I achieve this?
Harshal Kshatriya
  • 4,930
  • 8
  • 39
  • 56
70
votes
11 answers

Do comments slow down an interpreted language?

I am asking this because I use Python, but it could apply to other interpreted languages as well (Ruby, PHP, JavaScript). Am I slowing down the interpreter whenever I leave a comment in my code? According to my limited understanding of an…
Mantas Vidutis
  • 15,230
  • 20
  • 73
  • 91
69
votes
3 answers

Assigning a value to single underscore _ in Python/IPython interpreter

I created this function in Python 2.7 with ipython: def _(v): return v later if I call _(somevalue), I get _ = somevalue. in[3]: _(3) out[3]: 3 in[4]: print _ out[4]: 3 The function has disappeared! If I call _(4) I get: TypeError: 'int'…
68
votes
7 answers

How to write a Parser in C#?

How do I go about writing a Parser (Recursive Descent?) in C#? For now I just want a simple parser that parses arithmetic expressions (and reads variables?). Though later I intend to write an xml and html parser (for learning purposes). I am doing…
ApprenticeHacker
  • 19,279
  • 24
  • 94
  • 151
1
2 3
99 100