Hostname: page-component-77c89778f8-m8s7h Total loading time: 0 Render date: 2024-07-22T05:48:45.070Z Has data issue: false hasContentIssue false

Lightweight compilation of (C)LP to JavaScript*

Published online by Cambridge University Press:  05 September 2012

JOSE F. MORALES
Affiliation:
IMDEA Software Institute, Madrid, Spain (e-mail: josef.morales@imdea.org)
RÉMY HAEMMERLÉ
Affiliation:
School of Computer Science, Technical University of Madrid (UPM), Spain (e-mail: remy@clip.dia.fi.upm.es)
MANUEL CARRO
Affiliation:
IMDEA Software Institute, Madrid, Spain and School of Computer Science, Technical University of Madrid (UPM), Spain (e-mail: manuel.carro@imdea.org, manuel.hermenegildo@imdea.org, mcarro@fi.upm.es, herme@fi.upm.es)
MANUEL V. HERMENEGILDO
Affiliation:
IMDEA Software Institute, Madrid, Spain and School of Computer Science, Technical University of Madrid (UPM), Spain (e-mail: manuel.carro@imdea.org, manuel.hermenegildo@imdea.org, mcarro@fi.upm.es, herme@fi.upm.es)

Abstract

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.

Type
Regular Papers
Copyright
Copyright © Cambridge University Press 2012

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

References

Ait-Kaci, H. 1991. Warren's Abstract Machine, A Tutorial Reconstruction. MIT Press.CrossRefGoogle Scholar
Bolz, C. F., Leuschel, M. and Schneider, D. 2010. Towards a jitting VM for prolog execution. In PPDP'10 - Proc. of the 12th Int'l. ACM SIGPLAN Symposium on Principles and Practice of Declarative Programming. ACM, Hagenberg, Austria.Google Scholar
Börger, E. and Rosenzweig, D. 1990. From prolog algebras towards wam - a mathematical study of implementation. In CSL'90. Springer LNCS.Google Scholar
Cabeza, D. and Hermenegildo, M. 2001. Distributed WWW Programming using (Ciao) Prolog and the PiLLoW Library. Theory and Practice of Logic Programming 1, 3 (May), 251282.CrossRefGoogle Scholar
Chambers, C., Ungar, D. and Lee, E. 1989. An efficient implementation of self a dynamically-typed object-oriented language based on prototypes. SIGPLAN Not. 24, 10 (Sept.), 4970.CrossRefGoogle Scholar
Codognet, P. and Diaz, D. 1996. Compiling constraints in clp(fd). Journal of Logic Programming 27, 3, 185226.CrossRefGoogle Scholar
Cs, C. and Zhou, N.-F. 2007. A register-free abstract Prolog machine with jumbo instructions. In International Conference on Logic Programming.Google Scholar
Demoen, B. 2002. Dynamic attributes, their hProlog implementation, and a first evaluation. Technical Report CW 350, Department of Computer Science, K.U. Leuven, Leuven, Belgium. October.Google Scholar
ECMA International. 2009. ECMAScript Language Specification, Standard ECMA-262, Edition 5. Technical Report September. Available at http://wiki.ecmascript.org.Google Scholar
Gal, A., Eich, B., Shaver, M., Anderson, D., Mandelin, D., Haghighat, M. R., Kaplan, B., Hoare, G., Zbarsky, B., Orendorff, J., Ruderman, J., Smith, E. W., Reitmaier, R., Bebenita, M., Chang, M. and Franz, M. 2009. Trace-based just-in-time type specialization for dynamic languages. In Proceedings of the 2009 ACM SIGPLAN conference on Programming language design and implementation. PLDI '09. ACM, New York, NY, USA, 465478.CrossRefGoogle Scholar
Hermenegildo, M. V., Bueno, F., Carro, M., López, P., Mera, E., Morales, J. and Puebla, G. 2012. An overview of Ciao and its design philosophy. TPLP 12, 1–2, 219252. http://arxiv.org/abs/1102.5497.Google Scholar
Hermenegildo, M., Puebla, G., Bueno, F. and García, P. L. 2005. Integrated program debugging, verification, and optimization using Abstract interpretation (and The Ciao System Preprocessor). Science of Computer Programming 58, 12.CrossRefGoogle Scholar
Holzbaur, C. 1992. Metastructures vs. attributed variables in the context of extensible unification. In Proceedings of the 1992 International Symposium on Programming Language Implementation and Logic Programming. LNCS 631, Springer Verlag, 260268.Google Scholar
Holzbaur, C. 1995. OFAI clp(q,r) manual, edition 1.3.3. Technical Report TR-95-09, Austrian Research Institute for Artificial Intelligence, Vienna.Google Scholar
Holzbaur, C. and Frühwirth, T. W. 1999. Compiling constraint handling rules into prolog with attributed variables. In International Conference of Principles and Practice of Declarative Programming, PPDP'99. Lecture Notes in Computer Science, vol. 1702. Springer, 117133.CrossRefGoogle Scholar
Howe, J. M. and King, A. 2010. A pearl on sat solving in prolog. In FLOPS. 165174.CrossRefGoogle Scholar
Huitouze, S. L. 1990. A New Data Structure for Implementing Extensions to Prolog. In Proceedings of Programming Language Implementation and Logic Programming, Deransart, P. and Małuszyński, J., Eds. Lecture Notes in Computer Science, Number 456. Springer, 136150.CrossRefGoogle Scholar
Lindholm, T. and Yellin, F. 1996. The Java Virtual Machine Specification. Addison-Wesley.Google Scholar
Loitsch, F. and Serrano, M. 2007. Hop client-side compilation. In TFP 2007: Draft Proceedings of the 8th Symposium on Trends in Functional Programming.Google Scholar
Maffeis, S., Mitchell, J. and Taly, A. 2008. An operational semantics for JavaScript. In Proc. of APLAS'08. LNCS, vol. 5356. 307–325. See also: Dep. of Computing, Imperial College London, Technical Report DTR08-13, 2008.Google Scholar
Morales, J., Carro, M. and Hermenegildo, M. 2004. Improving the Compilation of Prolog to C Using Moded Types and Determinism Information. In Proceedings of the Sixth International Symposium on Practical Aspects of Declarative Languages. Lecture Notes in Computer Science, vol. 3057. Springer-Verlag, Heidelberg, Germany, 86103.CrossRefGoogle Scholar
Morales, J., Carro, M. and Hermenegildo, M. 2008. Comparing Tag Scheme Variations Using an Abstract Machine Generator. In Proceedings of the 10th Int'l. ACM SIGPLAN Symposium on Principles and Practice of Declarative Programming (PPDP'08). ACM Press, 3243.Google Scholar
Pineda, A. and Bueno, F. 2002. The O'Ciao Approach to Object Oriented Logic Programming. In Colloquium on Implementation of Constraint and LOgic Programming Systems (ICLP associated workshop). Copenhagen.Google Scholar
Tarau, P. 2011a. The binprolog experience: Architecture and implementation choices for continuation passing prolog and first-class logic engines. CoRR abs/1102.1178.Google Scholar
Tarau, P. 2011b. Integrated symbol table, engine and heap memory management in multi-engine prolog. SIGPLAN Not. 46, 11 (June), 129138.CrossRefGoogle Scholar
Warren, D. 1983. An Abstract Prolog Instruction Set. Technical Report 309, Artificial Intelligence Center, SRI International, 333 Ravenswood Ave, Menlo Park CA 94025.Google Scholar
Wielemaker, J. and Anjewierden, A. 2002. An architecture for making object-oriented systems available from prolog. In WLPE. 97110.Google Scholar
Wielemaker, J., Huang, Z. and vander Meij, L. der Meij, L. 2008. Swi-prolog and the web. Theory and Practice of Logic Programming 8, 3, 363392.CrossRefGoogle Scholar
Zakai, A. 2011. Emscripten: an llvm-to-javascript compiler. In Proceedings of the ACM international conference companion on Object oriented programming systems languages and applications companion. SPLASH '11. ACM, New York, NY, USA, 301312.CrossRefGoogle Scholar