A Sanskrit programming language whose type system is Panini's karaka grammar - and whose own compiler is written in itself.
翻译准备中
正在加载完整 README。
查看完整 README ↗A programming language whose type system is Pāṇini's grammar, and whose own compiler is written in itself.
Sanskrit does not decide meaning by word order. It marks the role each participant plays in an action — the agent, the patient, the instrument, the source — and lets the words fall where they like. Vāk makes those roles part of a function's type:
कार्यम् छानय(अपादानम् सूची संग्रहः, करणम् कार्यम् परीक्षा) : सूची { ... }
# ↑ the source drawn from ↑ the instrument drawn by
The analyser enforces Pāṇini's rule that an action takes at most one agent and one patient. And because each argument carries its own role, the order stops mattering — the same liberty a Sanskrit sentence gets from its case endings, moved into a type system. More on kāraka roles →
Vāk's own front end — lexer, parser, semantic analyser, compiler and virtual machine — is written in Vāk, 4,178 lines of it. Python builds that toolchain once, the way a C compiler is used once to build a self-hosting C compiler, and after that Python is not in the loop. More on the bootstrap →
Underneath, this is a real language rather than a demonstration: optional declared types,
lexical scope, first-class functions with closures, lists and dictionaries, exceptions,
modules and file I/O. Keywords, types, built-in functions, error names and numerals are
Sanskrit — not English with a Devanagari skin. Commands are imperative verbs (मुद्रय
"print!", उत्सृज "cast forth!"), the catch clause is in the locative case (दोषे "in
case of a fault"), and statements end with a danda ।.
कार्यम् अभिवादनम्(शब्दः नाम) : शब्दः {
प्रत्यागच्छ "नमस्ते " + नाम + "!"।
}
सूची जनाः = ["मैत्रेयी", "गार्गी", "आर्यभटः"]।
प्रत्येकम् (जनः अन्तः जनाः) {
मुद्रय अभिवादनम्(जनः)।
}
नमस्ते मैत्रेयी!
नमस्ते गार्गी!
नमस्ते आर्यभटः!
It runs five ways — a tree-walking interpreter, a bytecode VM in Python, that same VM written in Vāk, a runtime in C, and a native back end that compiles a program to a standalone executable needing no Python and no toolchain to run. All five are held to byte-identical output by a differential test suite, which is the main reason any of this can be trusted.
On how this was built. Vāk was designed by a person and implemented with substantial help from a large language model. The split is set out in कृत्रिमबुद्धिः, and the commit history records it.
And none of it requires a Devanagari keyboard: every keyword has an ASCII spelling, ASCII numerals work everywhere, and the browser playground turns romanised typing into Devanagari as you write.
The site — four self-contained pages in docs/, each generated, each with no external requests:
page what it is built by index.html the landing page — every program on it is run while the page is built docs/build_landing.pymanual.html the whole language in 17 sections — syntax, the standard library, every diagnostic, every flag docs/build_manual.pyplayground.html the toolchain in WebAssembly — runs Vāk in the browser docs/build_playground.pystory.html कथा — how the language was built, with every figure read from the repository docs/build_story.pyServe them with GitHub Pages (Settings → Pages → Deploy from branch →
/docs).
Four ways in. They run the same language; pick whichever suits you.
1 · The standalone binary — nothing else required. वाक्.exe in this
repository is the whole toolchain compiled to one file. It needs no Python.
Copy it anywhere and run it:
वाक्.exe प्रोग्राम.vak
The binary here is built for 64-bit Windows. On Linux or macOS, build your own — see Building the binary. The C sources are platform-neutral.
2 · With pip. Requires Python 3.10+ and pulls in no third-party packages.
pip install vak-lang
vaak प्रोग्राम.vak
The distribution is
vak-langand the command isvaak. The import name isvaaktoo —vakon PyPI is an unrelated bioacoustics package.
This gives you the interpreter, the bytecode VM, the native back end, the REPL
and the standard library, and the vak command works from any directory.
3 · From a clone, if you want the parts a wheel does not carry — the C
runtime, the Vāk-written toolchain behind --self, the documentation
generators and the editor extension:
以上为 README 的开头部分。其余内容请阅读原文。 查看完整 README ↗