Bootstrap proof স্বয়ং-নির্মাণের প্রমাণ
Stage 0
TypeScript interpreter runs self/main.shobdo on its own source (about 1.5 s)
→ build/shobdoc1Stage 1
Native shobdoc1 compiles the same source (about 0.6–0.8 s)
99089f71…e2d0Stage 2
Native shobdoc2 compiles it again
99089f71…e2d0Stage 3
Fixpoint copy installed as build/shobdoc
99089f71…e2d0$ npm run bootstrap 99089f71901cd8f666088eed7a0a5079da3b376d7660dc2f62c54ae28b78e2d0 build/shobdoc1 99089f71901cd8f666088eed7a0a5079da3b376d7660dc2f62c54ae28b78e2d0 build/shobdoc2 99089f71901cd8f666088eed7a0a5079da3b376d7660dc2f62c54ae28b78e2d0 build/shobdoc3 FIXPOINT: stage1 == stage2 == stage3 (677153 bytes, 2s). Compiler: build/shobdoc $ build/shobdoc -v শব্দক ০.২ (arm64 macOS, স্বয়ং-নির্মিত)
Independence evidence কোনো বাইরের সরঞ্জাম নেই
| Check | Result |
|---|---|
Imported symbols (nm -u) | 0 The compiler calls the kernel directly through system calls. |
Linked libraries (otool -L) | Only libSystem, which the macOS loader requires; no function from it is called. |
| Code signature | Written by self/macho.shobdo. Apple's codesign -v reports it valid. |
| Rebuild with an empty environment | identical env -i build/shobdoc3 self/main.shobdo |
| Node.js needed after bootstrap? | No Node is used once, as the stage-0 seed. |
stp x29, x30, [sp, #-0x10]! mov x29, sp mov x19, x0 ; argc mov x20, x1 ; argv mov x1, #0x4000 ; globals area size mov x2, #0x3 ; PROT_READ|PROT_WRITE mov x3, #0x1002 ; MAP_PRIVATE|MAP_ANON mov x16, #0xc5 ; mmap svc #0x80 mov x28, x0 ; x28 = globals base
Every instruction was encoded by self/arm64.shobdo, written in Bangla Shobdo.
Compiler pipeline কম্পাইলারের ধাপ
lexer.shobdo · 222➜ পার্সার
parser.shobdo · 427➜ নাম-সমাধান
resolver.shobdo · 342➜ কোড জেনারেটর
codegen.shobdo · 1,567➜ arm64 + Mach-O + সই
arm64 · 147, macho · 123➜ নেটিভ প্রোগ্রাম
+ runtime.shobdo · 1,483
mmap allocator, call and method dispatch, and throw.The five planned steps পরিকল্পনার ধাপ
Code generator for a first subset Done, beyond the subset
The whole language compiles except decimal numbers: integers, strings, lists, maps, functions, default arguments, closures, lambdas, classes, inheritance, উর্ধ্ব, গোপন, চেষ্টা/ধরো/ছোড়ো, ranges, string interpolation, ??, ?. and ternary.
Runtime: number printing, strings, memory Done
self/runtime.shobdo (1,483 lines) plus hand-encoded routines. Output uses Bangla digits; --latin-digits switches to Latin digits, as in the interpreter.
Native programs vs interpreter 16 / 16 identical
tools/difftest.sh compares stdout, stderr and exit code. Separately, a natively compiled AST dumper matched the TypeScript parser on all 24 source files.
Parser and code generator written in Shobdo Done
The compiler is written directly in Shobdo. The interpreter is used only as the stage-0 seed.
Compile the compiler with itself Byte-identical
Stage 1, 2 and 3 have the same SHA-256. npm run bootstrap repeats the proof from scratch.
Differential tests দোভাষী বনাম নেটিভ
| Program | Covers | Result |
|---|---|---|
| 01_basics | arithmetic, Bangla digits, interpolation, types, hex, bitwise, ternary | identical |
| 02_control | if/else chains, while, for over ranges, lists, strings and maps, break/continue | identical |
| 03_functions | recursion, default args, closures, counters, lambdas, map/filter/reduce, mutual recursion | identical |
| 04_strings | all string methods, slicing, search, escapes, quoting inside lists | identical |
| 05_lists_maps | list and map methods, insertion order, deletes, 1,000-element list, 500-key map | identical |
| 06_classes | constructors, inheritance, উর্ধ্ব, private access error, bound methods, printing | identical |
| 07_errors | 13 error cases (12 runtime errors plus a thrown map) caught with the same Bangla messages, rethrow, return/break inside চেষ্টা | identical |
| 08_bits_sha | bitwise operators, ভাগফল, SHA-256 (matches standard test vectors) | identical |
| 09_advanced | 3-level closures, fresh loop bindings, 3-level উর্ধ্ব chain, emoji, 9,000-item output, গণিত | identical |
| 10_io | file write/read, byte write, arguments, missing-file error, stdin at end of input | identical |
| e1–e6 | uncaught runtime error, uncaught throw, undefined name at run time, exit code 7, “did you mean”, constant assignment | 6 / 6 identical |
Performance গতি
| Benchmark | Interpreter | Native | Speed-up |
|---|---|---|---|
| Recursive Fibonacci (32) | 1.31 s | 0.03 s | ≈ 40× |
| Prime sieve to 2,000,000 | 1.69 s | 0.18 s | ≈ 9× |
| 300,000 string-key map updates | 0.24 s | 0.39 s | slower (0.6×) |
Language additions in this version নতুন
- Hex literals
0xFFand bitwise operators& | ^ << >>with sensible precedence:1 + 2 << 3is 24 and6 & 3 == 2is সত্য. ভাগফল(ক, খ)for integer division,বাইট_লেখোto write bytes,শা২৫৬for SHA-256,ত্রুটি_লেখোto print to stderr.আনো "file.shobdo"imports a whole file.ফাইল_অন্তর্ভুক্ত("file")embeds a file as a string; the compiler uses it to carry its runtime inside the binary.- Interpreter: control flow no longer uses JavaScript exceptions, and string interpolations now report the correct line in errors.
Problems found and fixed যা ধরা পড়েছে
| Symptom | Cause | Fix |
|---|---|---|
Self-signed binary killed on launch (exit 137) although codesign -v accepted it | Mach-O header claimed 11 load commands; the file had 10 | Count set to 10; binary runs |
| Stage 0 refused to load the compiler | A keyword (চেষ্টা) used as a map key, and a variable that shadowed the builtin কোড() | Renamed both; added a check for clashes with builtins |
| Test run hung | পড়ো() waited for terminal input | Test harness feeds /dev/null |
| fib(90) differed | The interpreter rounds above 2^53; native was exact (2,880,067,194,370,816,120) | Recorded as a known difference; the test now uses fib(70) |
Known limits and next steps সীমাবদ্ধতা ও পরের কাজ
- Decimal (floating-point) numbers; rejected with a clear Bangla error
- Garbage collection; memory is never freed
- Platforms other than arm64 macOS
- Unicode case conversion beyond ASCII; normalization beyond Bangla
- A Bangla error on stack overflow; deep recursion crashes instead
- One scoping edge case: a closure that runs before its enclosing function declares the name it uses is an error natively, while the interpreter falls back to an outer variable
- Floating-point numbers with exact JavaScript-compatible printing
- Faster runtime maps and strings; inline map lookups
- A mark-and-sweep garbage collector
- Grow the differential test corpus toward the 500-case conformance goal
- Linux ELF backend as the second target
How to reproduce নিজে চালিয়ে দেখুন
$ cd shobdo $ npm install && npm test # interpreter unit tests (12) $ npm run bootstrap # stage 0 → 1 → 2 → 3, fails unless byte-identical $ npm run test:native # 16 differential tests $ build/shobdoc examples/hello.shobdo -o hello && ./hello
Files: shobdo/self/ (compiler and runtime), shobdo/tools/bootstrap.sh, shobdo/tools/difftest.sh, shobdo/tests/native/, shobdo/README.md. The older TypeScript Mach-O prototype in shobdo/src/native/ is superseded and no longer used.