patternMinor
Does "static" or "dynamic" imply a compiler or interpreter implementation of a programming language?
Viewed 0 times
interpreterimplyprogrammingdynamiclanguagecompilerdoesimplementationstatic
Problem
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.
performed at compilation time, and a dynamic operation means it is
performed at run time?
-
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?
is implemented by a compiler but not by an interpreter?
is implemented by an interpreter but not a compiler?
Thanks.
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.
- 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?
-
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?
- Does a static operation imply that the language under consideration
is implemented by a compiler but not by an interpreter?
- Does a dynamic operation imply that the language under consideration
is implemented by an interpreter but not a compiler?
Thanks.
Solution
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
Anyway, from both a practical and theoretical perspective, anything an interpreter can do a compiler can do, and vice versa.
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.
Context
StackExchange Computer Science Q#63544, answer score: 3
Revisions (0)
No revisions yet.