Skip to main content
removed ad hominem attack
Source Link
FrankW
  • 6.6k
  • 4
  • 26
  • 42

Adding this as an answer because commenting requires 50 rep:

Those snide remarks that you can always bundle an interpreter in your executable or that there is no distinction between interpreting source code and executing compiled code aren't helping the discussion at all. They are trivially true, don't answer the question in any meaningful way, and seem to be posted mainly to make the poster look smart.

The reality is that there is a big difference between interpreting some Basic program and executing assembler. And there are areas in-between with P-code / byte-code with or without (just-in-time) compilers. So I will try to summarise some points in the context of this reality.

  • If how source code is parsed depends on run-time conditions, writing a compiler may become impossible, or so hard that nobody will bother.

  • Code that modifies itself is in the general case impossible to compile.

  • A program that uses an eval-like function usually cannot be completely compiled in advance (if you regard the string fed to it as part of the program), although if you're going to run the eval'ed code repeatedly it may still be useful to have your eval-like function invoke the compiler. Some languages provide an API for the compiler to make this easy.

  • The ability to refer to things by name doesn't preclude compilation, but you do need tables (as mentioned). Calling functions by name (like IDispatch) requires a lot of plumbing, to the point where I think most people would agree that we're effectively talking about a function call interpreter.

  • Weak typing (whatever your definition) makes compilation harder and perhaps the result less efficient, but often not impossible, unless different values trigger different parses. There is a sliding scale here: if the compiler can't deduce the actual type, it will need to emit branches, function calls and such that wouldn't otherwise be there, effectively embedding bits of interpreter in the executable.

Adding this as an answer because commenting requires 50 rep:

Those snide remarks that you can always bundle an interpreter in your executable or that there is no distinction between interpreting source code and executing compiled code aren't helping the discussion at all. They are trivially true, don't answer the question in any meaningful way, and seem to be posted mainly to make the poster look smart.

The reality is that there is a big difference between interpreting some Basic program and executing assembler. And there are areas in-between with P-code / byte-code with or without (just-in-time) compilers. So I will try to summarise some points in the context of this reality.

  • If how source code is parsed depends on run-time conditions, writing a compiler may become impossible, or so hard that nobody will bother.

  • Code that modifies itself is in the general case impossible to compile.

  • A program that uses an eval-like function usually cannot be completely compiled in advance (if you regard the string fed to it as part of the program), although if you're going to run the eval'ed code repeatedly it may still be useful to have your eval-like function invoke the compiler. Some languages provide an API for the compiler to make this easy.

  • The ability to refer to things by name doesn't preclude compilation, but you do need tables (as mentioned). Calling functions by name (like IDispatch) requires a lot of plumbing, to the point where I think most people would agree that we're effectively talking about a function call interpreter.

  • Weak typing (whatever your definition) makes compilation harder and perhaps the result less efficient, but often not impossible, unless different values trigger different parses. There is a sliding scale here: if the compiler can't deduce the actual type, it will need to emit branches, function calls and such that wouldn't otherwise be there, effectively embedding bits of interpreter in the executable.

The reality is that there is a big difference between interpreting some Basic program and executing assembler. And there are areas in-between with P-code / byte-code with or without (just-in-time) compilers. So I will try to summarise some points in the context of this reality.

  • If how source code is parsed depends on run-time conditions, writing a compiler may become impossible, or so hard that nobody will bother.

  • Code that modifies itself is in the general case impossible to compile.

  • A program that uses an eval-like function usually cannot be completely compiled in advance (if you regard the string fed to it as part of the program), although if you're going to run the eval'ed code repeatedly it may still be useful to have your eval-like function invoke the compiler. Some languages provide an API for the compiler to make this easy.

  • The ability to refer to things by name doesn't preclude compilation, but you do need tables (as mentioned). Calling functions by name (like IDispatch) requires a lot of plumbing, to the point where I think most people would agree that we're effectively talking about a function call interpreter.

  • Weak typing (whatever your definition) makes compilation harder and perhaps the result less efficient, but often not impossible, unless different values trigger different parses. There is a sliding scale here: if the compiler can't deduce the actual type, it will need to emit branches, function calls and such that wouldn't otherwise be there, effectively embedding bits of interpreter in the executable.

Source Link

Adding this as an answer because commenting requires 50 rep:

Those snide remarks that you can always bundle an interpreter in your executable or that there is no distinction between interpreting source code and executing compiled code aren't helping the discussion at all. They are trivially true, don't answer the question in any meaningful way, and seem to be posted mainly to make the poster look smart.

The reality is that there is a big difference between interpreting some Basic program and executing assembler. And there are areas in-between with P-code / byte-code with or without (just-in-time) compilers. So I will try to summarise some points in the context of this reality.

  • If how source code is parsed depends on run-time conditions, writing a compiler may become impossible, or so hard that nobody will bother.

  • Code that modifies itself is in the general case impossible to compile.

  • A program that uses an eval-like function usually cannot be completely compiled in advance (if you regard the string fed to it as part of the program), although if you're going to run the eval'ed code repeatedly it may still be useful to have your eval-like function invoke the compiler. Some languages provide an API for the compiler to make this easy.

  • The ability to refer to things by name doesn't preclude compilation, but you do need tables (as mentioned). Calling functions by name (like IDispatch) requires a lot of plumbing, to the point where I think most people would agree that we're effectively talking about a function call interpreter.

  • Weak typing (whatever your definition) makes compilation harder and perhaps the result less efficient, but often not impossible, unless different values trigger different parses. There is a sliding scale here: if the compiler can't deduce the actual type, it will need to emit branches, function calls and such that wouldn't otherwise be there, effectively embedding bits of interpreter in the executable.