Partial evaluation in guile › 优化解锁表达能力 optimization enables expressiveness [#270]

如果部分求值器好好完成他的任务,那么留存程序会运行得更快。然而我对此如此满意的真正原因不是这个;而是它能够让我编写不同的程序。
If the partial evaluator does its job right, the residual program will run faster. However this isn't the real reason that I'm so pleased with it; rather, it's that it lets me write different programs.

你知道,我一直在研究 Guile 编译器和虚拟机。当我写代码时,我知道 Guile 会如何处理这些代码。不幸的是,这导致我的程序要比必要的代码丑,因为我知道 Guile 不会为我内联一些重要的东西。我在比较底层的抽象写代码,因为我不信任编译器。
You see, I hack on Guile's compiler and VM and all that. When I write code, I know what Guile is going to do with it. Unfortunately, this caused my programs to be uglier than necessary, because I knew that Guile wasn't going to inline some important things for me. I wrote at a lower level of abstraction, because I couldn't trust the compiler.

现在,有了部分求值器,我很乐意使用辅助函数,甚至高阶的辅助函数,因为 Guile 基本上会做正确的事。这在支持语法抽象的语言中格外重要,比如 Scheme。如果你是一名 Schemer,但还没有看过 Kent Dybvig 的 Macro Writers' Bill of Rights 演讲(幻灯片),请务必看看。
Now, with the partial evaluator, I'm happy to use helper functions, even higher-order helpers, with the knowledge that Guile will mostly do the right thing. This is particularly important in the context of languages that support syntactic abstraction, like Scheme. If you're a Schemer and haven't seen Kent Dybvig's Macro Writers' Bill of Rights talk (slides), do check it out.

顺便一提,几周前,JSConf.eu 上发生了一件悲伤的事,Andreas Gal(即使是他!)为了获得足够的速度,他不得不手动内联 PDF.js 中的一些函数。不过,稍后再详细介绍 JavaScript。
Incidentally, there was a sad moment in JSConf.eu a couple weekends ago when Andreas Gal (of all people!) indicated that he had to manually inline some functions in PDF.js in order to get adequate speed. More on JavaScript a little later, though.