https://github.com/glojurelang/glojure Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By company size + Enterprises + Small and medium teams + Startups By use case + DevSecOps + DevOps + CI/CD + View all use cases By industry + Healthcare + Financial services + Manufacturing + Government + View all industries View all solutions * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners + Executive Insights * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} glojurelang / glojure Public * Notifications You must be signed in to change notification settings * Fork 2 * Star 287 Clojure interpreter hosted on Go, with extensible interop support. License EPL-1.0 license 287 stars 2 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 15 * Pull requests 1 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights glojurelang/glojure main BranchesTags [ ] Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 317 Commits .github/workflows .github/workflows cmd cmd doc doc internal internal nix nix pkg pkg scripts scripts test/glojure/ test/glojure/ test_glojure test_glojure .envrc .envrc .gitignore .gitignore CODEOWNERS CODEOWNERS LICENSE.md LICENSE.md Makefile Makefile README.md README.md go.mod go.mod go.sum go.sum shell.nix shell.nix View all files Repository files navigation * README * EPL-1.0 license Glojure example workflow Try it in your browser! (fair warning: startup on the web is slow) Gopher image Gopher image derived from @egonelbre, licensed under Creative Commons 1.0 Attributions license. Glojure is an interpreter for Clojure, hosted on Go. Glojure provides easy access to Go libraries, similar to how Clojure provides easy access to Java frameworks. Glojure is in early development; expect bugs, missing features, and limited performance. Backwards compatibility is not guaranteed until a v1 release. That said, it is used successfully in hobby projects and runs a significant subset of the (transformed) core Clojure library. Note that unlike most other Go implementations of Clojure, Glojure is a "hosted" language - a term used to describe languages that are implemented in terms of a host language (in this case, Go). This means that all Go values can be used as Glojure values and vice versa. Prerequisites Before you get started with Glojure, make sure you have installed and have knowledge of Go (version 1.19 or higher). Installation Glojure is currently available from source for all platforms where Go can run, and it requires at least go 1.19. Install it with the go install command: $ go install github.com/glojurelang/glojure/cmd/glj@latest After installation, you can start the REPL (Read-Eval-Print-Loop) with the glj command: $ glj user=> (println "Hello, world!") Hello, world! nil user=> Usage Here's a small example program that starts an HTTP server with a simple handler function that responds with the request body: ;; example.glj (ns example.server) (defn echo-handler [w r] (io.Copy w (.Body r)) nil) (net$http.Handle "/" (net$http.HandlerFunc echo-handler)) (net$http.ListenAndServe ":8080" nil) Run it with the glj command: $ glj ./example.glj $ curl localhost:8080 -d "sicp" sicp Interop Glojure ships with interop with many standard library packages out-of-the-box. Go package names are munged to avoid ambiguity with the use of / to refer to namespaced symbols; instances of / in package names are replaced with $. Here's a simple example: user=> (println (fmt.Sprintf "A couple of HTTP methods: %v" [net$http.MethodGet net$http.MethodPost])) A couple of HTTP methods: ["GET" "POST"] nil The following standard library packages are included by default: * bytes * context * errors * flag * fmt * io * io/fs * io/ioutil * math * math/big * math/rand * net/http * os * os/exec * os/signal * regexp * reflect * sort * strconv * strings * sync * sync/atomic * time * unicode To expose additional packages, you must generate a "package map" and compile your own executable that imports both your package map and the Glojure API. See the section below for more details. Expect improvements to both the availability of standard library packages and interop workflows. Accessing additional Go packages The gen-import-interop can be used to emit the contents of a .go file that will export a function that can be used to add the exports of additional packages to the Glojure package map. $ go run github.com/glojurelang/glojure/cmd/gen-import-interop \ -packages=:comma-separated-package-list: \ > your/package/gljimports/my_package_map.go Then, in your own program: package main import ( // Add your packages' exports to the pkgmap. _ "your.package/gljimports" ) // ... Differences from Clojure Numbers Clojure Glojure Type Notes Type long int64 double float64 float float32 double float64 byte byte Note that Go bytes are unsigned, whereas JVM bytes are signed. short int16 Note that JVM ints are 32-bit, whereas Go int int ints are 32- or 64-bit depending on the platform. The Glojure type is a tagged rune (type char lang.Char Char rune). JVM chars are 16-bit whereas Go runes are 32-bit. BigInt *lang.BigInt The Glojure type wraps *big.Int. BigDecimal *lang.BigDecimal The Glojure type wraps *big.Float. Ratio *lang.Ratio The Glojure type wraps *big.Rat. BigInteger *big.Int Native JVM BigInteger corresponds to *big.Int. Comparisons to other Go ports of Clojure Aspect Glojure Joker let-go Hosted^1 Yes No No Extensible Go interop Yes No No Concurrency Yes Yes (with GIL) Yes Clojure tooling (e.g. No Yes No linter) Execution Tree-walk Tree-walk Bytecode interpreter interpreter Interpreter If you'd like to see another port in this table, or if you believe there is an error in it, please file an issue or open a pull request! Footnotes 1. What does it mean to be a hosted language? For Clojure on the JVM, it means that all Java values are also Clojure values, and vice versa. Glojure strives to maintain the same relationship with Go. - About Clojure interpreter hosted on Go, with extensible interop support. Resources Readme License EPL-1.0 license Activity Custom properties Stars 287 stars Watchers 5 watching Forks 2 forks Report repository Releases 8 v0.2.6 Latest Oct 13, 2024 + 7 releases Packages 0 No packages published Contributors 3 * @jfhamlin jfhamlin James Hamlin * @elh elh Eugene Huang * @mateodif mateodif Mateo Difranco Languages * Go 92.2% * Clojure 7.6% * Other 0.2% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.