ba0b300917
- New TUI screens: Main Menu, Compile, Run, REPL, AI Generator, AI Settings, Help - AI configuration persisted in ~/.config/cljnim/config.json - Added illwill dependency for terminal UI - Updated experiments, examples, docs, and core modules
965 B
965 B
Clojure/Nim → Native Shared Library
Compile Clojure code to a C shared library (.so / .dll / .dylib).
Why?
- Embed Clojure in Python/Rust/Go/C via FFI
- Tiny binaries — no JVM overhead
- True C ABI — call Clojure functions from any language
Quick Start
./build.sh
This generates:
build/libmath.so— shared librarybuild/math.h— C headerbuild/math.nim— intermediate Nim source
Test from C
cd test_client
make
./test_client
Expected output:
square(5) = 25
add(10, 20) = 30
cube(3) = 27
factorial(5) = 120
How it works
cljnim compile-lib— generates Nim with exportedproc name*(...)nim c --app:lib --header— compiles Nim to.so+.h- C client links against the
.soand calls functions
Limitations
- Functions use
CljVal(Nim ref object) — client must call Nim runtime helpers NimMain()must be called before using the library