So I just got my Ruby books yesterday and started reading the Pick Axe book (you see how hip I am, slinging the lingo already?). I learn languages in what I’ve come to understand is peculiar among most of the people I know. Let me preface by saying I have kind of a bad memory for the details of method signatures and all that. So when I undertake to learn something I get the book and I read it straight through, cover to cover with never a finger on the keyboard. I like learning this way because when I sit down to program I like to have at least a broad understanding of most of the tools at my disposal - I’m pretty good at remembering a lot of features. I’m going to have to reference the book for all details anyway and having done some examples en route wouldn’t keep those examples in my mind anyway. Reading straight through I can get through the books pretty quicklky and set down to working on more complex projects right after that.

So, having read my 60 or so pages I note three things. One, they suggest that they are almost as popular as perl. Now, I’m not sure of the numbers but I would be shocked… SHOCKED… to find that Ruby had a fraction of the use base of perl. More momentum, sure, more mindshare, sure but Perl is used everywhere and Ruby… isn’t. Not yet, at least. That’s not me being a Perl booster, that’s just me knowing that Perl is used all over the place by all types of people for all types of purposes.

The language itself is seeming quite cool. One random thing I loved was the style tip of 2 space indents. I’ve been making my indents 3 ever since I discovered set tabstop, shiftwidth and expandtab in vi. I would’ve done 2, but at the time my company’s policy was 8 and for some reason 2 seemed to few, but 3 was fine. I will happily switch down. Another miscellaneous thing I appreciated was the pretty arbitrary interpolation scheme - so anything can be embedded in a string w/out having to do any crazy hacking. Very convenient.

I’m a little wierded out by this example:


a = [1, 2]
b = ‘cat’
a.each {|b| c = b * a[1]}
a → [1, 2]
b → [2

Which if I’m understanding correctly means that the local variable b, is simply overwritten by using ‘b’ as the name of the argument in the block. In perl a situation like this would be the equivalent of declaring a new lexical variable b in the argument list which would shadow the lexical b above it. That may take some getting used to.

In general, I’m impressed by the language, I love all the iterators over arrays. I love the usage of blocks in general, it all seems so high order to me and that’s something I can get behind. I am happy to be working in a language in which I’ll be able to use lambda again. Mmmm… lambda… Looking forward to the rest of the book and then onto Rails.

← newer Breakfast Links  ↑  Yahoo Pipes: Regex Module older →

TwitterCounter for @nybble73