Lightweight compilation of (C)LP to JavaScript*

We present and evaluate a compiler from Prolog (and extensions) to JavaScript which makes it possible to use (constraint) logic programming to develop the client side of web applications while being compliant with current industry standards. Targeting JavaScript makes (C)LP programs executable in virtually every modern computing device with no additional software requirements from the point of view of the user. In turn, the use of a very high-level language facilitates the development of high-quality, complex software. The compiler is a back end of the Ciao system and supports most of its features, including its module system and its rich language extension mechanism based on packages. We present an overview of the compilation process and a detailed description of the run-time system, including the support for modular compilation into separate JavaScript code. We demonstrate the maturity of the compiler by testing it with complex code such as a CLP(FD) library written in Prolog with attributed variables. Finally, we validate our proposal by measuring the performance of some LP and CLP(FD) benchmarks running on top of major JavaScript engines.

[1]  Christian Holzbaur,et al.  Metastructures versus Attributed Variables in the Context of Extensible Unification , 1992, PLILP.

[2]  Philippe Codognet,et al.  Compiling Constraints in clp(FD) , 1996, J. Log. Program..

[3]  Alon Zakai Emscripten: an LLVM-to-JavaScript compiler , 2011, OOPSLA Companion.

[4]  Craig Chambers,et al.  An efficient implementation of SELF, a dynamically-typed object-oriented language based on prototypes , 1989, OOPSLA '89.

[5]  Pierre Deransart,et al.  Programming Languages Implementation and Logic Programming , 1989, Lecture Notes in Computer Science.

[6]  Ankur Taly,et al.  An Operational Semantics for JavaScript , 2008, APLAS.

[7]  Frank Yellin,et al.  The Java Virtual Machine Specification , 1996 .

[8]  Manuel V. Hermenegildo,et al.  Integrated program debugging, verification, and optimization using abstract interpretation (and the Ciao system preprocessor) , 2005, Sci. Comput. Program..

[9]  Michael Leuschel,et al.  Towards a jitting VM for prolog execution , 2010, PPDP.

[10]  Manuel V. Hermenegildo,et al.  Distributed WWW Programming using (Ciao-)Prolog and the PiLLoW library , 2001, Theory Pract. Log. Program..

[11]  Jan Wielemaker,et al.  An Architecture for Making Object-Oriented Systems Available from Prolog , 2002, WLPE.

[12]  Neng-Fa Zhou,et al.  A Register-Free Abstract Prolog Machine with Jumbo Instructions , 2007, ICLP.

[13]  Manuel Serrano,et al.  Hop Client-Side Compilation , 2007, Trends in Functional Programming.

[14]  Serge Le Huitouze A New Data Structure for Implementing Extensions to Prolog , 1990, PLILP.

[15]  Hassan Aït-Kaci,et al.  Warren's Abstract Machine: A Tutorial Reconstruction , 1991 .

[16]  Jacob M. Howe,et al.  A Pearl on SAT Solving in Prolog , 2010, FLOPS.

[17]  Manuel V. Hermenegildo,et al.  Improved Compilation of Prolog to C Using Moded Types and Determinism Information , 2004, PADL.

[18]  Paul Tarau,et al.  Integrated symbol table, engine and heap memory management in multi-engine prolog , 2011, ISMM '11.

[19]  Mason Chang,et al.  Trace-based just-in-time type specialization for dynamic languages , 2009, PLDI '09.

[20]  Manuel V. Hermenegildo,et al.  An overview of Ciao and its design philosophy , 2011, Theory and Practice of Logic Programming.

[21]  Egon Börger,et al.  From Prolog Algebras Towards WAM - A Mathematical Study of Implementation , 1990, CSL.

[22]  Zhisheng Huang,et al.  SWI-Prolog and the web , 2007, Theory and Practice of Logic Programming.

[23]  Paul Tarau,et al.  The BinProlog experience: Architecture and implementation choices for continuation passing Prolog and first-class logic engines , 2011, Theory and Practice of Logic Programming.

[24]  Craig Chambers,et al.  An efficient implementation of SELF a dynamically-typed object-oriented language based on prototypes , 1989, OOPSLA 1989.

[25]  Manuel V. Hermenegildo,et al.  Comparing tag scheme variations using an abstract machine generator , 2008, PPDP '08.

[26]  Bart Demoen,et al.  Dynamic attributes, their hProlog implementation, and a first evaluation , 2002 .

[27]  Thom W. Frühwirth,et al.  Compiling Constraint Handling Rules into Prolog with Attributed Variables , 1999, PPDP.

[28]  Martin Rinard,et al.  Proceedings of the ACM international conference companion on Object oriented programming systems languages and applications companion , 2010 .