Gauche — Practical Scheme Scripting

A fast, practical R7RS Scheme implementation for scripting and real-world programming.

Download Gauche Latest release: 0.9.15 Documentation

Latest news

2025/12/14

Gauche-gtk2 0.6.2

Minor update. A new API addition and adaptation to newer Gauche.

Past announcements ...

Why Gauche?

Designed for scripting

Gauche emphasizes quick startup time, smooth integration with the operating system, and expressive syntax, making it suitable for automation, build tools, and shell-like scripting.

Batteries included

Gauche comes with networking, Unicode strings and regular expressions, threads, various algorithm and data structures, and more—available out of the box.

Modern Scheme and beyond

Gauche is compatible with R7RS (small and large) and supports a large collection of finalized SRFIs, along with language extensions, including integrated lazy sequences, object system with metaobject protocol, and more.

Stable and maintained

Developed and used for over two decades, Gauche focuses on stability, backward compatibility, and long-term maintainability.

A Taste of Gauche

;; Generator of Fibonacci numbers.  ^ is a shorthand of lambda.
(define (make-fib-gen)
  (let ([a 1] [b 1])
    (^[] (let1 c (+ a b) (rotate! a b c)))))

;; Create a lazy infinite list of Fibonacci numbers
(define *fibs* (generator->lseq (make-fib-gen)))

;; Take first 20 Fibonacci numbers
(take *fibs* 20)
;⇒ (1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765)

;; What is the 100th Fibonacci number?
(~ *fibs* 100)
;⇒ 573147844013817084101

;; Find n such that Fib(n) exceeds 2^64 for the first time
(use scheme.list)
(length (take-while (cut > (expt 2 64) <>) *fibs*))
;⇒ 93

;; Draw a Fibonacci spiral
(use gauche.lazy)
(define (fib-spiral xsize ysize)
  ;; List of points of the start of the quarter arc.  We use complex numbers, so
  ;; rotation is just multiplication.
  (define *Pn*
    (lmap-accum (^[Fn rot acc]
                  (let1 next (+ acc (* rot (make-rectangular Fn Fn)))
                    (values acc next)))
                0 *fibs* (circular-list 1 -i -1 +i)))
  (define (draw-arc Fn Pn Pn+1)
    (format #t "<path d='M ~a ~a A ~a ~a 0 0 0 ~a ~a' fill='none' stroke='black'/>\n"
            (real-part Pn) (imag-part Pn) Fn Fn (real-part Pn+1) (imag-part Pn+1)))
  ;; Emit SVG content
  (print #"<svg xmlns='http://www.w3.org/2000/svg' \
           viewBox='~(- xsize) ~(- ysize) ~(* xsize 2) ~(* ysize 2)'>")
  (for-each draw-arc
            *fibs*
            (take-while (^p (or (< (abs (real-part p)) xsize)
                                (< (abs (imag-part p)) ysize)))
                        *Pn*)
            (cdr *Pn*))
  (print "</svg>"))

;; Save the generated SVG to a file.
(with-output-to-file "fib-spiral.svg" (cut fib-spiral 600 480))

Here's the generated svg file:

Programatically generated Fibonacci spiral

Extensions

Gauche has a growing ecosystem of libraries and extensions, including community-maintained SRFIs and practical tools.

  • Over 200 libraries and extensions
  • Package management via gauche-package command
  • Easy to write and distribute your own extensions

Browse available extensions