Babu Language
A fun programming language built on JavaScript. Created by: Atikin Verse.
npm i babu-language
A fun programming language built on JavaScript. Created by: Atikin Verse.
π§ Step | π Command / Description |
---|---|
Navigate to the project folder | cd babu-language |
Install dependencies (if any) | npm install (optional β if CLI features/extensions added) |
Run a Babu file | node index.js path/to/file.babu |
β
1. Print Statement (test1.babu):
.
bol babu "Namaste Babu!"; //Output: Namaste Babu!
β
2. Variable Declaration & Usage (test2.babu)
.
let babu naam = "Babu Language"; bol babu naam; //Output: Babu Language
β
3. If-Else Condition (test3.babu)
.
let babu age = 20; agar babu (age >= 18) bol babu "Adult Babu"; nahi to babu bol babu "Chhota Babu"; kaam khatam babu //Output: Adult Babu
β
4. While Loop (test4.babu)
.
let babu i = 1; jab tak babu (i <= 3) bol babu i; i = i + 1; kaam khatam babu //Output: 1 2 3
β
5. Function and Return (test5.babu)
.
kaam babu greet(name) bol babu "Hello " + name; kaam khatam babu bula babu greet("Babu"); //Output: Hello Babu
6. File Write and Read (Requires Node.js with fs module) (test6.babu)
.
likho file "output.txt", "Hello from Babu"; let babu content = padho file "output.txt"; bol babu content; //Output: Hello from Babu
β
7. Error Handling (test7.babu)
.
galti ho sakti hai babu bol babu undefinedVariable; pakdo babu (err) bol babu "Error aaya: " + err.message; kaam khatam babu //Output: Error aaya: undefinedVariable is not defined
β
8. Boolean Test(test8.babu)
.
let babu isOpen = sahi babu; let babu isClosed = galat babu; bol babu isOpen; bol babu isClosed; //Output: true false
π§ Step | π Description |
---|---|
1. Create a .babu file | Write your Babu code in a file named hello.babu. |
2. Sample Code |
le babu name = "Babu", bol babu "Hello " + name |
3. Run the Babu file | Use the command node index.js hello.babu to transpile and execute the code. |
This is simple code snippet extension for Babu Language projects.
π§ Babu Syntax | π» JavaScript Equivalent |
---|---|
bol babu "Hello" | console.log("Hello") |
bol babu x + y | console.log(x + y) |
let babu x = 5 | let x = 5 |
const babu y = 10 | const y = 10 |
var babu z = 15 | var z = 15 |
agar babu (x > 3) | if (x > 3) { |
nahi to babu | } else { |
jab tak babu (x < 5) | while (x < 5) { |
kaam babu greet(name) | function greet(name) { |
wapis jao babu x * y | return x * y |
kaam khatam babu | } |
bula babu greet("Babu") | greet("Babu") |
sahi babu | true |
galat babu | false |
padho file "data.txt" | fs.readFileSync("data.txt", "utf-8") |
likho file "out.txt", "hello" | fs.writeFileSync("out.txt", "hello") |
galti ho sakti hai babu | try { |
pakdo babu (err) | } catch (err) { |
koi ghalti babu "message" | throw new Error("message") |
event babu click = bol babu "ok" | click = function() { console.log("ok") } |