Jhethia is a fun programming language modeled in Java, spiced up with the hilarious antics of Jhethalal. Its syntax somewhat mixes Rust and Python, promising a coding experience full of laughs and fun! Jhethia allows users to perform a wide range of basic operations typical of any programming language, all while injecting a dose of fun into the process. Jai Jinendra!
A 2023 graduate, dedicated full stack developer with a drive for building and innovating !
Creating something from scratch allows me to
deepen my understanding of programming concepts and unleash my zaney mind in a unique way.
What
is the first thing you learn when starting with coding? A Programming Language! So i figured no better
novel idea than to build one my own. It was a thoroughly enriching and learning experience : from
building my own lexers,parsers and basically a grammar of my own.
🙏🏻 Jai Jinendra 🙏🏻
The syntax of Jhethia is a mix of Rust and Python. The tokens are mostly defined in hindi and in certain cases dialogues are taken verbatim out of the show Taarak Mehta Ka Ooltah Chashmah.
<variable_name> = <expression>
For eg:
full_name = "Krishnan Iyer"
age = 42
weight = 64.78
is_scientist = sahi_baat_hai
A variable is a named storage that programs can manipulate.
Simply put, a variable helps programs to store values.
Variables in Jhethia can be of
Numerical, Text or Logical data-type.
The data-type isnt explictly mentioned while declaration.
kaam
<function name>
#class content#
...
khatam
kaam
<function name> [
x , y ]
#class content#
...
bhejo
<expression>
khatam
For eg:
kaam
Sum [
x , y ]
bhejo
x + y
khatam
A function in Java is a block of code that performs a
specific task, often reusable and callable with parameters.
Jhehtia declares a function using
keyword "kaam" and the arguments are passed via [] brackets.
The values are returned with
"bhejo" keyword.
lijiye_baapuji
<variable_name>
For eg:
lijiye_baapuji
first_name
lijiye_baapuji
age
lijiye_baapuji
plays_football
Jhethia accepts user input via "lijiye_baapuji" statements.
The values are stored in their respective variables. The data types which can be input are
Numerical,Text or Logical.
If there's a conflict in input data and the expected data-type an
exception is immediately raised.
dekhiye_baapuji
<expression>
For eg:
dekhiye_baapuji
"Chai Piyo, Biscuit Khao!"
dekhiye_baapuji
456 + 789
dekhiye_baapuji
40 > 20
Printing not only is essential in displaying values but also
plays a major role in debugging. Jhethia has a fun "dekhiye-baapuji" statement to display values.
Just like any other print statement, Jhethia allows concatantion and solves straight
forward
conditional expressions to display.
agar
<condition>
#statements
yatoh
<condition>
#statements
warna
#statements
khatam
For eg:
agar
baapuji ka
age < 20
dekhiye_baapuji
"Age is lesser than 24."
yatoh
age < 50
dekhiye_baapuji
"Age is lesser than 50."
warna
dekhiye_baapuji
"Age is greater than
50."
khatam
If/Else evaluates a condition, and enables branching in the
program's logic, allowing different paths to be taken based on different conditions. Our Jhehtia
uses "agar-yatoh-warna" statements to evaluate conditions.
The "ka" is used to read struct's
argument
value.The "khatam" statement means end.
While Loop
chai_piyo
<condition>
# statements
biscuit_khao
For Loop
chai_piyo
<variable> in
<lower_bound>...<upper_bound>
# statements
biscuit_khao
For Loop By Step
chai_piyo
<variable> in
<lower_bound>...<upper_bound> by
<step>
# statements
biscuit_khao
A loop is a control structure that repeats a block of code
multiple times until a specified condition is met, enhancing code efficiency and flexibility.
Jhethia has many loops famously for, while etc.
The chai-piyo biscuit-khao looping statement
is taken right from the show's hilarious dialogue.
Now that we're aware of the syntax and its functioning lets go over some sample code! Below are some programs and their reseponses to depict how cool Jhethia is !
lijiye_baapuji
first_value
lijiye_baapuji
second_value
ans = first_value / second_value
dekhiye_baapuji
"Apka Answer: "+ ans
In this example we've accepted two inputs from the command
line.
One being first_value and other is second_value.
We are doing a simple division operation and
storing the result in ans variable.
Finally we're displaying the result after concatantion with
a string.
*** Jai Jinendra ! Nashta Karke Jaana ! ***
enter "first value" >>>
2024
enter "second value" >>>
4
Apka Answer: 506
Now here we see that we're greeted with a "Jai Jinendra"
which is a staple dialogue in Tarak Mehta Ka Ooltah Chashmah.
The user inputs the values
and then internally the operation is performed
The result is displayed with the appropriate
string and value.
*** Jai Jinendra ! Nashta Karke Jaana ! ***
enter "first value" >>>
10
enter "second value" >>>
0
Poblem
: Aye Dobiii ! Zero Se Divide Kar Rahi Hai Queen Victoria ?!
Solution
: Try With A different Denominator
Exception in thread "main" OperationException()
...
Here we see how hilariously an arithmetic exception of
division by zero is handled.
The user had input the denominator value as zero and hence
exception was thrown.
The Poblem:Solution part is a nod to the intro theme of Tarak Mehta Ka
Ooltah Chashmah.
Binary Search:
kaam
BinarySearch [
arr, n, lo, hi, key ]
agar
hi >= lo
mid = (hi + lo) // 2
agar
arr{mid} < key
bhejo
binary_search [
arr,n,mid+1,hi,key ]
yatoh
arr{mid} > key
bhejo
binary_search [
arr,n,mid-1,hi,key ]
warna
bhejo
mid
khatam
warna
bhejo
- 1
khatam
bhejo
khatam
Binary search is a divide-and-conquer algorithm used to find a target value within a sorted array. It compares the target value with the middle element of the array. If they match, the search is successful. If not, it halves the search space by discarding one half, repeating the process until found or deemed absent.
Bubble Sort :
kaam
BubbleSort [
arr , n ]
chai_piyo
i in
0..n - 1
chai_piyo
j in
0..n - i - 1
agar
{j + 1} < {j}
temp = arr{j}
arr{j} = arr{j + 1}
arr{j + 1} = temp
khatam
biscuit_khao
biscuit_khao
khatam
Bubble sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. It's inefficient for large lists but easy to understand and implement.
It continues until no more swaps are needed, indicating that the list is sorted.
First and Foremost Clone Jhethia's Repository In Your System.
Then compile and package the program into an Uber jar, go to the ./target folder and then run the following
command :
java -cp Jhethia.jar org.prakarshs.JhethiaRun ../src/test/resources/hello_world.jhethia