Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 4, 2022 07:32 pm GMT

Bhailang: The viral Gen-Z programming language

There are about 9,000 different programming languages, but you sure havent seen any like the Bhailang. Bhai i.e. brother in Hindi is a very common affectionate way of addressing your friends, especially in India. Two Indian software developers recently created a toy programming language that broke the internet. The Bhailang makes coding fun for beginners and guarantees laughs. The syntax is made in a way that it feels like you arent coding but just casually talking to your friend.

What is "Bhai" Lang

Bhailang is a dynamically typed programming language, based on an inside joke, written in Typescript. The programming languages code starts with hello bhai and finishes with bye bhai. This scripting language is making the technical side of life a lot more fun and is enough to bring a smile to any coders face.

The origin story

Aniket Singh a software developer currently working in Amazon and Rishabh Tripathi currently working as a software developer in Groww are the creators of "Bhailang". Their bromance started from their college days at MNIT Bhopal, interning at Appointy and then JP Morgan enhanced this duo. Starting from building projects like Proximo to building a viral programming language Bhailang this couple showed the power of friendship or what we say "bhaichara" in Hindi.

In a social media post Aniket wrote:

We always had a curiosity about what it takes to create a programming language, but we always thought that it would be a tedious and complicated work. But guess what? We were wrong. It's actually quite fun! The actual Idea for "Bhailang" originated from an internal joke a couple of years back when we had just started programming, since then, this idea was lurking around in the back of our heads. Finally, a couple of weeks back we started the development work and here we are with bhailang. Bhailang is simple and made for fun toy language, which is written in typescript.

Learn the "Bhai" language

Let's jump straight into the syntax of this programming language to get the essence of Bhailang! The installation is pretty straight forward, but if you just want to begin, you can also try out their playground.

As we do with all programming languages, first let's learn how to run a "Hello World" program, but since it is the Bhailang let's print "Hello Bhai" instead!

Install the npm package

npm i -g bhailang

Create a file helloBhai.bhai and add the following code.

Please ignore this bhaihi bhai  bol bhai "Hello Bhai";bye bhai

Let's understand the above code. The entire code is enveloped between hi bhai and bye bhai. Anything outside this is ignored by the compiler. If you want to print something, as in our case "Hello Bhai", can be done by adding bol bhai before it. Bol bhai means "tell brother" in Hindi. And that's it! We are ready to run our first program in Bhailang.

Run the file on your terminal with the following command

bhailang helloBhai.bhai 

If everything went, you should see any output like this:
Hello bhai output

If you have an error, the Bhailang compiler won't just show you the error but will also talk to you like a friend and say "Bro what are you doing?" It is very cool right?
Bhailang error

Now that we have our Hello Bhai program setup, let's get a bit more into the technicalities of Bhailang as a programming language.

Bhailang Block
As mentioned before, hi bhai is the entry point and bye bhai is the end point. This is called the Bhailang block, anything outside this block will be ignored.

A semicolon is a must after each syntax otherwise you can hear the Shark Ashneer Grover every time.

//Ignoredhi bhai...// commentbye bhai// Ignored

Declaring Variable
bhai yea hai is the keyword to declare any type of variable. The keyword literally means "bro this is". Here's an example:

hi bhai  bhai yea hai a = 10;  bhai yea hai b = 13;bye bhai

Data Types
numbers and string are similar to other languages. NULL values are defined by nulla which means useless in Hindi. sahi(correct) and galat(wrong) are the boolean values which are true and false respectively.

hi bhai  bhai yea hai a = 10;  bhai yea hai b = "Bhai";  bhai yea hai c = nulla;  bhai yea hai d = sahi;  bhai yea hai e = galat;bye bhai 

Console Output
As developers we are obsessed with our console. It becomes vital to know how we display data on our console. Bhailang uses a pretty creative way when it comes to console output. bol bhai is used to print output on the console. Bol bhai typically means "tell me brother".

hi bhai   bhai yea hai a = 30;  bol bhai a;bye bhai 

Conditionals
Bhailang also supports conditional programming. The if-else block is now agar bhai-warna bhai block. Try running the following code, to see it live.

hi bhai    bhai ye hai a = 32;    agar bhai (a%2 == 0){        bol bhai This is even;    } warna bhai {        bol bhai This is odd;    }bye bhai

Loops
Lastly, you can create loops in Bhailang as well. jab tak hai block will be executed until the specific condition is sahi(true). If the condition becomes galat(false), statements within the block stop executing.

  • Use bas kar bhai to break the loop.
  • Use agla dekh bhai to continue within the loop

The most distinguishing feature of Bhailang is the way they display the errors. Here are some examples:

Syntax Error
Bhailang syntax error

Divisible by Zero Exception
Divisible by zero error

Infinite loop
Infinite loop

Create your own Bhailang

These two bhais not only made the effort to build an entire programming language with a compiler and interpreter but these community driven folks also kept the complete source code open on Github.

GitHub logo DulLabs / bhai-lang

A toy programming language written in Typescript

Bhai Lang

Total alertsLanguage grade: JavaScriptBuildBuildBuild

This is official repository for bhai-lang.

Bhai lang is a toy programming language written in Typescript.


Installation

npm i -g bhailang

Usage

Create a new file (test.bhai)

Edit the file with a text editorYou can also try out your code on Bhai Lang PlayGround

hi bhai  bol bhai "Hello bhai"bye bhai

Run

bhailang test.bhai

Output

hello bhai

Documentation

General

hi bhai is the entrypoint for the program and all program must end with bye bhai. Anything outside of it will be ignored.

This will be ignoredhi bhai// Write code herebye bhaiThis too

Variables

Variables can be declared using bhai ye hai.

hi bhai  bhai ye hai a = 10;  bhai ye hai b = "two";  bhai ye hai c = 15;  a = a + 1;  b = 21;  c *= 2;bye bhai

Types

Numbers and strings

So what are you waiting for? You can also create Bhailang in your own language! The source code is attached with an MIT license, so you can explore and have fun with the code and create your very own.

Outro

Learning a new language is always fun. But understanding the way Bhailang was created and how you can build your own language makes it a whole different game. In case you have some questions regarding the article or want to discuss something under the sun feel free to connect with me on LinkedIn

If you run an organisation and want me to write for you please do connect with me


Original Link: https://dev.to/aniket762/bhailang-the-viral-gen-z-programming-language-39dn

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To