COMPILE
THE FUTURE
FROM THE PAST.
BidhuScript is a statically-typed language with a native Go compiler. It lowers source through a three-address-code IR to LLVM IR, producing real native executables for Linux and Windows. Forge. Blueprint. Spawn. Snap. Skip.
bidhu@playground:~/src$ ./bidhu run examples/functions.bidhu ▸ lexing... ▸ parsing... ▸ sema ok ▸ ir lowered ▸ llvm ir emitted ▸ clang link ok ▸ exec ▸ ▸ ▸ ==================== BidhuScript functions ==================== 9 120 snap and skip: 0 1 2 4 5 6 done bidhu@playground:~/src$ ▊
FEATURES
First-class functions
forge add(int a, int b) ~> int defines a typed routine. ~> declares the return type. Snap and skip replace break and continue inside loops.
Stack-allocated objects
blueprint Point { int x; int y; } declares a class. spawn Point(3, 4) constructs one. Methods use my to refer to the receiver, like a hidden this pointer.
Native code, no VM
Source lowers through a three-address IR to LLVM IR, then to a real ELF or .exe via clang / llc+mingw. The legacy C backend is kept for side-by-side study.
Loop with an inverse flag
while(init; cond; incr; false) — the 4th clause toggles do-while semantics. A subtle nod to C's for, repurposed for explicit control.
Fixed-size, second-class
let int[4] nums = [10,20,30,40]; — declared size, stack-allocated. span(nums) folds to a compile-time constant. No array params or returns (yet).
Static type checking
Forge signatures are unique. Arity and types are checked at every call. ~> functions must return on every path. snap and skip are only legal inside a loop.
SYNTAX
let int x = 5;
let float y = 10.9;
let float result = x + y * 2;
let bool flag = true;
let string s = "Hello, " + "World";
if (result > 20.0) {
print("big");
} else {
print("small");
}
while(let int i = 0; i < 5; i = i + 1; false) {
print(i);
}forge factorial(int n) ~> int {
if (n <= 1) { return 1; }
return n * factorial(n - 1);
}
forge banner(string title) {
print("====================");
print(title);
}
banner("BidhuScript");
print(factorial(5));while(let int i = 0; i < 10; i = i + 1; false) {
if (i == 3) { skip; }
if (i == 7) { snap; }
print(i);
}
let int j = 0;
while(; j < 2; j = j + 1; true) {
print(j);
}blueprint Point {
int x;
int y;
forge sum() ~> int {
return my.x + my.y;
}
forge scale(int k) {
my.x = my.x * k;
my.y = my.y * k;
}
}
let Point p = spawn Point(3, 4);
print(p.sum());
p.scale(10);
print(p.sum());PIPELINE
PLAYGROUND
The in-browser interpreter is a TypeScript port of the reference Go implementation. For full LLVM-native compilation, build the bidhu CLI from source.