I was working once on a project that included using Javascript, Bash scripting and the Go programming languages.
Just like trying to speak three languages in one sentences, sometimes it takes a second to remember the syntax of each.
The more similar the syntax is between languages, the harder it actually becomes to switch. This made me realize how silly the whole thing really is. I know that as a programmer, I should have a strong favorite, a language that I am willing to die on some hill for. But, sometimes, I can’t help but roll my eyes.
I leave you to play spot all the differences between if conditions. I sorted the languages by year released.
Bash (~1989)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#!/bin/bash
echo -n "Enter a number: "
read VAR
if [[ $VAR -gt 10 ]]
then
echo "The variable is greater than 10."
elif [[ $VAR -eq 10 ]]
then
echo "The variable is equal to 10."
else
echo "The variable is less than 10."
fi
|
Python (~1991)
1
2
3
4
5
6
7
8
|
x = int(input("Please enter an integer: "))
if x < 0:
x = 0
print('Negative changed to zero')
elif x == 0:
print('Zero')
else:
print('More')
|
Javascript (~1995)
1
2
3
4
5
6
7
8
|
let x = 0;
if (x < 0) {
console.log("less than zero");
} else if (x == 0) {
console.log("zero");
} else {
console.log("something else");
}
|
GO (~2009)
1
2
3
4
5
6
7
8
|
x := 100
if x == 50 {
fmt.Println("Germany")
} else if x == 100 {
fmt.Println("Japan")
} else {
fmt.Println("Canada")
}
|
Rust (~2010)
1
2
3
4
5
6
7
8
9
|
let n = 5;
if n < 0 {
print!("{} is negative", n);
} else if n > 0 {
print!("{} is positive", n);
} else {
print!("{} is zero", n);
}
|