# πŸ”₯ Bara Lang > A Clojure dialect that compiles to Nim β†’ C β†’ native binaries. > Zero JVM. Zero Java. Pure native performance. [![Version](https://img.shields.io/badge/version-0.1.0-blue)](cljnim.nimble) [![Tests](https://img.shields.io/badge/tests-276%2B-green)]() [![Nim](https://img.shields.io/badge/nim-%3E%3D2.0-blue)](https://nim-lang.org) [![License](https://img.shields.io/badge/license-MIT-yellow)](LICENSE) [![Pipeline](https://gitlab.com/balvatar/lisp-nim/badges/main/pipeline.svg)](https://gitlab.com/balvatar/lisp-nim/-/pipelines) [![Coverage](https://img.shields.io/badge/coverage-clojure--test--suite-blue)](docs/en/07-clojure-test-suite.md)
## ⚑ Why Bara Lang? | | JVM Clojure | ClojureScript | Babashka | **Bara Lang** | |---|---|---|---|---| | JVM required | βœ… Yes | ❌ No | ❌ No | βœ… **No** | | GraalVM/native-image | ❌ Needed | ❌ No | βœ… Required | βœ… **No** | | Google Closure Compiler | ❌ No | βœ… Required | ❌ No | βœ… **No** | | Java stdlib dependency | βœ… Full | βœ… Heavy | βœ… Medium | βœ… **None** | | Startup time | ❌ Slow | ⚑ Fast | ⚑ Fast | ⚑ **Instant** | | Binary size | ❌ 50MB+ | ❌ ~MB | ❌ ~MB | βœ… **~3MB** | | Native speed | ❌ JIT | ❌ VM | βœ… AOT | βœ… **C-speed** | | FFI | ❌ JNI/C | ❌ JS | ❌ Limited | βœ… **Nim/C native** | Bara Lang is an **AI-first** Clojure implementation targeting the Nim ecosystem. It compiles Clojure source directly to Nim, then to C, and finally to a native binary. **Unlike every other Clojure dialect, Bara Lang has zero dependency on the Java ecosystem.** ## πŸš€ Quick Start ```bash git clone https://gitlab.com/balvatar/lisp-nim.git cd lisp-nim make build make check ./cljnim run examples/hello.clj ``` ```clojure ;; examples/hello.clj (println "Hello, native world!") ``` ```bash $ ./cljnim run examples/hello.clj Hello, native world! ``` ## πŸ“– Documentation | Language | Link | Contents | |---|---|---| | πŸ‡¬πŸ‡§ English | [docs/en/index.md](docs/en/index.md) | Getting started, architecture, AI integration, API reference | | πŸ‡§πŸ‡¬ Π‘ΡŠΠ»Π³Π°Ρ€ΡΠΊΠΈ | [docs/bg/index.md](docs/bg/index.md) | ΠŸΡŠΡ€Π²ΠΈ ΡΡ‚ΡŠΠΏΠΊΠΈ, Π°Ρ€Ρ…ΠΈΡ‚Π΅ΠΊΡ‚ΡƒΡ€Π°, AI интСграция, API справочник | | πŸ§ͺ Test Suite | [docs/en/07-clojure-test-suite.md](docs/en/07-clojure-test-suite.md) | Cross-dialect compliance with [jank-lang/clojure-test-suite](https://github.com/jank-lang/clojure-test-suite) | ## ✨ What Makes This Unique? ### 1. Completely Independent from Java The **only** Clojure dialect with absolutely no dependency on the Java ecosystem β€” not the JVM, not GraalVM, not the Java standard library, and not Google Closure Compiler. ``` Clojure source β†’ Nim source β†’ C source β†’ native binary ``` ### 2. Native HAMT Persistent Data Structures Built from scratch in Nim: - **Persistent Vector** β€” Hash Array Mapped Trie with 32-way branching and structural sharing - **Persistent Map** β€” HAMT-based immutable hash map, O(log₃₂ n) operations - **Persistent Set** β€” Backed by HAMT map - **Transients** β€” Batch mutations with `conj!`, `assoc!`, `persistent!` ### 3. Multiple Compilation Targets The same Clojure code compiles to: | Target | Status | Use Case | |--------|--------|----------| | **Native binary** | βœ… Ready | CLI tools, system programming, servers | | **Shared library** (.so/.dll/.dylib) | βœ… Ready | Embed in Python/Rust/Go/C via FFI | | **WASM** | βœ… Ready | Browser, serverless, edge computing | | **JavaScript** | βœ… Ready | Frontend, Node.js without 50MB JVM | ### 4. AOT Compiler β€” Not an Interpreter Full ahead-of-time compilation with C-speed execution and binary sizes ~3MB (debug), <1MB when stripped. The REPL uses a hybrid model: tree-walking interpreter for fast feedback (<1ms eval), AOT compilation for production builds. ### 5. Nim/C Interop Instead of Java Interop Direct FFI to the Nim and C ecosystem: ```clojure (nim/math/sin x) (nim/strutils/toUpper s) (nim/json/write-value-as-string data) ``` No JNI, no JVM bridging, no Java interop overhead. ### 6. AI-Native Tooling Built-In - **AI-assisted errors** β€” DeepSeek/MiMo explain compiler errors - **AI code generation** β€” `(ai/generate "quicksort")` in REPL - **AI optimization hints** β€” `(ai/optimize code)` suggests improvements - **AI debugging** β€” `(ai/debug expr)` analyzes runtime behavior - **JSON REPL protocol** β€” Structured I/O for AI agents and IDE integration ### 7. Concurrency Without the JVM - **Atoms** β€” Compare-and-swap semantics - **Agents** β€” Async state updates with `send`/`await` - **core.async channels** β€” `chan`, `>!`, ``, `->>`) | βœ… | | Persistent data structures (HAMT vector/map/set) | βœ… | | Transients for batch mutations | βœ… | | Atoms, Agents, Channels | βœ… | | `loop`/`recur` with true TCO | βœ… | | `try`/`catch`/`finally` | βœ… | | Namespace system (`ns`, `:require`) | βœ… | | Dependency resolution (deps.edn, Git deps) | βœ… | | Nim/C FFI interop | βœ… | | AI integration (DeepSeek, OpenAI, MiMo) | βœ… | | Cross-compilation targets (JS, WASM, shared libs) | βœ… | | Self-hosted REPL with tree-walking interpreter | βœ… | | 276+ unit tests | βœ… | | [jank-lang/clojure-test-suite](https://github.com/jank-lang/clojure-test-suite) compliance | βœ… | ## πŸ’‘ Examples ### Native math ```clojure ;; examples/math.clj (defn factorial [n] (if (= n 0) 1 (* n (factorial (- n 1))))) (println (factorial 5)) ;; => 120 ``` ### Nim interop ```clojure ;; examples/interop.clj (println (nim/math/sin 0.0)) (println (nim/strutils/toUpper "clojure")) ``` ### JSON (production-ready) ```clojure ;; examples/jsonista.clj (def data {:name "Alice" :age 30}) (println (json/write-value-as-string data)) ;; => {"name":"Alice","age":30} (println (json/read-value "{\"hello\":1}" {:keyword-keys? true})) ;; => {:hello 1} ``` See all examples in [`examples/`](examples/). ## πŸ€– AI-Powered Development ```bash export DEEPSEEK_API_KEY="sk-..." ./cljnim ai "function that sums a list using loop/recur" ``` Or use the REPL: ```clojure (ai/generate "quicksort") (ai/optimize my-code) (ai/debug failing-expr) ``` See [docs/en/03-ai-integration.md](docs/en/03-ai-integration.md) for details. ## πŸ“¦ Installation ```bash # Build from source git clone https://gitlab.com/balvatar/lisp-nim.git cd lisp-nim make build # The `cljnim` binary is now in the project root ./cljnim --help ``` ## πŸ—οΈ Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ .clj file │───▢│ Reader │───▢│ Emitter │───▢│ Nim code β”‚ β”‚ (source) β”‚ β”‚ (EDN/Clojureβ”‚ β”‚ (Clojureβ†’Nimβ”‚ β”‚ (.nim) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ syntax) β”‚ β”‚ codegen) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Nim compilerβ”‚ β”‚ (nim c) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Native binaryβ”‚ β”‚ (~3MB) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` ## πŸ“Š Benchmarks | Test | JVM Clojure | Bara Lang | Speedup | |------|-------------|-----------|---------| | factorial(20) | 2.1s | 0.003s | **700Γ—** | | fibonacci(35) | 3.8s | 0.005s | **760Γ—** | | hello world | 1.2s | 0.001s | **1200Γ—** | > JVM times include JVM startup. Bara Lang binaries start instantly. Run benchmarks: `make bench` ## 🀝 Contributing 1. Fork the repository 2. Create a feature branch 3. Run `make check` before committing 4. Submit a merge request See [docs/en/index.md](docs/en/index.md) for the development guide. ## πŸ“œ License [MIT](LICENSE) β€” Copyright (c) 2026 Bara Lang Contributors