On 9/23/2017 at 6:01 AM, SillyCow said:
I would not consider run time compilation as very different than interpretation. For me, the main advantage of compilation (and static typing) is that it helps find errors in large projects before you run them. C# and Java JIT is not the same, because the languages are precompiled into bytecode, and it's only the bytecode that goes through JIT.
First off, that's not how JavaScript compilation works today:
https://arstechnica.com/information-technology/2014/05/apple-integrates-llvm-compiler-to-boost-webkit-javascript-performance/
https://webkit.org/blog/3362/introducing-the-webkit-ftl-jit/
Modern JavaScript compilation in WebKit (I believe Google's V8 has something similar) has four stages of compilation, essentially live-profiling invocations of functions and pushing for the next tier of compilation/optimization when certain thresholds are crossed. The fourth stage in WebKit uses the same LLVM compiler back-end that powers the clang C++ compiler, swiftc Swift compiler, rustc Rust compiler and others.
Secondly, as pointed out by @ericrrichards22, typing proceeds along two orthogonal axes which we may label static and strong. Some "statically" typed languages, like C, are nevertheless weakly typed, permitting easy type coercion and often automatically/silently promoting them, with subtle errors—even with more stringent compiler flags enabled. Python and JavaScript are strongly typed languages, with zero coercion, but are dynamically typed in that they allow rebinding objects of different types against variables and elide type constraints on function signatures. A language like Rust shows that static typing is not absolute, as it permits rebinding against the same variable name as long as it can infer static type, but mandates type constraints (and lifetimes!) on function calls.
Quote
The interesting questions are:
Is the language designed to be compiled?
What design advantages do you get from compiling it?
What design advantages do you get from interpreting it?
etc...
None of these are interesting questions. Instead, ask:
-
whether it can efficiently be deployed to the target environment (no point writing a C++ program to run in the browser—yet);
-
whether the program can maintain the invariants required by the specification; and
-
what the median operational complexity and upper-bound cost of execution are.
As a developer, I wish every language offered both interpretation and compilation, so that I could model and explore the problem space and debug my solution interactively, and then compile with full optimizations for production deployment. I believe that is eventually where we'll end up, rendering this "debate" moot once and for all.