Files
bara-lang/experiments/native-lib/README.md
T
dimgigov 79cd9c08d8 chore: rebrand Clojure/Nim → Bara Lang across codebase
- Bulk replace Clojure/Nim → Bara Lang in src/, lib/, examples/, benchmarks/,
  experiments/, books/, LICENSE, cljnim.nimble, PLAN.md, AI_AGENT.md
- Rename book chapters: 05-clojure-nim.md → 05-bara-lang.md (en + bg)
- Update all chapter index links and anchors
- Replace project-specific 'Clojure' references with 'Bara Lang' in
  experiments/, src/ai_assist.nim, src/tui_screens.nim, src/emitter.nim,
  src/reader.nim, src/types.nim, lib/cljnim_runtime*.nim
- Keep legitimate JVM Clojure/ClojureScript/Clojure CLR references intact
2026-05-11 12:23:29 +03:00

969 B

Bara Lang → Native Shared Library

Compile Bara Lang code to a C shared library (.so / .dll / .dylib).

Why?

  • Embed Bara Lang in Python/Rust/Go/C via FFI
  • Tiny binaries — no JVM overhead
  • True C ABI — call Bara Lang functions from any language

Quick Start

./build.sh

This generates:

  • build/libmath.so — shared library
  • build/math.h — C header
  • build/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

  1. cljnim compile-lib — generates Nim with exported proc name*(...)
  2. nim c --app:lib --header — compiles Nim to .so + .h
  3. C client links against the .so and calls functions

Limitations

  • Functions use CljVal (Nim ref object) — client must call Nim runtime helpers
  • NimMain() must be called before using the library