
Can you believe there's a coffee place called Ruby!? That's genius! Anyway, this entry is about Ruby and JavaScript.
I've come to understand, at least at my rudimentary level of programming, that all of the programming languages are very much the same, they just have different syntax and different words for things... some slightly different ways of building pretty much the same thing.
For example, just the words used to make similar things happen like:
Creating a variable:
JavaScript:
var varName = "string";
Ruby:
var_name = "string"
Here, we get to leave out the "var" to declare, and leave out the semicolon. The two languages have different conventions fr how to name variables, and I think the above way illustrates them pretty well. How about this:
Printing to the console:
JavaScript:
console.log("Hello");
Ruby:
puts "Hello"
I get console.log, but it's so complicated. "Eloquent JavaScript" even says there's no other way to shorten this. Really? Really EJS? How about "puts" or even better, in Ruby, "p". Just "p"!!!! I mean, it behaves a little differently than "puts" or even "print" but we won't get into that. Oh, did I mention we didn't have to put parentheses or a semicolon? Just sayin'... and how about THIS:
If statements:
JavaScript:
if (a < b) {
//code;
}
else if (a > b) {
//code;
}
else {
//code;
}
Ruby:
if a < b
#code
elsif a > b
#code
else
#code
end
Was it Polonius in Hamlet that said "Brevity is the soul of wit"? (The comedy there was that Polonius rambled... much like I do... how ironic...) Anyway, huge differences here, again the parentheses and the semicolons, but also the curly bracers vs. just "end" for Ruby letting us know that's all. Also noteable is the way the commenting works in each language. This is illustrated a little above.
I hope y'all find this to be a little helpful, if not, make you aggravated at how JavaScript is so finicky about its bracers and brackets and bawbles. Nah, I'm sure I'll learn to love JavaScript... if not, I just will grin and bear it.