DEV Community

Revanth Nemtoor
Revanth Nemtoor

Posted on

Building "Smrti" - A Compile-to-Assembly Language based on Panini's Grammar. Seeking Feedback!

Namaste everyone,

I've been working on a new programming language called Smrti . My goal is to create a language that doesn't just swap English keywords for Sanskrit ones, but actually incorporates Sanskrit grammatical structures (like Vibhakti) into the syntax itself.

I built this language with the assistance of AI, which helped in generating the compiler architecture (written in Rust) while I focused on the linguistic design and core logic.

I would love to get your thoughts on the syntax, specifically how it feels to someone familiar with Sanskrit.

https://revanthnemtoor.github.io/smrti_docs.github.io/docs.html
https://github.com/revanthnemtoor/smrti_lang

How it compares to other Sanskrit-based languages
I've seen other attempts at Sanskrit programming languages, but many of them tend to follow a "Generic" approach:

Generic Approach: Strictly replaces English keywords with Sanskrit words (e.g., swapping if for yadi, print for vada) but keeps the C/Java-style grammar exactly the same. It often feels like English code translated word-for-word.

Smrti's Approach: I've tried to respect the grammar (Vyakarana) more deeply.

Vibhakti for Ranges: Instead of a C-style for (i=0; i<10; i++), Smrti uses case endings. For example, 1-tah 10-paryantam (From 1... Up to 10).

SOV Structure: Smrti supports Subject-Object-Verb ordering. You can write "Hello" vada; (Hello speak) instead of just vada("Hello");.

Meaningful Typing: Types are named Ank (Number/Mark), Dashansh (Decimal), Sutra (Thread/String), reflecting their nature.

Code Example
Here is a simple snippet in Smrti:

sutra Mukhyam() {
// Variable declaration
man count: Ank = 5;
// Range loop using -tah (Ablative) and -paryantam (Ending)
1-tah count-paryantam {
"Namaste World!" vada;
}
}
Does this syntax feel intuitive? Are there grammatical nuances (like the usage of tah and paryantam) that could be improved?

I appreciate any feedback or suggestions!

Top comments (0)