Search Here

BhaiLang Tutorial - A Desi Toy Programming Language for Fun

BhaiLang Tutorial | A Desi Toy Programming Language for Fun

The BhaiLang is a Toy Programming Language which is written in Typescript. This is basically a programming language for fun purposes. It is developed by Aniket Singh and Rishabh Tripathi.

This post is related to the usage of Bhailang programming with a walkthrough of the syntax and other conditional statements and finally my take on the future of this programming language.

Installing

You can download it through the npm package manager by using the below command.

npm i -g bhailang

In test.bhai

hi bhai
    bol bhai "Hello World";
bye bhai

Running the Script

bhailang test.bhai

//output
> Hello World

Entry Point

The main entry point of this language is the phrase hi bhai which ends with bye bhai. All the other tokens and variables must be declared inside it and anything declared outside will be ignored.

Declaring Variables and Datatypes

To declare a new variable use bhai ye hai followed by variable name and equal to its value.

hi bhai
    bhai ye hai name="pavan";
    bhai ye hai age=18;
    bhai ye hai is_student=sahi;
    bhai ye hai is_passed=galat;
    bhai ye hai course_name=nalla;
bye bhai

The word sahi means true, galat means false and nalla means null.

Printing values in Console

For printing use the phrase bol bhai which does the same as console.log in JavaScript.

hi bhai

    bhai ye hai name="pavan";
    bhai ye hai age=18;

    bol bhai "Hello World";

    bol bhai "My Name is ", name, " and age is :", age
bye bhai

// Output
>  Hello World
>  My Name is  pavan  and age is : 18

Conditional Statements

BhaiLang provides you with if-else and ladder if-else conditional statements.
For if-else use agar bhai and else part will be warna bhai.
For Ladder if-else uses agar bhai and else if part will be nahi to bhai with condition enclosed in the bracket.

hi bhai
    
    bhai ye hai age = 18;

    agar bhai ( age >= 18 ){
        bol bhai "You are eligible to vote";
    } warna bhai {
        bol bhai "You are not eligible to vote";
    }

    agar bhai ( age >= 18 ){
        bol bhai "You are eligible to vote";
    } nahi to bhai ( age < 18 ) {
        bol bhai "You are not eligible to vote";
    }

bye bhai
  

Looping Statements

For looping statements use jab tak bhai block with the condition and curly brackets. It acts as a while loop. You can also specify agla dekh bhai which is a continue keyword.
And bas kar bhai which is a break keyword.

jab tak bhai ( index<=numbers ){
    agar bhai (index%2==0){
        agar bhai ( index == 0 ){
            index+=1;
            agla dekh bhai;
        }

        bol bhai index, ' is even number';
    }
    index+=1;
}

Takeaways

I had fun learning this programming language it is basic and can easily be learned by developers with basic JavaScript knowledge. The only thing is in my mind is that since the programming language can out of a joke it was better if we would have the ability to declare functions.

The thing I really liked is that the runtime errors are very funny and make your day. I sincerely hope the developer brings new features to this language so that we can create some small applications and test them out.

Watch Video