<story><title>Compilers for free with weval</title><url>https://bernsteinbear.com/blog/weval/</url></story><parent_chain></parent_chain><comment><author>JonChesterfield</author><text>I remember being really excited about the derive-a-compiler-from-a-partial-evaluator premise when I first ran across it. You genuinely do get a compiler from an interpreter plus a partial evaluator. That trick does work.&lt;p&gt;The gotcha I didn&amp;#x27;t spot at the time is that a compiler is (I think, could be argued either way) easier to write than a partial evaluator. The &amp;quot;get it for free bit&amp;quot; only really applies if someone else gave you the partial evaluator &lt;i&gt;and&lt;/i&gt; if you somehow don&amp;#x27;t need to spend ages debugging why that partial evaluator isn&amp;#x27;t behaving like you hoped.&lt;p&gt;Now that I&amp;#x27;m somewhat more beaten down by toolchain dev, I&amp;#x27;m starting to think compilers are easier to write than interpreters. It&amp;#x27;s definitely not a clear win in favour of the interpreter. If you compile to x64, or to C, or to javascript or whatever, you now have a thing you can debug with whatever tools are native to that target. If you run in an interpreter, you get to debug that interpreter running the program, with whatever somewhat ad hoc debugging tools you put into the interpreter yourself.&lt;p&gt;Getting useful semantic error message out of an interpreter at partial evaluation time (aka the &amp;quot;compile time&amp;quot; of the aggregate tool) is probably solvable but not likely to work out of the box. Partial eval isn&amp;#x27;t really a phase separation friendly thing.</text></comment>
<story><title>Compilers for free with weval</title><url>https://bernsteinbear.com/blog/weval/</url></story><parent_chain></parent_chain><comment><author>rst</author><text>The most elaborate deployed version of this idea is probably PyPy, an alternative Python implementation that works by giving a JIT-compiling partial evaluator a hint-annotated Python interpreter as the program, and the Python code to be executed as its input.  Slightly abstruse overview here: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;doc.pypy.org&amp;#x2F;en&amp;#x2F;latest&amp;#x2F;architecture.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;doc.pypy.org&amp;#x2F;en&amp;#x2F;latest&amp;#x2F;architecture.html&lt;/a&gt;</text></comment>