> Source code is compiled on-the-fly when loaded from a source file or entered via the shell.[0]
> Whether compiling on the fly or precompiling, the compiler produces optimized machine code, with some optimization across separately compiled library boundaries. [0]
> Chez Scheme compiles source forms as it sees them to machine code before evaluating them, i.e., "just in time." [1]
Chez can both JIT and pre-compile. But it absolutely has a JIT, and has had as far back as I could trace.
Well, sure, but it is not what we mostly consider a JIT. The "JIT" part is just an AOT compile at runtime, without most of the nice things that we generally consider being a JIT.
Take a hypothetical example: (for ([i (in-range a b c)]) (display i)). At compile time, chez has no way to know whether c is positive or negative (if it is set at runtime), thus making each iteration check whether c is positive or negative. In racket such code has negligible performance impact because the runtime will generate native code "just in time" with optimizations deduced from run-time information.
The JIT of chez is just a side effect of the AOT being fast enough to run on the fly. SBCL does the same.
> Well, sure, but it is not what we mostly consider a JIT. The "JIT" part is just an AOT compile at runtime, without most of the nice things that we generally consider being a JIT.
Huh? Then what do you consider a JIT?
> In computing, just-in-time (JIT) compilation, also known as dynamic translation, is a way of executing computer code that involves compilation during execution of a program – at run time – rather than prior to execution. Most often, this consists of source code or more commonly bytecode translation to machine code, which is then executed directly. [0]
Cisco says Chez compiles code just before it uses it, at runtime:
> Chez Scheme compiles source forms as it sees them to machine code before evaluating them, i.e., "just in time."
They refer to it as a "incremental native compiler". Incremental compilation happens at runtime. An incremental compiler that runs at runtime is a form of JIT compiler.
> JIT compilation is a combination of the two traditional approaches to translation to machine code – ahead-of-time compilation (AOT), and interpretation – and combines some advantages and drawbacks of both
Everything I know and Wiki says that is a JIT.
Are you saying it isn't a JIT because it isn't a tracing JIT? Bearing in mind tracing JITs came about in the 70s, but JITs themselves are about a decade older.
The incremental compilation step is just their name for the nanopass compilation (many small steps). The code you execute is static and won't change during the execution of the program (unless you redefine it using a repl).
Do we at least agree that Chez does not generate code at runtime? Because I am very certain it does not (I have spent a lot of time with the chez codebase)
If you still want to call it a JIT then every language that compiles code to an intermediate representation and then executes it is a JIT language,which means just about every friggin language.
I have also ported a non-trivial amount of code making use of rackets JIT optimizations (based on hot paths) to Chez and have spent a lot of time compensating for the lack of the same optimizations in Chez.
SBCL compiles code fast enough to not have a distinct compilation step for most software in a way similar to chez and no one would consider it a JIT.
Edit:
Let me quote Andy Keep (akeep on github. One of chez schemes developers):
Chez Scheme does compile at the REPL, but in general I would not call it a JIT compiler. It just compiles everything the same way regardless of if you are compiling it ahead of time or while you are running in an interactive session.
> Whether compiling on the fly or precompiling, the compiler produces optimized machine code, with some optimization across separately compiled library boundaries. [0]
> Chez Scheme compiles source forms as it sees them to machine code before evaluating them, i.e., "just in time." [1]
Chez can both JIT and pre-compile. But it absolutely has a JIT, and has had as far back as I could trace.
[0] https://cisco.github.io/ChezScheme/
[1] https://www.scheme.com/csug8/use.html