Can you tell whether a programming language is compiled or interpreted by just its syntax?

For instance, can someone tell that X programming language is compiled rather interpreted simply by looking at the syntax of X.

Perhaps there’s a common theme in compiled and interpreted programming languages that is unique to each?

1 answer

  • answered 2019-12-11 01:48 kaya3

    No. For comparison, can you tell whether a meal will be eaten using knife and fork, or with bare hands, just from the ingredients used to cook it?

    You can probably make some educated guesses - for example, if the ingredients include noodles, then the meal will probably not be eaten with bare hands. Likewise, if the language's syntax includes explicit type declarations on every variable and function signature, then that's a clue that some sort of static checking will be done at "compile-time" before the program is run.

    But the fundamental fact is that nothing stops you from eating noodles with your bare hands if you don't mind getting a bit messy, and likewise nothing stops you from writing an implementation of a statically-typed language which does all of the checks at runtime. For fun, I once wrote a tree-walking interpreter for a bare-bones subset of Java which did exactly that.

    So the problem with this is that syntax is a property of a programming language, but "compiled" vs. "interpreted" is not a property of a programming language; it is a property of a programming language implementation. The same meal can be eaten with knife-and-fork and with bare hands, and the same language can be both compiled and interpreted, if there is a compiler for it and also an interpreter for it. Java bytecode is a prime example; it can be interpreted, or compiled to native code at runtime by the JIT compiler.