540 likes | 578 Views
Explore the history, success, and challenges faced by SWI-Prolog, a prominent logic programming language. Learn about its features, developments, commercial involvement, and community impact. Discover the place of Prolog in IT infrastructure and its role as a logic server.
E N D
Jan Wielemaker VU University Amsterdam ICLP-2012
ICLP-2012 Contents • Viewpoint • A brief history of SWI-Prolog • The Prolog landscape • The place of Prolog in IT infrastructure • The Prolog software community
ICLP-2012 Viewpoint • Logic programming • Programming languages • Prolog • Prolog implementations • Prolog usage • Prolog community (user and developers) • Used TPLP special issue on Prolog implementations
ICLP-2012 A brief history of SWI-Prolog • 1983 D. L. Bowen, L. M. Byrd, and WF. Clocksin. “A portable Prolog compiler” • 1986 I wrote a virtual machine based on this paper • 1987 Use in European KADS project, replacing Quintus. Distributed using FTP
ICLP-2012 Success in KADS • Bi-directional Prolog ↔ C interface allowed for better integration to PCE (graphics) • Quintus compatibility on `as needed' basis to support the project • Fast compiler, lazy loading (autoload) • Fast saved-state (based on `undump') and reload of modified code using ?- make. • Command-line editing and completion
ICLP-2012 Yet another Prolog(not to br confused YAP) • Satisfied our needs • We had full control • … but, nothing unique that was not added to commercial systems within weeks → Released • FTP • Academic `non-commercial use' • No need to fill out forms
ICLP-2012 Educational • Free of hassle (download, compile, use) • Supports popular academic Unix machines • Resource friendly • Compliant with primitives in textbooks
ICLP-2012 The Carrot: quick release model • Input • Contributions (mostly portability) • Bug reports • Functionality requests • Output • Fast response • Updated source on FTP, ranging from hours to a week
ICLP-2012 The middle ages (1988-2001) • New libraries, bugfixes, etc. • ISO part-I • Port to Windows 95/NT3.5 • Quality (CVS, test suite) • But … we missed lots of Prolog research (parallel, CLP, ...)
ICLP-2012 2001: License • GNU libreadline conflicts with non-commercial-use license • FSF: remove libreadline or change SWI-Prolog license → SWI-Prolog moved to LGPL • Started http://www.swi-prolog.org
ICLP-2012 2003: CLP • After Mumbai ICLP, together with Tom Schrijvers and Bart Demoen • Copy of `dynamic attributed variables' as proposed by Demoen and implemented for hProlog • Leuven CHR, coroutining • Markus Triska started pure Prolog clp(fd)
ICLP-2012 2003.. Web support • Multi-threading • Unicode • Atom garbage collection • SGML/XML • HTTP Server and client libraries • RDF libraries and store
ICLP-2012 Commercial involvement • Contributions • JPL, the Java interface • Quality checks and bug fixes • Sponsored development • Unbounded integers and rationals (GMP) • SSL interface • Memory management • PlDoc, PlUnit • IF/Prolog portability layer
ICLP-2012 Success • Right time • Early hassle-free Prolog for education • Early port to Windows (students) • Model • Quick release cycle: 2 weeks for development, 6 months for stable version • Technical • Interface, do-what-I-mean, robustness, interfaces
ICLP-2012 Failure • Trying to do `everything' • Packages often rely on undocumented SWI-specific extensions, making it hard to reuse them • Improving • Development APIs (share with PDT) • Modularized I/O and OS interface (YAP) • Modularize (GIT) repository
ICLP-2012 Part-II The Prolog landscape
ICLP-2012 Is Prolog in BAD shape? • Ohloh (http://www.ohloh.net/)
ICLP-2012 Is Prolog in BAD shape? • Discontinued in many Dutch universities or moved to a `language overview course' • Hard to convince our (PhD) students to use it, even for RDF because • Perceived as `hard to learn' • No modern (IDE) tools • No library for X, Y and Z (you name it) • ``An irrelevant language from the past'' • ``I always programmed in (often) Java''
ICLP-2012 Some often heard reasons • (Early) fragmentation of the language • No programmers/No jobs • Logic programming/Prolog is unsuitable as a general purpose language • Failed standardization
ICLP-2012 Fragmentation? #Implementations (source: OpenDirectory)
ICLP-2012 No programmers?
ICLP-2012 Books Source: Amazon (UK)
ICLP-2012 The Gartner Hype Cycle Explained
ICLP-2012 Part III The place of Prolog in IT infrastructure
ICLP-2012 General Purpose vs Logic server • `General purpose' • Missing language features (e.g., destructive assignment) • Needs graphics, Web, DB, etc., interfaces • `Logic server' • Needs language interfaces • Suffers from object/relational impedance mismatchhttp://en.wikipedia.org/wiki/Object-relational_impedance_mismatch
ICLP-2012 Logic server • Native (Amzi!) • JVM based (Jinni, Minerva, Jekejeke, …) • Successor • BinProlog → Jinni • IF/Prolog → Minerva
ICLP-2012 Embedding is popular • SWI-Prolog has interfaces for C (native), C++ (native and contributed), Java, C#, Python, Perl (contributed) • 113 projects on GitHUB combine Prolog with:
ICLP-2012 SWI-Prolog: `glue' • Prolog is good at `glue' due to • Dynamic nature (incl. typing) • Flexible dynamically typed data representation makes it simple to represent data from external systems • Natural mapping of tabular data • Interactive development environment • Rules, DSLs, ...
ICLP-2012 Some realized `glue' (for SWI) • Databases (ODBC) • RDF • XML/SGML/HTML • R (statistical computing) • HTTP Server library • Spatial reasoning (geos library) • OpenGL, OSC, MIDI, Gtk, Matlab, ...
ICLP-2012 Prolog as primary language(SecuritEase)
ICLP-2012 Conclusion • `Logic server' seems a more natural and easier to sell first option • Provided with well designed `glue', Prolog is also attractive as primary application language, including scripting
ICLP-2012 Part IV The Prolog software community
ICLP-2012 Comparing models * Stability of specification makes duplicates easier to handle
ICLP-2012 Forking (Unix wars) Source: Wikipedia
ICLP-2012 Distributions (Linux)
ICLP-2012 Summary • Shared standards are good but slow. Fits poorly in a culture of innovation. • Shared code leads to • Reuse (stand on the shoulders of giants) • Fast innovation • Sharing needs a common ground And, where do we stand?
ICLP-2012 Independent Development • Various module systems • Predicate based ↔ name based • Operating system access • File system, networking • Interfaces • DB, Graphics, C, Java, C#, ...
ICLP-2012 Shared design • WAM • Garbage collectors • Tabled evaluation • Attributed variables
ICLP-2012 Shared specification • ISO standard
ICLP-2012 Forked specification • Quintus module system (SICStus, Ciao, YAP, SWI) • hProlog Dynamic attributed vars (SWI, YAP, XSB) • SWI Thread API (YAP, XSB)
ICLP-2012 Forked code • DEC10 library (forked many times) • clp(q,r) • Draxler's Prolog → SQL compiler • SWI I/O and OS access (YAP, close to shared) • SWI XML/SGML (XSB) • SWI PlUnit (SICStus) • Parts of XSB tabling (YAP)?
ICLP-2012 Shared Prolog components • Logtalk (many) • CHR (hProlog, SWI, XSB, YAP, B-Prolog, SICStus, Ciao)
ICLP-2012 Requirements for sharing • Common ground for • Core Prolog (++) • Prolog extensions (attvar,tabling) (+) • Structuring (modules, objects) (+/-) • Interface to non-Prolog resources (–) http://www.cs.unipr.it/~bagnara/Papers/Prolog-FLI-survey • Always remaining issues → need work-around • Conditional compilation (++) • Macro expansion (+)
ICLP-2012 Comparision of FLI m: manual, f: functional, p: procedural, l: low level, s: static, d: dynamic, b: both http://www.cs.unipr.it/~bagnara/Papers/Prolog-FLI-survey
ICLP-2012 Progress (Foreign) • FLI emulations • SICStus ↔ SWI (Alpino, XPCE) • YAP ← SWI (SWI packages) • YAP ← Bprolog (PRISM) • Reuse SWI I/O and OS builtins in YAP • In part based on FLI emulation • Also emulated low-level SWI FLI
ICLP-2012 Prolog Commons • Goal: arrive at a shared Prolog library • Minimal shared module support • Shared document and annotation model • Ciao effort • Website, GIT repo
ICLP-2012 YAP/SWI`dialect' framework :- expects_dialect(X) says • Text is written for X • Loads dialect(X) (= library(dialect/X)) • Defines built-ins of X not in target • Rewrites conflicting built-ins using macros • Rewrites module API using macros • Pushes X-compatible library
ICLP-2012 Dialects implemented • YAP • BProlog, Commons, hProlog, SWI-Prolog • SWI • YAP, BIM, hProlog, Commons, Ciao, IF/Prolog `As-needed' basis
ICLP-2012 Dialect applied (SWI) • Alpino (now maintained as portable code) • 500Klines, C,C++,Tcl/Tk • SICStus → SWI • Prosyn (ported) • 1Mlines, C,C++ (Windows MFC) • IF/Prolog → SWI • Replaced MFC with web-GUI, other C with pure Prolog code
ICLP-2012 Dialect Applied (YAP) • Many of SWI's extension packages • PRISM