Wednesday, August 19, 2009

Rubular

ooooo... came across this just now by accident. Really cool!

Rubular - a Ruby regular expression editor.

This is the first Ruby-centric regex checker that I've found. Handy reference.

Thursday, August 13, 2009

Ugh!

Google is a blessing and a disappointment at the same time sometimes. I got distracted looking for a routine today to solve a particular question I had. I was looking for a simple (?) mathematical algorithm. I found many pages on the Math - they were okay, but only helpful to a point. And then I found some pages with sample Ruby code on them - great!

Until I actually tried the code. And read the code. And then gagged myself with a spoon and completely rewrote the code. I ended up with less than half of the total lines of code that I originally found on the 'net. (BTW, I still don't know what the other half of the code was trying to do. Really.)

Why is it that almost all of the Ruby code samples out there (that I have come across) are written by non-Ruby programmers? Their code is junk. I'm sorry but anyone who takes Java, Perl or C code (or whatever) and thinks they can do some simple translation to Ruby is sadly mistaken.

It took me about 15 minutes of staring at a For-Next loop to discover that I could rewrite it with a .each do loop. I was confused by the For-Next -- I hadn't seen one of those since the early 90's. It was just really surreal code, you know? Here I was looking at non-Ruby code that worked in Ruby. Weird.

Did it solve my problem? Kinda sorta. Rewriting the code into something intelligible gave me enough insight to write the remaining code I needed to answer my question.

I debated whether or not to include some examples here (of the shoddy Ruby code) but I don't think I want to give any attention to some of the many poor programmers out there. They clearly don't deserve any more mention than Google has already provided. I'll think about posting some of my examples here when I get some free time though ... for balance.

Note to the Ruby posers out there: Just stop. Please. You're embarrassing yourselves. It ain't a bandwagon. If you don't get it, please stay away from the programming language translators. Ruby ain't like the other languages - it puts humans first, not the machine. Talk in human terms, not computer jargon. Ugh.

I would have preferred to have gotten no (Google) hits and just posted the question to one of the helpful Ruby forums instead.