Learn a New Language
When was the last time you had the desire to learn a new programming language? It can seem like a daunting task at first. However, it can be easier than you think. In this article, we will look at a commonality among programming languages that allows us to think differently about taking on a new learning path.
My Path
I have always loved learning. I first learning about programming logic using PASCAL in a college course over twenty years ago. After years as a hobbyist (read about my Journey), I started at Flatiron School in August 2019. When I started, I enrolled in the Part-time Online curriculum because I wasn't sure I could manage a full-time job and the curriculum at the same time. After the first project, I switched to the full-time curriculum because I was so far ahead of my cohort. Why? Well, as I explained to my Tech Lead at Flatiron: "Adoes while loop is a while loop."
Common Ground
So, even though languages differ, logic does not. The logic behind a while loop is thus:
while (condition is true) {
do stuff
}
This is the logic. So, let's look at a few examples:
PHP
$x = 1;
while($x <= 5) {
echo "The number is: $x <br>";
$x++;
}
In PHP, variables are prepended by $, so as long x is greater than or equal to 5, then the while loop will print the enclosed statement. For that matter, Perl is almost identical:
my $counter = 10;
while($counter > 0){
print("$counter\n");
$counter++;
}
Perl uses the same $ pretending to variables, uses print instead of echo to print out the statement.
For example: JavaScript
var i = 1
while (i <= 5) {
text += "The number is " + i;
i++;
}
Ruby
i = 0
while i <= 5
puts "The number is #{i}"
i += 1
end
Java
int i=10;
while(i<=5){
System.out.println("The number is["+i"]");
i++;
}
The basic logic is the same: loop until a condition is met. The only differences are the language-specific syntax. The next time you are interested in another language, remember that the logical building blocks remain the same; it is the language-specific rules and syntax that change. So, in my case, a "while loop was a while loop."