Implementation Tour

45.1 Chez Scheme

Chez is renowned for compile speed and generated-code quality. Racket CS runs on it.

(import (chezscheme))
(time (let loop ((i 0) (acc 0)) (if (= i 10000000) acc (loop (+ i 1) (+ acc i)))))
(compile-file "app.ss")                     ; → app.so (machine code)
(load "app.so")
(printf "~a + ~a = ~a~n" 1 2 3)             ; Chez's printf/format
(define ht (make-hashtable equal-hash equal?))
(hashtable-set! ht "a" 1)
(hashtable-ref ht "a" 0)                    ; 1
(sort < '(3 1 2))                           ; (1 2 3)
(fork-thread (lambda () (display "in a thread")))   ; threaded builds
(trace-define (f x) (* x 2))                ; tracing
(inspect 'some-object)                      ; interactive inspector

45.2 GNU Guile

Guile provides POSIX bindings, a web server ((web server)), FFI, threads, GOOPS, fibers (via the fibers library), the Guix package manager ecosystem, and Hoot (compile to WebAssembly).

#!/usr/bin/env guile
!#
(use-modules (ice-9 format) (ice-9 textual-ports) (srfi srfi-1) (ice-9 match))
(format #t "~a has ~d items~%" "cart" 3)
(define content (call-with-input-file "notes.txt" get-string-all))
(define h (make-hash-table))
(hash-set! h 'a 1)
(hash-ref h 'a)                             ; 1
(sort '(3 1 2) <)                           ; (1 2 3)
(system "ls -l")                            ; run a shell command
(getenv "HOME")

45.3 CHICKEN

chicken-install srfi-1 http-client      # install eggs
csc -O3 app.scm -o app                  # compile to a native executable via C
csi                                     # interpreter / REPL
(import (chicken format) (chicken string) (chicken process-context))
(printf "Args: ~a~%" (command-line-arguments))
(string-split "a,b,c" ",")              ; ("a" "b" "c")

45.4 Others

gsc compiles to C or JavaScript; lightweight threads; used for embedding and the Gerbil Scheme system

Systems-programming dialect on Gambit with modules, actors, and a standard library

Tiny, embeddable in C, strict R7RS, many (chibi ...) libraries and the snow package tool

Fast-starting scripting, rich libraries, good Unicode MIT/GNU Scheme

SICP environment, native code compiler, Edwin #lang r7rs (via the r7rs package), plus Racket's own powerful libraries Compiles R7RS to C with native threads

Optimizing R6RS/R7RS compiler, bare-metal capable