GNU Guile Scheme Gets a Register VM and CPS-Based IL
In late November, Andy Wingo pushed a new register VM to Guile's (the GNU implementation of the Scheme language) master branch. It brought a number of performance improvements, but led to a bit of a conceptual mismatch between the compiler's direct-style intermediate language and the virtual machine. Earlier this week Andy Wingo announced a new continuation-passing style intermediate language for Guile. From the article:
"To recap, we switched from a stack machine to a register machine because, among other reasons, register machines can consume and produce named intermediate results in fewer instructions than stack machines, and that makes things faster. To take full advantage of this new capability, it is appropriate to switch at the same time from the direct-style intermediate language (IL) that we had to an IL that names all intermediate values. ... In Guile I chose a continuation-passing style language. ... Guile's CPS language is composed of terms, expressions, and continuations. It was heavily inspired by Andrew Kennedy's 'Compiling with Continuations, Continued' paper. ... The optimizations I have currently implemented for CPS are fairly basic. Contification was tricky. One thing I did recently was to make all non-tail $call nodes require $kreceive continuations; if, as in the common case, extra values were unused, that was reflected in an unused rest argument. This required a number of optimizations to clean up and remove the extra rest arguments for other kinds of source expressions: dead-code elimination, the typical beta/eta reduction, and some code generation changes."
The article describes the CPS language provided by Guile and explains the reasons behind choosing CPS over SSA or A-Normal Form. The Guile manual contains draft documentation. The new VM and Intermediate Language will be released with Guile 2.2, which should be out later this year.
I'll wager this article garners less than 100 comments. Also, WTF is all this "guile" about?
C|N>K
Is GNU parroting the parrot VM?
Never done anything substantial in Scheme, but was probably my favorite language to learn in college, in the context of a function programming course. I did not know there as a GNU interpreter. Will have to check it out. Speaking of functional languages, someone told me that the XKCD website is programmed entirely in Haskell. True?
The frightening thing is, a year ago, I wouldn't have understood this post. Now I'm reading the paper on Contifications and nodding my head, going "Yeah, yeah... huh... uh... yeah, okay..." It's been that kind of year. This is the kind of stuff that's starting to show up on webdevs' radars. With the release of ECMA-6 and the precompiler suites, the essential core scheme-ness of even Javascript is starting to infect us all.
GNU guile's built-in reader includes support for SRFI-105, so you can use infix expressions directly. In particular, you can use {...} instead of (...) and put the operator in the EVEN position, e.g., {n https://www.gnu.org/software/guile/manual/html_node/SRFI_002d105.html
If you want to eliminate more of the parens, you can use guile with SRFI-110, which provides support for indentation-sensitive semantics. An implementation is available with an MIT license. See more here: http://readable.sourceforge.net/
- David A. Wheeler (see my Secure Programming HOWTO)
I don't think I have ever encountered a title at Slashdot more meaningless to me than this one. There might be a lesson in that, and I don't think the lesson is for me.
The Guile team is doing amazing work. Starting with version 2, Scheme is no longer something that always runs slow. My simple test code run several times faster in Guile 2 compared to similar code in python 3. The problem is that no one seems to be interested. It's quite sad. Guile is simply a fantastic, fairly complete programming environment with a very fast VM. In the early days of Gnome, GNU elevated Scheme to the number 1 status among the Gnome languages, but it was dropped since then. I don't know whether this is from the perception of LISP as the old-school language or the rejection of the code aesthetics due to meticulous use of parenthesis.
> I don't think the lesson is for me
You gotta decide whether the lesson is for you or not.
The outcome of one of the choices will be that you've learnt something, the outcome of the other, that you won't.
Guess which is which.
BTW: Kudos, Andy! I bow in awe.