philipbohun.com

Glojure by Example

Glojure is an interpreter for Clojure hosted on Go. Clojure values and Go values live in the same process, so a Glojure program can call Go libraries the way Clojure on the JVM calls Java.

Glojure by Example is a hands-on introduction using annotated example programs. Start with Hello World or browse the full list below.

The tour follows the shape of Go by Example. Go features that Glojure does not have are omitted, including const and iota, struct embedding, generics, channel direction types, defer and panic, the embed directive, and host packages glj does not export (such as encoding/json, encoding/xml, crypto/sha256, encoding/base64, net, log, and text/template). Clojure topics that the Go tour never reaches are added instead: keywords, lists, sets, sequences, namespaces, records, protocols, multimethods, atoms, exceptions, EDN, reader conditionals, and embedding.

Examples were run with glojure v0.7.25. Install the glj command with go install github.com/glojurelang/glojure/cmd/glj@latest. Glojure is still pre-1.0, so a few Clojure forms are missing or behave differently. Those differences are called out on the pages where they matter.