Benoît
raw JSON →Benoît is a self-interpreting, self-evolving, self-proving programming language where every line is simultaneously code, test, proof, and documentation. Version 0.8.0 runs .ben files natively via a Pratt parser and tree-walking evaluator (zero eval, zero new Function), offers 68% token reduction compared to equivalent JavaScript, and includes a genetic algorithm (evolve.mjs) that discovers functions from assertions alone with 80% success rate. Active development with monthly releases, it targets Node >=18 and focuses on human-AI collaboration, pattern matching with guards, pipes, async/await, and a built-in property inference engine that detects 31 mathematical properties automatically. Unlike traditional languages, there is no separation between code, tests, and documentation.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported ↓
error TypeError: benoit.compile is not a function ↓
error SyntaxError: Unexpected token (0:22) - '?' is not valid at this position ↓
error Error: runBen expects a string or a file path, got object ↓
Warnings
breaking v0.4.0 dropped CommonJS support; package is ESM-only. ↓
breaking v0.5.0 renamed compile API to transpile. ↓
breaking v0.6.0 changed default export from a parse function to a multi-purpose transformer. ↓
deprecated evalBen function deprecated since v0.7.0; use runBen instead. ↓
gotcha Pattern-matching guards use 'when' keyword; 'if' is not valid inside patterns. ↓
gotcha Token-reduction measurement is for transpiled JS, not for performance; no benchmarks guarantee speed improvement. ↓
Install
npm install benoit yarn add benoit pnpm add benoit Imports
- default wrong
const benoit = require('benoit')correctimport benoit from 'benoit' - runBen wrong
import { run_ben } from 'benoit'correctimport { runBen } from 'benoit' - transpile wrong
import { compile } from 'benoit'correctimport { transpile } from 'benoit' - EvolveMachine wrong
import { evolve } from 'benoit'correctimport { EvolveMachine } from 'benoit'
Quickstart
import { runBen } from 'benoit';
const code = `
fib n ->
n < 2? -> n
else? -> fib(n - 1) + fib(n - 2)
fib(0) is 0
fib(5) is 5
fib(10) is 55
`;
runBen(code).then(({ passed, total }) => {
console.log(`Passed ${passed}/${total} assertions.`);
}).catch(err => console.error(err));