Compiling Scheme to JavaScript
Florian Loitsch, Manuel Serrano · 2006
This paper presents SCM2JS a compiler that translates a variant of the Scheme programming language into JavaScript. On the one hand, some Scheme features are missing, amongst which the most important are the lack of support for continuations, the absence of exact numbers, and a partial treatment of tail recursions. On the other hand, some extensions are added for improving the connection between Scheme and JavaScript. In particular, SCM2JS extends Scheme with the JavaScript dot-notation which enables compact class accesses. Scheme code and JavaScript can be mixed because they both access functions and variables of the other language and because they share, at runtime, a common memory. The codes produced by SCM2JS are fast because for most programs they have performance comparable to equivalent hand-written JavaScript programs. Hence, one may use SCM2JS for replacing JavaScript with Scheme. For instance, one may implement web libraries or HTML actions in Scheme. The paper shows how this can be done in context of Hop, a programming language dedicated to interactive web development. 1.