Bhailang — A Fun Programming Language
Bhailang is a dynamically typed toy programming language, based on an inside joke, written in Typescript, created by two Indian bros — Aniket Singh and Rishabh Tripathi. It is inspired by “Bro-Talk” which is commonly used by the Hindi-speaking male peoples from India.
This programming language is making the tech side of life a lot more fun and it’s a little something to bring a smile to the coder’s face.
It is a different language from others programming languages because It uses casual Hindi language as syntax which is known as Bhailang. There are a few keywords that make the Bhailang more interesting — “hi bhai…bye bhai”, “bhai ye hai”, “bol bhai”, “jab tak bhai”, “bas kar bhai”, “agar bhai”, “warna bhai”, etc.
‘Bhai’, the Hindi word for brother, is the heart of this programming language.
Let’s enjoy Bhai Ki Language — The Bhailang
Installation
The journey with Bhailang is really simple — Just create a directory for your project, and then run the npm command —
npm i -D bhailang
Create a file and run the code
Now, we can create a file with .bhai
extension — helloBhai.bhai
. Copy and paste the below code.
hi bhai
bol bhai “Hello Bhai!”;
bye bhai
Now run the code and you can see the console output as Hello Bhai!
.
npx bhailang helloBhai.bhai
Bhailang block
hi bhai
is the entry point and bye bhai
is the end point. This is called Bhailang block, anything outside of this block will be ignored.
semicolon ;
is must after each syntax otherwise you can hear Ashneer Grover’s voice.
// Ignoredhi bhai
...
// comment
bye bhai// Ignored
Declaring Variable
bhai ye hai
is keyword to declare any type of variables.
hi bhai
bhai ye hai a = 10;
bhai ye hai b = 13;
bye bhai
Data Types
numbers
and string
are similar to other language. NULL values are defined by nulla
keyword. sahi
and galat
are the Boolean values.
hi bhai
bhai ye hai a = 10;
bhai ye hai b = "Bhai";
bhai ye hai c = nulla;
bhai ye hai d = sahi;
bhai ye hai d = galat;
bye bhai
Console output
bol bhai
is used to print output on console.
hi bhai
bhai ye hai a = 10;
bhai ye hai b = 13;
bol bhai a + b;
bye bhai
Conditionals
Bhailang supports conditional programming. agar bhai
block is executed if condition is sahi
otherwise warna bhai
block will be executed.
hi bhai
bhai ye hai a = 10;
agar bhai (a%2 == 0){
bol bhai “Are ye to Even hai.”;
} warna bhai {
bol bhai “Ye to Odd hai.”;
}
bye bhai
Loops
jab tak hai
block will be executed until the specific condition is sahi
. If the condition becomes galat
statement within the block stops executing.
- Use
bas kar bhai
to break the loop. - Use
agla dekh bhai
to continue within the loop.
hi bhai
bhai ye hai a = 0;
jab tak bhai (a < 10){
a += 1;
agar bhai(a == 4){
bol bhai “ye hai “, a;
}
agar bhai(a == 6){
bol bhai “Agla dekh”;
agla dekh bhai;
}
agar bhai(a == 8){
bol bhai “Ruk ja”;
bas kar bhai;
}
}
bol bhai “Bas bhai, mai to thak gya”, a;
bye bhai
Common Errors
The more fun part comes while displaying errors in the console. Whenever you get any compilation error or runtime error it will show the error in Ashneer Grover’s famous voice — Kya kar rha hai tu??...
There are some common errors and exceptions below —
- Syntax Error
- Divisible by Zero Exception
- Infinite loop
You can find the complete code here which is explained in this article.
Resources:
Happy Learning!!!
Thanks for reading and sharing! 😄 👏