Skip to main content
108 votes
Accepted

Can we make general statements about the performance of interpreted code vs compiled code?

No. In general, the performance of a language implementation is primarily dependent on the amount of money, resources, manpower, research, engineering, and development spent on it. And specifically, ...
Jörg W Mittag's user avatar
80 votes

Can we make general statements about the performance of interpreted code vs compiled code?

Generalizations and specific scenarios are literally opposites. You seem to be contradicting yourself. On the one hand, you want to make a general statement about interpreted vs compiled languages. ...
loneboat's user avatar
  • 971
37 votes

Can we make general statements about the performance of interpreted code vs compiled code?

As a rule of thumb, an interpreted program is about 2x–10x slower than writing the program in the interpreter's host language, with interpreters for more dynamic languages being slower. This is ...
amon's user avatar
  • 134k
35 votes

Why are commonly compiled languages not interpreted for faster iteration?

I refute the premise. There are interpreters / REPLs for compiled, static languages, they're just not as much part of the common workflow as with dynamic languages. Though that also depends on the ...
leftaroundabout's user avatar
35 votes

How can an interpreter run code without translating into machine code?

You can write a simple interpreter.  Let's make a language that "A" means print Hello and "B" means print Space and "C" means print World, then null means end program. ...
Erik Eidt's user avatar
  • 34.2k
33 votes
Accepted

In which process does syntax error occur? (tokenizing or parsing)

A tokenizer is just a parser optimization. It's perfectly possible to implement a parser without a tokenizer. A tokenizer (or lexer, or scanner) chops the input into a list of tokens. Some parts of ...
amon's user avatar
  • 134k
25 votes
Accepted

Is it possible to create a "bootstrapped" interpreter independent of the original interpreter?

The short answer is: you are right in your suspicion, you always need either another interpreter written in X or a compiler from Y to some other language for which you have an interpreter already. ...
Jörg W Mittag's user avatar
23 votes
Accepted

What semantic features of Python (and other dynamic languages) contribute to its slowness?

What semantic features of Python (and other dynamic languages) contribute to its slowness? None. Performance of language implementations is a function of money, resources, and PhD theses, not ...
Jörg W Mittag's user avatar
21 votes
Accepted

How are variables stored in a language compiler or interpreter?

Interpreter An intepreter will work about the way you guessed. In a simple model, it will maintain one dictionary with the variable names as dictionary keys and the variable values as dictionary ...
Ralf Kleberhoff's user avatar
18 votes

Can we make general statements about the performance of interpreted code vs compiled code?

You absolutely can say something about the performance of compiled/interpreted technologies. But first, you must define "performance". If you're building a computationally simple embedded system, then ...
jhbh's user avatar
  • 289
18 votes

Why are commonly compiled languages not interpreted for faster iteration?

Why isn't a thing to interpret a codebase for quick iterative development instead of generating code for a binary each time? Many languages, including C and C++ don’t lend themselves to repl style ...
Telastyn's user avatar
  • 109k
15 votes

In which process does syntax error occur? (tokenizing or parsing)

You'd usually expect most syntax errors to come from the parser, not the lexer. The lexer would generate an error if (and mostly only if) there's something in the input that can't be tokenized. In ...
Jerry Coffin's user avatar
  • 44.5k
12 votes

Can we make general statements about the performance of interpreted code vs compiled code?

This is a technical question and you already got many good technical answers, but I'd like to point out a slightly different aspect of your situation: the fact that you can't just base a decision like ...
Radu Murzea's user avatar
  • 1,820
12 votes

Why do we need to embed an interpreter in a program?

Elisp is not embedded in Emacs. Emacs is written in Elisp. In some sense, Emacs is embedded in Elisp. Emacs started out as a set of Editor MACroS for the TECO editor on ITS. It was then ported to ...
Jörg W Mittag's user avatar
11 votes

How Does An Interpreter Work?

Your question is too broad to be answered in a few paragraphs. And actually interpreters do not mean much: the BASIC interpreter of the ZX80 (in 1980) is really different from today's Guile, Lua, Ruby,...
Basile Starynkevitch's user avatar
11 votes

In which process does syntax error occur? (tokenizing or parsing)

Tokenizer just splits character stream into tokens. From tokenizer POV this is completely valid: 1 * * 1 and translates to something like: ["1", MULTIPLY, MULTIPLY, "1"] Only parser can reject such ...
Banthar's user avatar
  • 350
11 votes
Accepted

How can an interpreter run code without translating into machine code?

An interpreter is nothing more than a computer program (usually compiled to machine code) that's designed to execute other computer programs. Like a compiler, an interpreter contains logic to read ...
dan04's user avatar
  • 3,959
10 votes

Do bytecode compilers compile syntax directly or intermediate assembly language?

If I do compiler -> intermediate language -> bytecode - it should be simpler, but will take much more time because I have to write three programs. You don't need to write three programs, you just ...
Basile Starynkevitch's user avatar
10 votes

What semantic features of Python (and other dynamic languages) contribute to its slowness?

While Python's current implementation (which lacks a lot of the optimisations performed by other dynamic languages, e.g. modern Javascript implementations and, as you point out, Lua) is a source of ...
Jules's user avatar
  • 17.8k
10 votes

Can we make general statements about the performance of interpreted code vs compiled code?

Partial evaluation is a conceptual framework relevant to relate interpreters and compilers. Can we make general statements about the performance of interpreted code vs compiled code? Programming ...
Basile Starynkevitch's user avatar
10 votes

How are variables stored in a language compiler or interpreter?

It depends on the implementation. For example, a C compiler might maintain a symbol table during compilation. This is a rich data structure that allows pushing and popping of scopes, since each ...
Erik Eidt's user avatar
  • 34.2k
10 votes
Accepted

Language of an interpreter

No, it isn't true. To use the same language, you would also need to have a compiler for that language, so that you could compile the interpreter to machine code. If all you have is an interpreter, ...
Simon B's user avatar
  • 9,633
10 votes

How can one interpret an Abstract Syntax Tree without recursion?

You can systematically calculate such an approach. For simplicity, I'll consider evaluating arithmetic expressions, but the transforms are completely mechanical. I'll use Haskell as the language. ...
Derek Elkins left SE's user avatar
10 votes

How can an interpreter run code without translating into machine code?

Every programming language has semantics. These semantics are what a program means, and it defines what actions should be taken when one "runs" the program. An interpreter reads in a ...
Cort Ammon's user avatar
  • 11.6k
9 votes
Accepted

How does a JIT compiler actually emit and then call the emitted native code?

If I was writing a normal compiler, I couldsimply write the desired binary to a file, to be run later by the system in whatever manner it usually would be, but how would a JIT compiler do that during ...
Jörg W Mittag's user avatar
9 votes

Why are commonly compiled languages not interpreted for faster iteration?

Comparing say python and swift, in python even simple checks are not made until runtime. I don't actually know if my program runs until every code path has been executed. On the other hand, swift ...
gnasher729's user avatar
  • 45.8k
8 votes
Accepted

Why use Java as a server-side language over an interpreted language?

There's the title of your question which is a valid one and then there is the content of the question which contains some poor assumptions and/or incorrect statements. I'll address the body first: ...
JimmyJames's user avatar
  • 27.5k
8 votes
Accepted

Why do we need to embed an interpreter in a program?

your program is just a finite machine that can execute a finite set of instructions Stricto sensu, this is true, but not very interesting. Indeed, my desktop has only three terabytes of memory (...
Basile Starynkevitch's user avatar
8 votes
Accepted

How would I modify the JavaScript interpreter?

For what you want to achieve, it would probably be best to define your own language that compiles down to JavaScript, like CoffeeScript, Dart or TypeScript do. In other words, rather than a patch to ...
Kilian Foth's user avatar
7 votes

Is it possible to create a "bootstrapped" interpreter independent of the original interpreter?

You are correct in noting that a self-hosting interpreter still requires an interpreter to run itself, and can't be bootstrapped in the same sense as a compiler. However, a self-hosted language is ...
amon's user avatar
  • 134k

Only top scored, non community-wiki answers of a minimum length are eligible