In programming language theory, there are operations which are distinguished between static and dynamic, e.g. static/dynamic scoping, static/dynamic typing, ....

Does "static" or "dynamic" imply a compiler or interpreter implementation of a programming language?

Let me explain the above question and my thoughts and confusions about it.

  1. Is it correct that a static operation means the operation is performed at compilation time, and a dynamic operation means it is performed at run time?
  2. When an operation is performed by an interpreter, is it at compilation time or run time?

    It seems to me that people often says it is at run time.

    But if I am correct, an interpreter first translates and then executes a program, so to answer the question, do we need to specify whether the operation is performed when the interpreter translates or executes a program?

  3. Does a static operation imply that the language under consideration is implemented by a compiler but not by an interpreter?
  4. Does a dynamic operation imply that the language under consideration is implemented by an interpreter but not a compiler?


  • 2
    $\begingroup$ Are you aware that we discourage more than one question per post? And by interpreter do you mean the real one (that executes line by line) or the modern one that parses file, does some checks, precompiles etc? $\endgroup$
    – Evil
    Sep 16, 2016 at 19:28
  • $\begingroup$ I fail to see the differences between the two kinds of interpreters you mentioned. What I have learnt is that there is only one kind of interpreters, as far as the things you mentioned. If you have some reference or link which can explain what you mean, please let me know. Thanks. $\endgroup$
    – Tim
    Sep 16, 2016 at 19:37
  • 1
    $\begingroup$ @Evil I've never heard a definition of a "real" interpreter like that. Can you provide a citation (preferably an academic one)? $\endgroup$ Sep 25, 2016 at 14:32

1 Answer 1


First, as a commenter mentioned, there isn't necessarily a clear general distinction between compilers and interpreters. A compiler is a program that takes source code, and produces a program which takes the input and produces the output. An interpreter is a program that takes source code and an input and produces the output. Under this definition, there are fairly trivial ways of converting an interpreter into a compiler and vice-versa (this is called the curry/uncurry operation in functional programming). There are also some more interesting general ways like partial evaluation.

What is true is that you may define the execution semantics of many programming languages may be defined on an abstract machine which loses much of the information in the original program. Most interpreters do this in some sense.

Second, keep in mind that all the various uses of "static/dynamic" are different things. For example, a static architecture is one where each component may only be connected to a fixed set of other components, while a dynamic architecture is one where some process connects them (e.g.: dependency injection). Most compilers are completely unaware of your application's architecture, so this question is pretty irrelevant for static/dynamic architecture.

In particular, for your question, "static typing" and "dynamic typing" are not really even on the same dimension. "Dynamic typing" is not a type system, although using it typically requires having an Any type. "Static typing" is usually just called "typing."

Anyway, from both a practical and theoretical perspective, anything an interpreter can do a compiler can do, and vice versa.

  • 1
    $\begingroup$ "there are fairly trivial ways of converting an interpreter into a compiler" -- given that there are dynamic languages that can't even be parsed, that statement can not be true in general. $\endgroup$
    – Raphael
    Sep 25, 2016 at 14:45
  • $\begingroup$ The trivial way is to package the program into an interpreter+source package, similar to programs such as ruby script2exe. Also, name one such language. $\endgroup$ Sep 25, 2016 at 15:33
  • $\begingroup$ Older Perl - cannot be parsed until data is present. I will look for paper, but historical venue are punched cards - interpreted on fly, then Basic, which translated statements for opcodes and then different strategies emerged 1) run on fly 2) parse and run intermediate language 3) precompile to bytecode. Sorry for bringing that up, but it makes a lot of difference to OP question, just wanted to be sure how he understands that. If I find paper I will provide it, but we can safely call it ancient history and just ignore it. $\endgroup$
    – Evil
    Sep 25, 2016 at 16:23
  • $\begingroup$ @JamesKoppel Perl. $\endgroup$
    – Raphael
    Sep 25, 2016 at 17:14
  • $\begingroup$ Packaging the interpreter with the code and changing the file ending is, arguably, not a compilation process. $\endgroup$
    – Raphael
    Sep 25, 2016 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.