GNU Guile

Last updated
GNU Guile
GNU-Guile-logo.svg
Family Lisp
Designed by Aubrey Jaffer, Tom Lord, Miles Bader
Developer GNU Project
First appeared1993;31 years ago (1993) [1]
Stable release
3.0.9 [2] / 25 January 2023;12 months ago (2023-01-25) [2]
Platform IA-32, x86-64, AArch64, armel, armhf, mips, mips64el, mipsel, ppc64el, s390x
OS Linux, BSD, Windows (through MinGW or Cygwin)
License LGPL-3.0-or-later
Filename extensions .scm .go (Guile object)
Website gnu.org/software/guile
Influenced by
Lisp, Scheme, SCM

GNU Ubiquitous Intelligent Language for Extensions [3] (GNU Guile) is the preferred extension language system for the GNU Project [4] and features an implementation of the programming language Scheme. Its first version was released in 1993. [1] In addition to large parts of Scheme standards, Guile Scheme includes modularized extensions for many different programming tasks. [5] [6]

Contents

For extending programs, Guile offers libguile which allows the language to be embedded in other programs, and integrated closely through the C language application programming interface (API); similarly, new data types and subroutines defined through the C API can be made available as extensions to Guile. [7]

Guile is used in many programs under the GNU project umbrella (GDB, Make, Guix, GNU TeXmacs, GnuCash, LilyPond Lepton-EDA...) [8] but it also sees use outside of that, for example in Google's schism.

Guile Scheme

Guile Scheme is a general-purpose, high-level programming language whose flexibility allows expressing concepts in fewer lines of code than would be possible in languages such as C. For example, its hygienic macro system allows adding domain specific syntax-elements without modifying Guile. Guile implements the Scheme standard R5RS, most of R6RS and R7RS, [9] several Scheme Requests for Implementation (SRFI), and many extensions of its own.

The core idea of Guile Scheme is that "the developer implements critical algorithms and data structures in C or C++ and exports the functions and types for use by interpreted code. The application becomes a library of primitives orchestrated by the interpreter, combining the efficiency of compiled code with the flexibility of interpretation." [10] Thus Guile Scheme (and other languages implemented by Guile) can be extended with new data types and subroutines implemented through the C API.

The standard distribution offers modules for Portable Operating System Interface (POSIX) system calls, scheduling, a foreign function interface, S-expression based XML processing through SXML, SXPath, and SXSLT, HTTP and other World Wide Web APIs, delimited continuations, array programming, [11] and other functionality. [5] [6] Guile programs can use facilities from SLIB, the portable Scheme library. [12]

Implementation details

When using continuations with call/cc, a requirement of the Scheme standard, Guile copies the execution stack into the heap and back. [13] Its manual suggests using delimited continuations instead, because they have a more efficient implementation. [14]

Because foreign code may have pointers to Scheme objects, Guile uses the conservative Boehm–Demers–Weiser (BDW) garbage collector. [15]

History

The Guile manual gives details of the inception and early history of the language. [16] A brief summary follows:

After the success of Emacs in the free software community, as a highly extensible and customizable application via its extension (and partly implementation) language Emacs Lisp, the community began to consider how this design strategy could apply to the rest of the GNU system. Tom Lord initially began work on an embeddable language runtime named the GNU Extension Language (GEL), which was based on Aubrey Jaffer's Scheme implementation SCM (which in turn was based on George Carrette's SIOD). [17] [18] Lord convinced Richard Stallman to make GEL the official extension language of the GNU project, based on the argument that Scheme was a cleaner Lisp dialect than Emacs Lisp, and that GEL could evolve to implement other languages on the same runtime, namely Emacs Lisp. After Lord discovered GEL had a naming conflict with another programming language, he solicited suggestions for a new name. From several contributions in several Usenet newsgroups, Lord controversially chose Guile from a suggestion by Lee Thomas. [19] [20] [21] [22]

During the development of Guile (then GEL) and before its public release, the extension language Tcl was gaining popularity and being pushed as a universal extension language. Stallman saw Tcl as being underpowered as an extension language, and posted a criticism to the comp.lang.tcl newsgroup, which initiated a flamewar known as the "Tcl War". [23] Since the public announcement of the Guile project coincided with the Tcl debate, it has become a common misconception that Guile began as a reaction to this.

After the initial release of Guile, development languished for many years, but 2009–2010 saw major improvements, [24] and Guile 2.0 was released in 2011 with a new compiler infrastructure, a virtual machine implementation, a switch to the Boehm–Demers–Weiser garbage collector, many improvements to the Guile Scheme language, and other major changes. [25]

One of the goals of Guile is to allow other languages to be used alongside Scheme, such that Guile would effectively be a language-neutral runtime environment. Various attempts at this have been made in past versions: a dialect of Scheme essentially differing only in its C-like syntax, a translation of Emacs Lisp, a Tcl converter motivated by tkWWW, and something roughly resembling the language Logo. [26] With version 2.0, the project successfully transitioned to a compiler tower approach, allowing the definition of compilers from one language to another, typically from a higher-level one to a lower-level intermediate representation, and eventually virtual machine bytecode or native machine code. [27] [28]

On 16 Mar 2017, Guile 2.2.0 was released with a new optimizing compiler and high-performance register virtual machine. According to the release announcement by Andy Wingo, real-world programs often showed a speedup of 30% or more with Guile 2.2 when compared to the previous 2.0 series. Guile 2.2.0 also lowered memory usage, sped up the "eval" interpreter, provided better support for multi-core programming, and removed any fixed limit on recursive function calls. It also supported the creation of user-space concurrency facilities that multiplex millions of concurrent lightweight "fibers" and provided a complete Emacs-compatible Elisp implementation, implementing all of Elisp's features and quirks in the same way as Emacs. [29]

On 16 January 2020, Guile 3.0.0 was released with just-in-time (JIT) native code generation for much greater performance. Compared to 2.2, microbenchmark performance is around twice as good on the whole, while some individual benchmarks are up to 32 times as fast. It also featured support for interleaved definitions and expressions in lexical contexts, native support for structured exceptions, better support for the R6RS and R7RS Scheme standards and many optimizations. [30] [31]

19581960196519701975198019851990199520002005201020152020
 LISP 1, 1.5, LISP 2(abandoned)
  Maclisp
  Interlisp
  MDL
  Lisp Machine Lisp
  Scheme  R5RS R6RS R7RS small
  NIL
  ZIL (Zork Implementation Language)
  Franz Lisp
  Common Lisp  ANSI standard
  Le Lisp
  MIT Scheme
  XLISP
  T
  Chez Scheme
  Emacs Lisp
  AutoLISP
  PicoLisp
  Gambit
  EuLisp
  ISLISP
  OpenLisp
  PLT Scheme   Racket
  newLISP
  GNU Guile
  Visual LISP
  Clojure
  Arc
  LFE
  Hy
  Chialisp

Emacs integration

There have been several past unfinished attempts to replace or supplement the Emacs Lisp extension language with Guile, parallel to the efforts of supporting other languages in Guile.[ citation needed ]

With version 2.0 of Guile, a new attempt at implementing Elisp on the Guile compiler tower and replacing Emacs's Elisp implementation with that of libguile has begun and made significant progress through Google Summer of Code projects. [32] A Guile-based Emacs could offer better execution performance for Emacs Lisp, support new Emacs Lisp language features more easily, make Guile libraries written in other programming languages available to Emacs Lisp code, and allow writing Emacs extensions in other programming languages supported by Guile, all while remaining fully backward compatible with existing Emacs Lisp code bases.

As of October 2014, the implementation had reached a stage where Guile Emacs is able to reliably run most Emacs Lisp code. Remaining problems or possible problems involve the different internal representation of Emacs Lisp strings from Scheme strings, the difference between how Emacs Lisp and Scheme treat the Boolean false and empty list objects, Emacs Lisp macros not integrating with Scheme, Emacs Lisp not having been designed for concurrency, and the portability of Guile to platforms supported by Emacs. Other concerns raised by the Emacs community include the relative sizes of the Emacs and Guile communities, and whether it would cause splitting in the community if Emacs were extensible in programming languages other than Emacs Lisp. [33]

GNU Make integration

GNU make can be built with support for GNU Guile as an embedded extension language. [34]

Related Research Articles

<span class="mw-page-title-main">Common Lisp</span> Programming language standard

Common Lisp (CL) is a dialect of the Lisp programming language, published in American National Standards Institute (ANSI) standard document ANSI INCITS 226-1994 (S2018). The Common Lisp HyperSpec, a hyperlinked HTML version, has been derived from the ANSI Common Lisp standard.

<span class="mw-page-title-main">Emacs Lisp</span> Dialect of Lisp used as the primary implementation and extension language for Emacs

Emacs Lisp is a dialect of the Lisp programming language used as a scripting language by Emacs. It is used for implementing most of the editing functionality built into Emacs, the remainder being written in C, as is the Lisp interpreter. Emacs Lisp is also termed Elisp, although there are also older, unrelated Lisp dialects with that name.

An integrated development environment (IDE) is a software application that provides comprehensive facilities for software development. An IDE normally consists of at least a source-code editor, build automation tools, and a debugger. Some IDEs, such as IntelliJ IDEA, Eclipse and Lazarus contain the necessary compiler, interpreter or both; others, such as SharpDevelop and NetBeans, do not.

<span class="mw-page-title-main">Lisp (programming language)</span> Programming language family

Lisp is a family of programming languages with a long history and a distinctive, fully parenthesized prefix notation. Originally specified in 1960, Lisp is the third-oldest high-level programming language still in common use, after Fortran and COBOL. Lisp has changed since its early days, and many dialects have existed over its history. Today, the best-known general-purpose Lisp dialects are Common Lisp, Scheme, Racket, and Clojure.

<span class="mw-page-title-main">Scheme (programming language)</span> Dialect of Lisp

Scheme is a dialect of the Lisp family of programming languages. Scheme was created during the 1970s at the MIT Computer Science and Artificial Intelligence Laboratory and released by its developers, Guy L. Steele and Gerald Jay Sussman, via a series of memos now known as the Lambda Papers. It was the first dialect of Lisp to choose lexical scope and the first to require implementations to perform tail-call optimization, giving stronger support for functional programming and associated techniques such as recursive algorithms. It was also one of the first programming languages to support first-class continuations. It had a significant influence on the effort that led to the development of Common Lisp.

Bytecode is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references that encode the result of compiler parsing and performing semantic analysis of things like type, scope, and nesting depths of program objects.

<span class="mw-page-title-main">Common Lisp Object System</span>

The Common Lisp Object System (CLOS) is the facility for object-oriented programming in ANSI Common Lisp. CLOS is a powerful dynamic object system which differs radically from the OOP facilities found in more static languages such as C++ or Java. CLOS was inspired by earlier Lisp object systems such as MIT Flavors and CommonLoops, although it is more general than either. Originally proposed as an add-on, CLOS was adopted as part of the ANSI standard for Common Lisp and has been adapted into other Lisp dialects such as EuLisp or Emacs Lisp.

Scheme In One Defun, or humorously Scheme In One Day (SIOD) is a programming language, a dialect of the language Lisp, a small-size implementation of the dialect Scheme, written in C and designed to be embedded inside C programs. It is notable for being perhaps the smallest practical implementation of a Lisp-like language. It was written by George J. Carrette originally. It is free and open-source software released under a GNU Lesser General Public License (LGPL).

Hemlock is a free Emacs text editor for most POSIX-compliant Unix systems. It follows the tradition of the Lisp Machine editor ZWEI and the ITS/TOPS-20 implementation of Emacs, but differs from XEmacs or GNU Emacs, the most popular Emacs variants, in that it is written in Common Lisp rather than Emacs Lisp and C—although it borrows features from the later editors. Hemlock was originally written by the CMU Spice project in Spice Lisp for the PERQ computer.

A foreign function interface (FFI) is a mechanism by which a program written in one programming language can call routines or make use of services written or compiled in another one. An FFI is often used in contexts where calls are made into binary dynamic-link library.

Scheme 48 is a programming language, a dialect of the language Scheme, an implementation using an interpreter which emits bytecode. It has a foreign function interface for calling functions from the language C and comes with a library for regular expressions (regex), and an interface for Portable Operating System Interface (POSIX). It is supported by the portable Scheme library SLIB, and is the basis for the Scheme shell Scsh. It has been used in academic research. It is free and open-source software released under a BSD license.

<span class="mw-page-title-main">SCM (Scheme implementation)</span> Implementation of the Scheme programming language

SCM is a programming language, a dialect of the language Scheme.

SISC is an R5RS Scheme implementation, which includes a full number tower, hygienic macros, proper tail recursion, and first class continuations. SISC is short for Second Interpreter of Scheme Code, in reference to its predecessor LISC, the Lightweight Interpreter of Scheme Code.

libffi is a foreign function interface library. It provides a C programming language interface for calling natively compiled functions given information about the target function at run time instead of compile time. It also implements the opposite functionality: libffi can produce a pointer to a function that can accept and decode any combination of arguments defined at run time.

<span class="mw-page-title-main">GNU Emacs</span> GNU version of the Emacs text editor

GNU Emacs is a free software text editor. It was created by GNU Project founder Richard Stallman, based on the Emacs editor developed for Unix operating systems. GNU Emacs has been a central component of the GNU project and a flagship project of the free software movement. Its tag line is "the extensible self-documenting text editor."

Emacs, originally named EMACS, is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as "the extensible, customizable, self-documenting, real-time display editor". Development of the first Emacs began in the mid-1970s, and work on GNU Emacs, directly descended from the original, is ongoing; its latest version is 29.2, released January 2024.

<span class="mw-page-title-main">Scripting language</span> Programming language for run-time events

A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled.

Tcl is a high-level, general-purpose, interpreted, dynamic programming language. It was designed with the goal of being very simple but powerful. Tcl casts everything into the mold of a command, even programming constructs like variable assignment and procedure definition. Tcl supports multiple programming paradigms, including object-oriented, imperative, functional, and procedural styles.

References

  1. 1 2 Blandy 1997, p. 102.
  2. 1 2 "GNU Guile 3.0.9 released". gnu.org.
  3. "GNU Guile (About Guile)". GNU Project. Guile is the GNU Ubiquitous Intelligent Language for Extensions, the official extension language for the GNU operating system.
  4. "GNU coding standards, Which Languages to Use". GNU Project.
  5. 1 2 "Guile Manual, API Reference". GNU Project.
  6. 1 2 "Guile Manual, Guile Modules". GNU Project.
  7. "To encourage customization, Guile provides extensive interfaces, allowing C code to interact with the Scheme world. C code can freely create, access, and mutate Scheme objects; C functions may call Scheme functions and vice versa; C code may add new types to the Scheme world and take advantage of Guile's garbage collection… Most of the standard Scheme procedures are implemented by C functions, visible to Guile clients; for example, applications can call the C function scm_cons, which is the underlying implementation of the Scheme procedures cons ." Blandy 1997, pp. 94, 96.
  8. "Applications using Guile". GNU Project. Archived from the original on 2017-11-24.
  9. "R7RS Incompatibilities (Guile Reference Manual)". GNU Project. Retrieved 2020-01-20.
  10. Blandy 1997, p. 87.
  11. "Guile Manual, Arrays". GNU Project.
  12. "Guile Manual, SLIB". GNU Project. SLIB is not included in the Guile distribution, but can be installed separately.
  13. "Because Guile allows foreign functions and Scheme functions to call each other freely, a Guile continuation may include both C and Scheme stack frames. For simplicity, Guile's implementation of call/cc copies the entire C stack into the heap; invoking a continuation copies the stack back from the heap and uses the longjmp function to reactivate it. This implementation has a number of drawbacks...", Blandy 1997, p. 99.
  14. "Guile Manual, Continuations". GNU Project.
  15. "Guile Manual, Conservative GC". GNU Project.
  16. "Guile Manual, History".
  17. "It's hard to determine just who designed Guile. A large share of the credit surely belongs to Aubrey Jaffer whose excellent Scheme interpreter, SCM, forms the core of the implementation. The module system was designed and built by Miles Bader…" "An Anatomy of Guile, The Interface to Tcl/Tk", 1995
  18. "Here is a very, very brief history of this interpreter. I hope that people involved in its past will contribute more to this document. SIOD: George Carrette wrote SIOD, the earliest version. Although most of this code has been rewritten or replaced over time, the garbage collector from SIOD is still an important part of Guile. SIOD is still actively developed and freely available. It has a very small footprint." Guile Scheme 1995.
  19. "The name Guile was first suggested in a Usenet discussion by Lee Thomas." Guile Scheme 1995.
  20. Lee Thomas (1994-11-04). "The Name of the Rose". Newsgroup:  gnu.misc.discuss.
  21. "GUILE - two more reasons to prefer it".
  22. "GEL:Important Name Change".
  23. Archives of the Tcl War
  24. Wingo, Andy. "Older blog entries for wingo (starting at number 328)". Advogato.
  25. "Guile News". GNU Project. Archived from the original on 2014-03-28.
  26. Lord, Thomas (July 1995). "An Anatomy of Guile The Interface to Tcl/Tk" (PostScript). Third Annual Tcl/Tk Workshop. Toronto, Ontario, Canada: Usenix . Retrieved 23 November 2010.
  27. "Guile Manual, Other Languages". GNU Project. Guile is still fundamentally a Scheme, but it tries to support a wide variety of language building-blocks, so that other languages can be implemented on top of Guile.
  28. "Guile Manual, Compiler Tower". GNU Project. Guile defines a tower of languages, starting at Scheme and progressively simplifying down to languages that resemble the VM instruction set.
  29. "GNU Guile 2.2.0 released". 2017-03-16. Retrieved 2020-01-20.
  30. "GNU Guile 3.0.0 released". 2020-01-16. Retrieved 2020-01-20.
  31. "GNU Guile 3.0.0 released". 2020-01-16. Retrieved 2020-01-20.
  32. "Re. Elisp implementation?". BT Templeton.
  33. "The future of Emacs, Guile, and Emacs Lisp".
  34. "12.1 GNU Guile Integration". gnu.org . Retrieved 16 March 2020.

Further reading