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
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
## What is this project?
|
||||
|
||||
**Clojure/Nim** is a Clojure dialect that compiles to Nim, then to C, then to native binaries.
|
||||
**Bara Lang** is a Clojure dialect that compiles to Nim, then to C, then to native binaries.
|
||||
|
||||
Current state: **Working compiler + REPL + macro system + file/git ops + Nim interop.**
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Clojure/Nim Contributors
|
||||
Copyright (c) 2026 Bara Lang Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Clojure/Nim — Test Suite Compliance Plan
|
||||
# Bara Lang — Test Suite Compliance Plan
|
||||
|
||||
## Current Status: 233/233 (100%)
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ run_aot_bench() {
|
||||
echo ""
|
||||
|
||||
# Pre-compiled native binary
|
||||
echo " [Clojure/Nim AOT]"
|
||||
echo " [Bara Lang AOT]"
|
||||
local nim_total=0
|
||||
local nim_times=()
|
||||
for ((i=1; i<=runs; i++)); do
|
||||
@@ -71,7 +71,7 @@ run_aot_bench() {
|
||||
|
||||
if [ $nim_avg -gt 0 ]; then
|
||||
local speedup=$((jvm_avg / nim_avg))
|
||||
echo " => Clojure/Nim AOT is ${speedup}x FASTER (avg)"
|
||||
echo " => Bara Lang AOT is ${speedup}x FASTER (avg)"
|
||||
fi
|
||||
else
|
||||
echo " [JVM Clojure] — not installed"
|
||||
|
||||
@@ -5,7 +5,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
echo "=============================================="
|
||||
echo " Clojure/Nim vs JVM Clojure — Benchmarks"
|
||||
echo " Bara Lang vs JVM Clojure — Benchmarks"
|
||||
echo "=============================================="
|
||||
echo ""
|
||||
|
||||
@@ -17,8 +17,8 @@ run_bench() {
|
||||
echo "--- $name ---"
|
||||
echo ""
|
||||
|
||||
# Clojure/Nim
|
||||
echo " [Clojure/Nim]"
|
||||
# Bara Lang
|
||||
echo " [Bara Lang]"
|
||||
local nim_total=0
|
||||
local nim_times=()
|
||||
for ((i=1; i<=runs; i++)); do
|
||||
@@ -58,7 +58,7 @@ run_bench() {
|
||||
|
||||
if [ $jvm_avg -gt 0 ]; then
|
||||
local speedup=$((jvm_avg / nim_avg))
|
||||
echo " => Clojure/Nim is ${speedup}x FASTER (avg)"
|
||||
echo " => Bara Lang is ${speedup}x FASTER (avg)"
|
||||
fi
|
||||
else
|
||||
echo " [JVM Clojure] — not installed, skipping"
|
||||
@@ -66,7 +66,7 @@ run_bench() {
|
||||
echo ""
|
||||
}
|
||||
|
||||
echo "Building Clojure/Nim..."
|
||||
echo "Building Bara Lang..."
|
||||
nim c -o:"$PROJECT_DIR/cljnim" "$PROJECT_DIR/src/cljnim.nim" 2>/dev/null
|
||||
echo ""
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Clojure/Nim — The Native Clojure Book
|
||||
# Bara Lang — The Native Clojure Book
|
||||
|
||||
> A practical guide to Clojure that compiles to native binaries. No JVM required.
|
||||
|
||||
## What You Will Learn
|
||||
|
||||
This book teaches **Clojure** through the lens of **Clojure/Nim** — a real compiler that turns your Clojure code into native machine code via Nim and C.
|
||||
This book teaches **Clojure** through the lens of **Bara Lang** — a real compiler that turns your Clojure code into native machine code via Nim and C.
|
||||
|
||||
You do not need Java. You do not need Leiningen. You need Nim, a C compiler, and curiosity.
|
||||
|
||||
@@ -16,7 +16,7 @@ You do not need Java. You do not need Leiningen. You need Nim, a C compiler, and
|
||||
| [02 — Advanced](en/02-advanced.md) | Transducers, specs, parallelism, performance | Write code that scales. |
|
||||
| [03 — Tooling](en/03-tooling.md) | Project structure, deps, testing, debugging | Ship reliable software. |
|
||||
| [04 — Recipes](en/04-recipes.md) | Common patterns, state management, APIs | Copy-paste solutions that work. |
|
||||
| **[05 — Clojure/Nim](en/05-clojure-nim.md)** | **Native compilation, AI integration, JSON REPL, WASM** | **What makes this dialect unique.** |
|
||||
| **[05 — Bara Lang](en/05-bara-lang.md)** | **Native compilation, AI integration, JSON REPL, WASM** | **What makes this dialect unique.** |
|
||||
|
||||
## Quick Start
|
||||
|
||||
@@ -29,7 +29,7 @@ make build && make check
|
||||
|
||||
## Running the Examples
|
||||
|
||||
Most examples work in any Clojure REPL. Chapter 5 examples are specific to Clojure/Nim:
|
||||
Most examples work in any Clojure REPL. Chapter 5 examples are specific to Bara Lang:
|
||||
|
||||
```bash
|
||||
# Human REPL
|
||||
@@ -53,9 +53,9 @@ Most examples work in any Clojure REPL. Chapter 5 examples are specific to Cloju
|
||||
## Stats
|
||||
|
||||
- **8 chapters** (4 core + 4 translated)
|
||||
- **1 new chapter** on Clojure/Nim (native compilation, AI, cross-targets)
|
||||
- **All code tested** against Clojure/Nim v0.1.0
|
||||
- **1 new chapter** on Bara Lang (native compilation, AI, cross-targets)
|
||||
- **All code tested** against Bara Lang v0.1.0
|
||||
|
||||
---
|
||||
|
||||
*This book is maintained as part of the Clojure/Nim project.*
|
||||
*This book is maintained as part of the Bara Lang project.*
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# Clojure/Nim: Native Clojure
|
||||
# Bara Lang: Native Clojure
|
||||
|
||||
> Същият език, който обичаш. Компилиран до нативен код. Без JVM.
|
||||
|
||||
---
|
||||
|
||||
## Какво е Clojure/Nim?
|
||||
## Какво е Bara Lang?
|
||||
|
||||
**Clojure/Nim** е пълен диалект на Clojure, който се компилира до нативен машинен код през Nim компилатора. Това не е интерпретатор — това е истински компилатор с пълен pipeline за оптимизация:
|
||||
**Bara Lang** е пълен диалект на Clojure, който се компилира до нативен машинен код през Nim компилатора. Това не е интерпретатор — това е истински компилатор с пълен pipeline за оптимизация:
|
||||
|
||||
```
|
||||
Твоят .clj файл
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
### Защо native?
|
||||
|
||||
| JVM Clojure | Clojure/Nim |
|
||||
| JVM Clojure | Bara Lang |
|
||||
|-------------|-------------|
|
||||
| Нуждае се от Java runtime | Самостоятелен бинарен файл |
|
||||
| ~2-5 секунди startup | Мигновен старт |
|
||||
@@ -112,7 +112,7 @@ JSON REPL е проектиран за програмно взаимодейст
|
||||
|
||||
## AI-асистирана разработка
|
||||
|
||||
Clojure/Nim е първата Clojure имплементация, в която AI асистенцията е първокласна функция.
|
||||
Bara Lang е първата Clojure имплементация, в която AI асистенцията е първокласна функция.
|
||||
|
||||
### Обяснение на грешки
|
||||
|
||||
@@ -154,7 +154,7 @@ export DEEPSEEK_API_KEY="sk-..."
|
||||
|
||||
## `loop` / `recur`: Истинска TCO
|
||||
|
||||
За разлика от JVM Clojure (който използва `recur`, за да избегне stack overflow, но все пак работи върху stack-based VM), Clojure/Nim компилира `loop`/`recur` до native `while` цикъл:
|
||||
За разлика от JVM Clojure (който използва `recur`, за да избегне stack overflow, но все пак работи върху stack-based VM), Bara Lang компилира `loop`/`recur` до native `while` цикъл:
|
||||
|
||||
```clojure
|
||||
(defn factorial [n]
|
||||
@@ -170,7 +170,7 @@ export DEEPSEEK_API_KEY="sk-..."
|
||||
|
||||
## Cross-Compilation Target-и
|
||||
|
||||
Clojure/Nim може да таргетира множество платформи от един и същи изходен код:
|
||||
Bara Lang може да таргетира множество платформи от един и същи изходен код:
|
||||
|
||||
### Нативен бинарен файл (по подразбиране)
|
||||
```bash
|
||||
@@ -201,7 +201,7 @@ nim c -d:release --cpu:wasm32 --os:linux program.nim
|
||||
|
||||
## Persistent Структури от Данни
|
||||
|
||||
Clojure/Nim имплементира истински **Hash Array Mapped Trie (HAMT)** вектори и карти:
|
||||
Bara Lang имплементира истински **Hash Array Mapped Trie (HAMT)** вектори и карти:
|
||||
|
||||
```clojure
|
||||
(def v (vector 1 2 3))
|
||||
@@ -263,9 +263,9 @@ Threading макроси, `when-let`, `cond`, `doto`, `some->` — всички
|
||||
|
||||
---
|
||||
|
||||
## Кога да използваш Clojure/Nim
|
||||
## Кога да използваш Bara Lang
|
||||
|
||||
| Use Case | Clojure/JVM | Clojure/Nim |
|
||||
| Use Case | Clojure/JVM | Bara Lang |
|
||||
|----------|-------------|-------------|
|
||||
| Големи уеб услуги | ✅ | ⚠️ (ранен етап) |
|
||||
| CLI инструменти | ⚠️ (бавен старт) | ✅ (мигновен) |
|
||||
@@ -286,4 +286,4 @@ Threading макроси, `when-let`, `cond`, `doto`, `some->` — всички
|
||||
|
||||
---
|
||||
|
||||
*Clojure/Nim е доказателство, че не ти трябва виртуална машина, за да пишеш елегантен, функционален, immutable код. Трябва ти само добър компилатор.*
|
||||
*Bara Lang е доказателство, че не ти трябва виртуална машина, за да пишеш елегантен, функционален, immutable код. Трябва ти само добър компилатор.*
|
||||
@@ -8,11 +8,11 @@
|
||||
- **Анонимни функции** - [5.2](bg/01-fundamentals.md#52-анонимни-функции)
|
||||
- **Аритности** - [5.1.2](bg/01-fundamentals.md#512-множество-арности)
|
||||
- **Асинхронно програмиране** - [16](bg/01-fundamentals.md#16-coreasync), [4](bg/04-recipes.md#4-async-рецепти)
|
||||
- **Атом (Atom)** - [11.1](bg/01-fundamentals.md#11-атоми-atoms), [5](bg/05-clojure-nim.md#конкурентност)
|
||||
- **AI интеграция** - [5](bg/05-clojure-nim.md#ai-асистирана-разработка)
|
||||
- **AI агенти** - [5](bg/05-clojure-nim.md#json-repl-за-ai-агенти)
|
||||
- **Clojure/Nim** - [5](bg/05-clojure-nim.md) — Нативна компилация, AI, JSON REPL
|
||||
- **Cross-compilation** - [5](bg/05-clojure-nim.md#cross-compilation-target-и) — JS, WASM, shared libraries
|
||||
- **Атом (Atom)** - [11.1](bg/01-fundamentals.md#11-атоми-atoms), [5](bg/05-bara-lang.md#конкурентност)
|
||||
- **AI интеграция** - [5](bg/05-bara-lang.md#ai-асистирана-разработка)
|
||||
- **AI агенти** - [5](bg/05-bara-lang.md#json-repl-за-ai-агенти)
|
||||
- **Bara Lang** - [5](bg/05-bara-lang.md) — Нативна компилация, AI, JSON REPL
|
||||
- **Cross-compilation** - [5](bg/05-bara-lang.md#cross-compilation-target-и) — JS, WASM, shared libraries
|
||||
|
||||
## Б
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# Clojure/Nim: Native Clojure
|
||||
# Bara Lang: Native Clojure
|
||||
|
||||
> The same language you love. Compiled to native binaries. No JVM required.
|
||||
|
||||
---
|
||||
|
||||
## What is Clojure/Nim?
|
||||
## What is Bara Lang?
|
||||
|
||||
**Clojure/Nim** is a complete Clojure dialect that compiles to native machine code via the Nim compiler. It is not an interpreter — it is a real compiler with a full optimization pipeline:
|
||||
**Bara Lang** is a complete Clojure dialect that compiles to native machine code via the Nim compiler. It is not an interpreter — it is a real compiler with a full optimization pipeline:
|
||||
|
||||
```
|
||||
Your .clj file
|
||||
@@ -26,7 +26,7 @@ The result is a single executable file, often under **1 MB**, that starts instan
|
||||
|
||||
### Why Native?
|
||||
|
||||
| JVM Clojure | Clojure/Nim |
|
||||
| JVM Clojure | Bara Lang |
|
||||
|-------------|-------------|
|
||||
| Needs Java runtime installed | Self-contained binary |
|
||||
| ~2-5 second startup time | Instant startup |
|
||||
@@ -112,7 +112,7 @@ The JSON REPL is designed for programmatic interaction. Every operation has stru
|
||||
|
||||
## AI-Powered Development
|
||||
|
||||
Clojure/Nim is the first Clojure implementation built with AI assistance as a first-class feature.
|
||||
Bara Lang is the first Clojure implementation built with AI assistance as a first-class feature.
|
||||
|
||||
### Error Explanation
|
||||
|
||||
@@ -154,7 +154,7 @@ export DEEPSEEK_API_KEY="sk-..."
|
||||
|
||||
## `loop` / `recur`: Real TCO
|
||||
|
||||
Unlike JVM Clojure (which uses `recur` to avoid stack overflow but still runs on a stack-based VM), Clojure/Nim compiles `loop`/`recur` to a native `while` loop:
|
||||
Unlike JVM Clojure (which uses `recur` to avoid stack overflow but still runs on a stack-based VM), Bara Lang compiles `loop`/`recur` to a native `while` loop:
|
||||
|
||||
```clojure
|
||||
(defn factorial [n]
|
||||
@@ -170,7 +170,7 @@ This generates efficient C code with no function calls. It is **genuinely O(1) s
|
||||
|
||||
## Cross-Compilation Targets
|
||||
|
||||
Clojure/Nim can target multiple platforms from the same source:
|
||||
Bara Lang can target multiple platforms from the same source:
|
||||
|
||||
### Native Binary (default)
|
||||
```bash
|
||||
@@ -202,7 +202,7 @@ This is something JVM Clojure simply cannot do.
|
||||
|
||||
## Persistent Data Structures
|
||||
|
||||
Clojure/Nim implements real **Hash Array Mapped Trie (HAMT)** vectors and maps:
|
||||
Bara Lang implements real **Hash Array Mapped Trie (HAMT)** vectors and maps:
|
||||
|
||||
```clojure
|
||||
(def v (vector 1 2 3))
|
||||
@@ -264,9 +264,9 @@ Threading macros, `when-let`, `cond`, `doto`, `some->` — all implemented as re
|
||||
|
||||
---
|
||||
|
||||
## When to Use Clojure/Nim
|
||||
## When to Use Bara Lang
|
||||
|
||||
| Use Case | Clojure/JVM | Clojure/Nim |
|
||||
| Use Case | Clojure/JVM | Bara Lang |
|
||||
|----------|-------------|-------------|
|
||||
| Large web services | ✅ | ⚠️ (early stage) |
|
||||
| CLI tools | ⚠️ (slow startup) | ✅ (instant) |
|
||||
@@ -287,4 +287,4 @@ Threading macros, `when-let`, `cond`, `doto`, `some->` — all implemented as re
|
||||
|
||||
---
|
||||
|
||||
*Clojure/Nim is proof that you do not need a virtual machine to write elegant, functional, immutable code. You just need a good compiler.*
|
||||
*Bara Lang is proof that you do not need a virtual machine to write elegant, functional, immutable code. You just need a good compiler.*
|
||||
@@ -24,10 +24,10 @@
|
||||
|
||||
- **Caching** - [1.5](en/01-fundamentals.md#15-memoization), [8.6](en/02-advanced.md#86-preload-and-cache), [8.2](en/04-recipes.md#82-caching-with-ttl)
|
||||
- **Case** - [6.1.5](en/01-fundamentals.md#615-case)
|
||||
- **Channels** - [16.1](en/01-fundamentals.md#161-channels), [5](en/05-clojure-nim.md#concurrency)
|
||||
- **Clojure/Nim** - [5](en/05-clojure-nim.md) — Native compilation, AI integration, JSON REPL
|
||||
- **Compilation (native)** - [5](en/05-clojure-nim.md#what-is-clojure-nim)
|
||||
- **Cross-compilation** - [5](en/05-clojure-nim.md#cross-compilation-targets) — JS, WASM, shared libraries
|
||||
- **Channels** - [16.1](en/01-fundamentals.md#161-channels), [5](en/05-bara-lang.md#concurrency)
|
||||
- **Bara Lang** - [5](en/05-bara-lang.md) — Native compilation, AI integration, JSON REPL
|
||||
- **Compilation (native)** - [5](en/05-bara-lang.md#what-is-bara-lang)
|
||||
- **Cross-compilation** - [5](en/05-bara-lang.md#cross-compilation-targets) — JS, WASM, shared libraries
|
||||
- **Characters** - [4.3](en/01-fundamentals.md#43-characters)
|
||||
- **Chunked sequences** - [2.2](en/02-advanced.md#22-chunked-sequences)
|
||||
- **Circuit breaker** - [3.4](en/04-recipes.md#34-circuit-breaker)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Package
|
||||
version = "0.1.0"
|
||||
author = "Clojure/Nim Team"
|
||||
author = "Bara Lang Team"
|
||||
description = "Clojure dialect compiling to Nim"
|
||||
license = "MIT"
|
||||
srcDir = "src"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
; AI-Native Tooling Demo
|
||||
; File and Git operations from Clojure
|
||||
; File and Git operations from Bara Lang
|
||||
|
||||
(println "=== File Operations ===")
|
||||
|
||||
; Write a file
|
||||
(file/write "/tmp/ai_demo.txt" "Hello from Clojure/Nim AI!")
|
||||
(file/write "/tmp/ai_demo.txt" "Hello from Bara Lang AI!")
|
||||
|
||||
; Read it back
|
||||
(println (file/read "/tmp/ai_demo.txt"))
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
; C FFI — Достъп до C функции директно от Clojure
|
||||
; C FFI — Достъп до C функции директно от Bara Lang
|
||||
; (c-fn sin "math.h" :double [:double])
|
||||
; Това генерира Nim proc с {.importc.} pragma
|
||||
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
; First Clojure/Nim program
|
||||
; First Bara Lang program
|
||||
(println "Hello, Nim world!")
|
||||
(println (+ 1 2 3))
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
; jsonista.clj — Production JSON library example for Clojure/Nim
|
||||
; jsonista.clj — Production JSON library example for Bara Lang
|
||||
; Modeled after https://github.com/metosin/jsonista
|
||||
; Replaces Java/Jackson dependencies with native Nim JSON performance
|
||||
;
|
||||
; This example demonstrates:
|
||||
; - Fast JSON encoding/decoding without JVM overhead
|
||||
; - Keyword keys support (Clojure idiomatic)
|
||||
; - Keyword keys support (Bara Lang idiomatic)
|
||||
; - File I/O
|
||||
; - Pretty printing
|
||||
; - Complex nested data structures
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# jsonista.clj — Production JSON библиотека за Clojure/Nim
|
||||
# jsonista.clj — Production JSON библиотека за Bara Lang
|
||||
|
||||
> Моделирана след [metosin/jsonista](https://github.com/metosin/jsonista), но с **нула Java зависимости**.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
Този пример демонстрира пълноценна JSON библиотека с API идентично на jsonista, но:
|
||||
|
||||
| | JVM jsonista | Clojure/Nim jsonista |
|
||||
| | JVM jsonista | Bara Lang jsonista |
|
||||
|---|---|---|
|
||||
| JVM зависимост | ✅ Required (JVM + Jackson) | ❌ Няма |
|
||||
| Jackson/databind | ✅ Required | ❌ Няма |
|
||||
@@ -21,8 +21,8 @@
|
||||
; Основни функции
|
||||
(json/write-value-as-string data) ; -> JSON string
|
||||
(json/write-value-as-string data opts) ; -> JSON string с опции
|
||||
(json/read-value json-string) ; -> Clojure data
|
||||
(json/read-value json-string opts) ; -> Clojure data с опции
|
||||
(json/read-value json-string) ; -> Bara Lang data
|
||||
(json/read-value json-string opts) ; -> Bara Lang data с опции
|
||||
(json/write-value-to-file path data) ; -> записва във файл
|
||||
(json/write-value-to-file path data opts) ; -> записва във файл
|
||||
(json/read-value-from-file path) ; -> чете от файл
|
||||
@@ -86,7 +86,7 @@
|
||||
```
|
||||
Clojure code
|
||||
↓
|
||||
Clojure/Nim Compiler
|
||||
Bara Lang Compiler
|
||||
↓
|
||||
Nim код + cljnim_runtime (std/json)
|
||||
↓
|
||||
@@ -127,7 +127,7 @@ make check
|
||||
|
||||
## Сравнение с оригиналния jsonista
|
||||
|
||||
| Feature | JVM jsonista | Clojure/Nim |
|
||||
| Feature | JVM jsonista | Bara Lang |
|
||||
|---|---|---|
|
||||
| `write-value-as-string` | ✅ | ✅ |
|
||||
| `read-value` | ✅ | ✅ |
|
||||
@@ -140,4 +140,4 @@ make check
|
||||
|
||||
---
|
||||
|
||||
**Извод:** С Clojure/Nim получаваш същото production-ready JSON API, но без целия Java overhead — native бинарен файл, мигновен старт, и достъп до цялата Nim/C ecosystem.
|
||||
**Извод:** С Bara Lang получаваш същото production-ready JSON API, но без целия Java overhead — native бинарен файл, мигновен старт, и достъп до цялата Nim/C ecosystem.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Clojure/Nim Experiments
|
||||
# Bara Lang Experiments
|
||||
|
||||
Unconventional compilation targets that JVM Clojure cannot do.
|
||||
|
||||
@@ -10,7 +10,7 @@ Unconventional compilation targets that JVM Clojure cannot do.
|
||||
| `native-lib/` | ✅ Working | Clojure → Nim → C shared library (.so) |
|
||||
| `wasm-target/` | 🏗️ Skeleton | Clojure → Nim → WASM via Emscripten |
|
||||
|
||||
## web-target — Clojure in the Browser
|
||||
## web-target — Bara Lang in the Browser
|
||||
|
||||
```bash
|
||||
cd web-target
|
||||
@@ -19,9 +19,9 @@ node -e "require('./build/math.js'); console.log(jsSquare(7))"
|
||||
# → 49
|
||||
```
|
||||
|
||||
**Unique:** No JVM, no JavaScript source code — pure Clojure compiled to JS.
|
||||
**Unique:** No JVM, no JavaScript source code — pure Bara Lang compiled to JS.
|
||||
|
||||
## native-lib — Clojure as a C Library
|
||||
## native-lib — Bara Lang as a C Library
|
||||
|
||||
```bash
|
||||
cd native-lib
|
||||
@@ -31,9 +31,9 @@ cd test_client && make && LD_LIBRARY_PATH=../build ./test_client
|
||||
# → c_factorial(5) = 120
|
||||
```
|
||||
|
||||
**Unique:** Call Clojure functions from Python, Rust, Go, C via FFI.
|
||||
**Unique:** Call Bara Lang functions from Python, Rust, Go, C via FFI.
|
||||
|
||||
## wasm-target — Clojure at Native Speed in Browser
|
||||
## wasm-target — Bara Lang at Native Speed in Browser
|
||||
|
||||
```bash
|
||||
cd wasm-target
|
||||
@@ -42,14 +42,14 @@ cd wasm-target
|
||||
# Open www/index.html in browser
|
||||
```
|
||||
|
||||
**Unique:** Clojure running as WebAssembly — faster than ClojureScript, smaller than JVM.
|
||||
**Unique:** Bara Lang running as WebAssembly — faster than ClojureScript, smaller than JVM.
|
||||
|
||||
## Architecture
|
||||
|
||||
All experiments share the same pipeline:
|
||||
|
||||
```
|
||||
Clojure Source (.clj)
|
||||
Bara Lang Source (.clj)
|
||||
↓
|
||||
cljnim compile-lib
|
||||
↓
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# Clojure/Nim → Native Shared Library
|
||||
# Bara Lang → Native Shared Library
|
||||
|
||||
Compile Clojure code to a C shared library (`.so` / `.dll` / `.dylib`).
|
||||
Compile Bara Lang code to a C shared library (`.so` / `.dll` / `.dylib`).
|
||||
|
||||
## Why?
|
||||
|
||||
- **Embed Clojure in Python/Rust/Go/C** via FFI
|
||||
- **Embed Bara Lang in Python/Rust/Go/C** via FFI
|
||||
- **Tiny binaries** — no JVM overhead
|
||||
- **True C ABI** — call Clojure functions from any language
|
||||
- **True C ABI** — call Bara Lang functions from any language
|
||||
|
||||
## Quick Start
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Generated by Clojure/Nim
|
||||
# Generated by Bara Lang
|
||||
import cljnim_runtime
|
||||
|
||||
proc square*(x: CljVal): CljVal =
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# C-friendly wrappers around Clojure-generated code
|
||||
# C-friendly wrappers around Bara Lang-generated code
|
||||
# Exports plain C types (int, char*) instead of CljVal
|
||||
|
||||
import cljnim_runtime
|
||||
|
||||
# Import the generated Clojure functions
|
||||
# Import the generated Bara Lang functions
|
||||
include build/math
|
||||
|
||||
proc c_square*(x: cint): cint {.exportc, dynlib.} =
|
||||
|
||||
@@ -12,13 +12,13 @@ extern void NimMain(void);
|
||||
int main(void) {
|
||||
NimMain();
|
||||
|
||||
printf("=== Clojure/Nim Native Library Test ===\n\n");
|
||||
printf("=== Bara Lang Native Library Test ===\n\n");
|
||||
|
||||
printf("c_square(7) = %d\n", c_square(7));
|
||||
printf("c_add(10, 20) = %d\n", c_add(10, 20));
|
||||
printf("c_factorial(5) = %d\n", c_factorial(5));
|
||||
printf("c_greet(\"World\") = %s\n", c_greet("World"));
|
||||
|
||||
printf("\nAll tests passed! Clojure in a .so file.\n");
|
||||
printf("\nAll tests passed! Bara Lang in a .so file.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Clojure/Nim → WASM (via Emscripten)
|
||||
# Bara Lang → WASM (via Emscripten)
|
||||
|
||||
Compile Clojure code to WebAssembly using Nim's Emscripten backend.
|
||||
Compile Bara Lang code to WebAssembly using Nim's Emscripten backend.
|
||||
|
||||
## Why?
|
||||
|
||||
@@ -31,7 +31,7 @@ Then open `www/index.html` in a browser.
|
||||
1. `cljnim compile-lib` — generates Nim with exported functions
|
||||
2. `nim c -d:emscripten` — compiles Nim to WASM + JS glue
|
||||
3. Browser loads `math.js` (glue) + `math.wasm` (WASM module)
|
||||
4. JS calls `_wasmSquare(7)` → WASM executes native Clojure code
|
||||
4. JS calls `_wasmSquare(7)` → WASM executes native Bara Lang code
|
||||
|
||||
## Future
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# WASM-friendly wrappers around Clojure-generated code
|
||||
# WASM-friendly wrappers around Bara Lang-generated code
|
||||
# Uses Emscripten FFI: cint → JS number, cstring → JS string
|
||||
|
||||
import cljnim_runtime
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Clojure/Nim → WASM Demo</title>
|
||||
<title>Bara Lang → WASM Demo</title>
|
||||
<style>
|
||||
body { font-family: monospace; max-width: 800px; margin: 40px auto; padding: 20px; background: #1a1a2e; color: #eee; }
|
||||
h1 { color: #e94560; }
|
||||
@@ -10,8 +10,8 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>⚡ Clojure/Nim → WASM (Emscripten)</h1>
|
||||
<p>Clojure compiled to Nim, then to WebAssembly via Emscripten.</p>
|
||||
<h1>⚡ Bara Lang → WASM (Emscripten)</h1>
|
||||
<p>Bara Lang compiled to Nim, then to WebAssembly via Emscripten.</p>
|
||||
|
||||
<div class="result">
|
||||
<div id="output">Loading WASM module...</div>
|
||||
@@ -25,7 +25,7 @@
|
||||
<b>wasmSquare(7)</b> = ${Module._wasmSquare(7)}<br>
|
||||
<b>wasmFactorial(5)</b> = ${Module._wasmFactorial(5)}<br>
|
||||
<br>
|
||||
<i>Clojure running at native speed in your browser!</i>
|
||||
<i>Bara Lang running at native speed in your browser!</i>
|
||||
`;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# Clojure/Nim → JavaScript
|
||||
# Bara Lang → JavaScript
|
||||
|
||||
Compile Clojure code to JavaScript via Nim's JS backend.
|
||||
Compile Bara Lang code to JavaScript via Nim's JS backend.
|
||||
|
||||
## Why?
|
||||
|
||||
- **No JVM** — Clojure in the browser without 50MB runtime
|
||||
- **No JavaScript** — write Clojure, get JS
|
||||
- **No JVM** — Bara Lang in the browser without 50MB runtime
|
||||
- **No JavaScript** — write Bara Lang, get JS
|
||||
- **Smaller than ClojureScript** — no Google Closure compiler needed
|
||||
|
||||
## Quick Start
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Generated by Clojure/Nim
|
||||
# Generated by Bara Lang
|
||||
import cljnim_runtime_js
|
||||
|
||||
proc square*(x: CljVal): CljVal =
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# JS-friendly wrappers around Clojure-generated code
|
||||
# JS-friendly wrappers around Bara Lang-generated code
|
||||
# These expose plain JS types (number, string) instead of CljVal
|
||||
|
||||
import cljnim_runtime_js
|
||||
|
||||
# Import the generated Clojure functions
|
||||
# Import the generated Bara Lang functions
|
||||
include build/math
|
||||
|
||||
proc jsSquare*(x: int): int {.exportc.} =
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Clojure/Nim → JS Demo</title>
|
||||
<title>Bara Lang → JS Demo</title>
|
||||
<style>
|
||||
body { font-family: monospace; max-width: 800px; margin: 40px auto; padding: 20px; background: #1a1a2e; color: #eee; }
|
||||
h1 { color: #e94560; }
|
||||
@@ -14,8 +14,8 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>🔥 Clojure/Nim → JavaScript</h1>
|
||||
<p>Clojure code compiled to Nim, then to JavaScript. Running in your browser.</p>
|
||||
<h1>🔥 Bara Lang → JavaScript</h1>
|
||||
<p>Bara Lang code compiled to Nim, then to JavaScript. Running in your browser.</p>
|
||||
|
||||
<div class="result">
|
||||
<div class="label">square(7)</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Simplified core.async for Clojure/Nim
|
||||
# Simplified core.async for Bara Lang
|
||||
# Provides channels with put!/take!/close! and go blocks
|
||||
import deques, locks
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Persistent Map — Hash Array Mapped Trie (HAMT)
|
||||
# Clojure-style 32-way branching with structural sharing
|
||||
# Bara Lang-style 32-way branching with structural sharing
|
||||
# Takes pre-computed hashes and equality functions from callers
|
||||
|
||||
import hashes
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Persistent Vector — Hash Array Mapped Trie
|
||||
# Clojure-style 32-way branching with structural sharing
|
||||
# Bara Lang-style 32-way branching with structural sharing
|
||||
|
||||
type
|
||||
PVecNode*[T] = ref object
|
||||
|
||||
@@ -481,7 +481,7 @@ proc cljNumEq*(args: seq[CljVal]): CljVal =
|
||||
cljBool(true)
|
||||
|
||||
proc cljEqual*(a, b: CljVal): bool =
|
||||
## Clojure = equality: structural equality for all types, numeric equality for numbers
|
||||
## Bara Lang = equality: structural equality for all types, numeric equality for numbers
|
||||
if a.isNil and b.isNil: return true
|
||||
if a.isNil or b.isNil: return false
|
||||
if a.kind != b.kind:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Minimal Clojure runtime for JavaScript target
|
||||
# Minimal Bara Lang runtime for JavaScript target
|
||||
# No C FFI, no threads, no processes — just plain Nim/JS
|
||||
|
||||
type
|
||||
|
||||
+10
-10
@@ -1,4 +1,4 @@
|
||||
# AI Assistance for Clojure/Nim Compiler
|
||||
# AI Assistance for Bara Lang Compiler
|
||||
# Supports DeepSeek API and OpenAI-compatible APIs (Xiaomi MiMo, etc.)
|
||||
# API keys are read from environment variables — never hardcoded.
|
||||
|
||||
@@ -95,7 +95,7 @@ proc getCachedError*(errorMsg, fileName: string): string =
|
||||
|
||||
proc buildErrorPrompt*(errorMsg, sourceCode, fileName: string): string =
|
||||
## Build a prompt for the AI to analyze a compiler error
|
||||
result = """You are an expert Clojure/Nim compiler assistant. The user got a compilation error.
|
||||
result = """You are an expert Bara Lang compiler assistant. The user got a compilation error.
|
||||
|
||||
**File:** """ & fileName & """
|
||||
|
||||
@@ -110,21 +110,21 @@ proc buildErrorPrompt*(errorMsg, sourceCode, fileName: string): string =
|
||||
```
|
||||
|
||||
Please explain the error in simple terms and suggest a fix. Keep your response under 200 words.
|
||||
If the error is in Clojure code, show the corrected Clojure snippet.
|
||||
If the error is in Bara Lang code, show the corrected Bara Lang snippet.
|
||||
Respond in the same language as the user's source code comments (Bulgarian or English).
|
||||
"""
|
||||
|
||||
proc buildGenerationPrompt*(description: string): string =
|
||||
## Build a prompt for AI code generation
|
||||
result = """You are an expert Clojure programmer. Generate a Clojure function based on this description:
|
||||
result = """You are an expert Bara Lang programmer. Generate a Bara Lang function based on this description:
|
||||
|
||||
""" & description & """
|
||||
|
||||
Requirements:
|
||||
- Use idiomatic Clojure
|
||||
- Use idiomatic Bara Lang
|
||||
- Include docstring
|
||||
- Use loop/recur instead of recursion if possible
|
||||
- Return ONLY the Clojure code, no explanations
|
||||
- Return ONLY the Bara Lang code, no explanations
|
||||
"""
|
||||
|
||||
proc buildOptimizationPrompt*(code: string): string =
|
||||
@@ -142,7 +142,7 @@ Consider:
|
||||
- Transients for batch operations
|
||||
- Parallelization opportunities (pmap, reducers)
|
||||
|
||||
Keep response under 200 words. Return ONLY Clojure code suggestions, no explanations.
|
||||
Keep response under 200 words. Return ONLY Bara Lang code suggestions, no explanations.
|
||||
"""
|
||||
|
||||
proc buildDebugPrompt*(code: string, evalResult: string): string =
|
||||
@@ -216,19 +216,19 @@ proc explainError*(errorMsg, sourceCode, fileName: string): AiResponse =
|
||||
return res
|
||||
|
||||
proc generateCode*(description: string): AiResponse =
|
||||
## High-level helper: generate Clojure code from description
|
||||
## High-level helper: generate Bara Lang code from description
|
||||
let config = detectConfig()
|
||||
let prompt = buildGenerationPrompt(description)
|
||||
return callAiApi(config, prompt)
|
||||
|
||||
proc optimizeCode*(code: string): AiResponse =
|
||||
## High-level helper: suggest optimizations for Clojure code
|
||||
## High-level helper: suggest optimizations for Bara Lang code
|
||||
let config = detectConfig()
|
||||
let prompt = buildOptimizationPrompt(code)
|
||||
return callAiApi(config, prompt)
|
||||
|
||||
proc debugCode*(code: string, evalResult: string): AiResponse =
|
||||
## High-level helper: debug a Clojure expression and its result
|
||||
## High-level helper: debug a Bara Lang expression and its result
|
||||
let config = detectConfig()
|
||||
let prompt = buildDebugPrompt(code, evalResult)
|
||||
return callAiApi(config, prompt)
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
# Clojure/Nim — AI-First Clojure Compiler
|
||||
# Bara Lang — AI-First Compiler
|
||||
import os, osproc, strutils, times
|
||||
import reader, emitter, types, repl, macros, deps, ai_assist, tui
|
||||
|
||||
@@ -213,7 +213,7 @@ proc main() =
|
||||
let args = commandLineParams()
|
||||
|
||||
if args.len == 0:
|
||||
echo "Clojure/Nim — AI-First Clojure Compiler"
|
||||
echo "Bara Lang — AI-First Compiler"
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
echo " cljnim compile <file.clj> [output.nim] Compile to Nim source"
|
||||
@@ -222,7 +222,7 @@ proc main() =
|
||||
echo " cljnim repl [--json] Start REPL (human or AI mode)"
|
||||
echo " cljnim deps Resolve dependencies from deps.edn"
|
||||
echo " cljnim -e '<code>' Evaluate expression"
|
||||
echo " cljnim ai '<description>' Generate Clojure code with AI"
|
||||
echo " cljnim ai '<description>' Generate Bara Lang code with AI"
|
||||
echo " cljnim tui Start interactive TUI"
|
||||
echo ""
|
||||
echo "REPL Commands:"
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
# Clojure → Nim Emitter
|
||||
# Bara Lang → Nim Emitter
|
||||
import strutils, sets, algorithm
|
||||
import types
|
||||
import macros
|
||||
@@ -2059,7 +2059,7 @@ proc emitProgramInternal(forms: seq[CljVal]): string =
|
||||
pushScope()
|
||||
requiredImports = initHashSet[string]()
|
||||
var headerLines: seq[string] = @[
|
||||
"# Generated by Clojure/Nim",
|
||||
"# Generated by Bara Lang",
|
||||
"import cljnim_runtime",
|
||||
]
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# Clojure Reader (EDN subset)
|
||||
# Bara Lang Reader (EDN subset)
|
||||
import strutils
|
||||
import types
|
||||
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
# AI-First REPL for Clojure/Nim
|
||||
# AI-First REPL for Bara Lang
|
||||
import os, osproc, strutils, json, times, net
|
||||
import reader, emitter, types, macros, eval, ai_assist
|
||||
|
||||
@@ -82,7 +82,7 @@ proc buildProgram(state: ReplState, form: CljVal, isDef: bool): string =
|
||||
allForms.add(form)
|
||||
|
||||
var header = @[
|
||||
"# Generated by Clojure/Nim REPL",
|
||||
"# Generated by Bara Lang REPL",
|
||||
"import cljnim_runtime",
|
||||
"",
|
||||
]
|
||||
@@ -252,7 +252,7 @@ proc evalForm*(state: var ReplState, formStr: string): JsonNode =
|
||||
}
|
||||
|
||||
proc runHumanRepl*(state: var ReplState) =
|
||||
echo "Clojure/Nim REPL"
|
||||
echo "Bara Lang REPL"
|
||||
echo "Type :quit to exit, :help for commands"
|
||||
echo ""
|
||||
|
||||
@@ -275,7 +275,7 @@ proc runHumanRepl*(state: var ReplState) =
|
||||
echo ":defs List defined vars"
|
||||
echo ":clear Clear all definitions"
|
||||
echo ":ns Show current namespace"
|
||||
echo ":ai <desc> Ask AI to generate Clojure code"
|
||||
echo ":ai <desc> Ask AI to generate Bara Lang code"
|
||||
echo ":optimize <code> Ask AI to suggest optimizations"
|
||||
echo ":debug <expr> Ask AI to debug an expression"
|
||||
of ":defs":
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
# Clojure/Nim TUI — Terminal User Interface
|
||||
# Bara Lang TUI — Terminal User Interface
|
||||
# Fullscreen menu-driven interface for cljnim
|
||||
|
||||
import std/os
|
||||
@@ -72,7 +72,7 @@ proc runTui*() =
|
||||
illwillDeinit()
|
||||
showCursor()
|
||||
echo ""
|
||||
echo "=== Starting Clojure/Nim REPL ==="
|
||||
echo "=== Starting Bara Lang REPL ==="
|
||||
echo "Type :quit to return to TUI"
|
||||
echo ""
|
||||
var replState = initReplState(rmHuman)
|
||||
|
||||
+3
-3
@@ -127,7 +127,7 @@ proc drawMainMenu*(tb: var TerminalBuffer, state: var ScreenState) =
|
||||
let h = terminalHeight()
|
||||
|
||||
# Header
|
||||
let title = "Clojure/Nim TUI"
|
||||
let title = "Bara Lang TUI"
|
||||
tb.write(centerX(title, w), 1, fgCyan, title)
|
||||
tb.drawHorizLine(0, w - 1, 2, doubleStyle = true)
|
||||
|
||||
@@ -436,7 +436,7 @@ proc drawRun*(tb: var TerminalBuffer, state: var ScreenState) =
|
||||
let w = terminalWidth()
|
||||
let h = terminalHeight()
|
||||
|
||||
tb.write(centerX("Run Clojure File", w), 1, fgCyan, "Run Clojure File")
|
||||
tb.write(centerX("Run Bara Lang File", w), 1, fgCyan, "Run Bara Lang File")
|
||||
tb.drawHorizLine(0, w - 1, 2, doubleStyle = true)
|
||||
|
||||
let valX = 12
|
||||
@@ -646,7 +646,7 @@ proc drawHelp*(tb: var TerminalBuffer, state: var ScreenState) =
|
||||
tb.drawHorizLine(0, w - 1, 2, doubleStyle = true)
|
||||
|
||||
let helpText = @[
|
||||
"Clojure/Nim TUI v0.1.0",
|
||||
"Bara Lang TUI v0.1.0",
|
||||
"",
|
||||
"Navigation:",
|
||||
" Arrow Keys / Tab Navigate menus and fields",
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# Clojure Value Types (Compiler internal representation)
|
||||
# Bara Lang Value Types (Compiler internal representation)
|
||||
import sequtils, strutils
|
||||
|
||||
type
|
||||
|
||||
Reference in New Issue
Block a user