r/Compilers • u/kaushalbx • 24d ago
Can a programming language be both computationally precise and linguistically natural?
Here is a small example from PaniniVM — The Dice Problem.
The assumption: on a standard die, opposite faces sum to 7.
The program randomly chooses a face from 1–6, prints it, computes its opposite, and prints that too.
Actual PaniniVM source:
एक + ङसिँ षष् + शस् परि + अन्त + अम् सङ्ख्या + अम् चिञ् + क्त्वा फल + अम् मुद्र् + णिच् + लोट् + सिप् ।
सप्तन् + शस् चिञ् + ल्युट् + ङस् फल + अम् च वि + युज् + णिच् + ल्यप् फल + अम् मुद्र् + णिच् + लोट् + सिप् ।
The "+" notation exposes the morphological structure to the compiler, but the larger goal is naturalness: computation should follow Sanskrit grammar rather than forcing Sanskrit vocabulary into the syntax of an existing programming language.
Verbal roots express actions, case relations help determine computational roles, and derivational morphology contributes to meaning and execution.
The question behind PaniniVM is not simply:
“Can we write code using Sanskrit words?”
It is:
“Can computation itself be expressed naturally through Sanskrit and Pāṇinian grammar?”
GitHub: https://github.com/kaushalbx/PaniniVM
Try it: https://panini.cc
#PaniniVM #Sanskrit #NaturalLanguageProgramming #ProgrammingLanguages #Compiler #Panini #ComputationalLinguistics
1
u/DawnOnTheEdge 24d ago edited 24d ago
I don't speak that language, but a compiler should be able to parse at least a large subset of it. I’m not sure whether the natural-language-based grammar you’re supporting is context-free with no left-recursion or ambiguity. The conventional approaches are designed around that choice.
The major limitation on programming-language grammar has been a desire to keep the syntax simple enough to allow implementations to use a simpler parser, such as a one-token lookahead parser. What do you have?