The complete language reference — fifteen keywords, a small standard library, and a browser-native interpreter. Every example below is runnable; press the play icon on any block to open it in the playground.
Open the playgroundKeep the complete Hinglish keyword guide, syntax reference, and standard functions handy offline.
AltFLang is a modern, high-performance conversational programming language designed with an intuitive desi-style syntax. It runs entirely inside your browser with a custom-built Lexer, Parser, AST, and Interpreter — zero external dependencies or server compilation required.
; or newlines.// or #./* ... */.{ ... }.bol(...) or chhap(...).rakho)Use rakho to declare mutable variables:
rakho aam = 10;
aam = 20; // Re-assignment is allowed
bol("Aam ki count:", aam);pakka)Use pakka to declare constants that cannot be reassigned:
pakka PI = 3.14159;
// Reassigning PI will throw a Runtime Error!AltFLang supports standard dynamic primitives and compound data structures:
| Type | AltFLang Literal / Value | Description |
|---|---|---|
| Number | 10, 3.14, -5 | Integers and floating-point numbers |
| String | "Namaste", 'Duniya' | Text literals with escape sequences |
| Boolean | sahi (true), galat (false) | Truthy/falsy boolean values |
| Null | khali | Represents empty or non-existent value |
| Array | [1, 2, "aam"] | Ordered zero-indexed lists |
| Object | { naam: "AltF", aayu: 1 } | Key-value mapping pairs |
rakho Suchi = [10, 20, 30];
rakho Vastu = { chabi: "Moolya" };
bol("Array zero index:", Suchi[0]);
bol("Object property:", Vastu.chabi);+ (addition / string concatenation), - (subtraction), * (multiplication), / (division), % (modulo).
== (equal), != (not equal), < (less than), > (greater than), <= (less than or equal), >= (greater than or equal).
&& (AND), || (OR), ! (NOT).
rakho a = 15;
rakho b = 4;
bol("Modulo:", a % b); // 3
bol("Logical AND:", (a > 10) && (b < 5)); // sahiagar / warna)agar, warna agar, and warna.Conditionals evaluate expressions and execute matching blocks:
rakho ank = 85;
agar (ank >= 90) {
bol("A+ Grade!");
} warna agar (ank >= 75) {
bol("First Division!");
} warna {
bol("Pass");
}jab_tak / chalo)bhang), and continue (aage).jab_tak)rakho ginti = 0;
jab_tak (ginti < 5) {
bol("Kram:", ginti);
ginti = ginti + 1;
}chalo)chalo (rakho i = 0; i < 3; i = i + 1) {
agar (i == 1) {
aage; // skip 1
}
bol("Loop index:", i);
}aage / bhang)aage skips to the next iteration; bhang leaves the loop entirely.
chalo (rakho i = 0; i < 5; i = i + 1) {
agar (i == 3) {
bhang; // stop the loop at 3
}
bol("Chal raha hai:", i);
}
// prints 0, 1, 2Loops nest freely, and both keywords apply to the innermost loop:
chalo (rakho i = 0; i < 2; i = i + 1) {
chalo (rakho j = 0; j < 2; j = j + 1) {
bol(i, j);
}
}karya / lautao)Functions are declared with karya and return with lautao:
karya guna_karo(x, y) {
lautao x * y;
}
rakho uttar = guna_karo(6, 7);
bol("6 * 7 =", uttar);A function can call itself. lautao exits immediately, so the base case
guards the recursion:
karya factorial(n) {
agar (n <= 1) {
lautao 1;
}
lautao n * factorial(n - 1);
}
bol("5! =", factorial(5)); // 120Functions are values: pass them as arguments, return them, store them in variables. A returned function keeps access to the scope it was created in (a closure):
karya ginti_banao() {
rakho ginti = 0;
karya badhao() {
ginti = ginti + 1;
lautao ginti;
}
lautao badhao;
}
rakho counter = ginti_banao();
counter();
bol("Counter:", counter()); // 2bol(...args): Prints values to console output.chhap(...args): Alias for bol — identical behaviour.lambai(item): Returns length of array, string, or object keys.prakar(val): Returns type string ("sankhya", "shabd", "sahi_galat", "suchi", "vastu", "khali").jodo(array, item): Pushes item onto array.nikalo(array): Pops item from array.sankhya(val): Converts value to number.shabd(val): Converts value to string representation.samay(): Returns current epoch timestamp in milliseconds.ganit: Math object with abs, floor, ceil, round, random, pow, sqrt, min, max, PI, E.bol("Math Random:", ganit.random());
bol("Square Root of 144:", ganit.sqrt(144));Arrays are zero-indexed and mutable in place:
rakho suchi = [1, 2, 3];
suchi[0] = 99; // assign by index
jodo(suchi, 4); // push
rakho aakhri = nikalo(suchi); // pop, returns the removed item
bol(suchi, aakhri, lambai(suchi));Objects support both dot and bracket access, and nest freely:
rakho vastu = { naam: "AltF", andar: { saal: 2026 } };
bol(vastu.naam); // dot
bol(vastu["naam"]); // bracket
bol(vastu.andar.saal); // nestedlambai works on all three: arrays, strings, and object keys.
agar treats these as false — everything else is true:
| Value | Truthiness |
|---|---|
galat | false |
khali | false |
0 | false |
"" (empty string) | false |
agar (0) { bol("nahi chalega"); } warna { bol("0 is falsy"); }
agar ("") { bol("nahi chalega"); } warna { bol("empty string is falsy"); }Errors carry the exact line and column, and stop execution at that point:
pakka PI = 3.14159;
PI = 3;Running that stops with:
[Line 2, Column 4] Runtime Error: Cannot reassign constant variable 'PI'The playground highlights the offending line in the editor and prints the same message in the output console, so you can jump straight to it.