Ganges

Basics

Let's start with the basics. Ganges is a dynamically typed, interpreted language built using the book Writing an Interpreter in Go. The book is a hands-on guide on how to build an interpreter from scratch.

Nomenclature

Ganges uses Sanskrit-inspired keywords that map closely to their equivalents in modern programming languages like JavaScript. This not only makes the language unique, but also reinforces semantic clarity with cultural roots.

Below is a reference table that shows common JavaScript keywords alongside their Ganges counterparts and a brief description of their use.

JavaScriptGangesDescription
letramaused to declare variable
ifyadiif block
elseanyathaelse block
printvadhato write to console
functionkriyato declare a function
whilechakrawhile loop initiation
truesatyathe boolean value true
falseasatyathe boolean value false
returndaanreturn value from a function

Variables

Variables in Ganges are declared using the keyword rama. You don’t need to specify a type — just assign a value using =.

Strings are enclosed in double quotes. Every statement must end with a semicolon (;). Variable names follow snake_case or camelCase — your call.

app/variables.ga

1   rama myName = "Sidharth";

2   rama gfName = "19022023";

3   rama baby = "Dhanu";

Data Types

Ganges supports simple but powerful types: boolean, string, and integer. No type declarations are needed — the interpreter figures it out.

Booleans use true or false, strings go inside double quotes, and integers are written as-is. Terminate every declaration with a semicolon.

app/dataTypes.ga

1   rama isAlive = true;

2   rama name = "Lakshman";

3   rama age = 27;

Arithmetic Operations

Ganges supports all basic arithmetic operations:+,-,*, and/. Use them freely on integers.

Operations follow standard precedence rules. Variables can store results of expressions.

app/arithmetic.ga

1   rama a = 10;

2   rama b = 5;

3   rama sum = a + b;

4   rama diff = a - b;

5   rama prod = a * b;

6   rama div = a / b;

Print Statements

To print output in Ganges, use the keyword vadha. This function prints to the console.

Wrap what you want to print inside parentheses and double quotes. Don't forget the semicolon (;) at the end.

app/main.ga

1   vadha("Namaste!");

2   vadha("My name is Sidharth");

3   vadha("Ganges flows strong");

Conditionals

Conditional logic in Ganges is handled using yadi for if and anyatha for else. The condition goes inside parentheses, and the branches inside curly braces.

Unlike many languages, the yadi-anyatha block is an expression. That means it returns a value and can be directly assigned to a variable.returns value

app/conditionals.ga

1   rama mood = yadi (5 > 3) {

2     "happy"

3   } anyatha {

4     "sad"

5   };

Difference from Traditional If/Else

  • yadi is an expression, not a statement.
  • It can return a value directly — no need for ternaries or mutables.
  • You must end the full expression with a semicolon if used in a binding.