elfs: (Default)
[personal profile] elfs
So, in my neverending quest to Learn New Stuff, I've been using my self-development time to teach myself Ruby, a new high-level programming language that was popular for a long time in Japan (and is often thought of as "the Japanese version of Perl"), but is now making its way into the U.S., mostly due to the success of Rails, an incredibly powerful application framework that makes shake-and-bake HTML and WSDL businesses easy.

One of the things that many programming languages try to hit is the "sweet spot" between obviousness and repetition: on the one hand, it should be absolutely clear to anyone even vaguely familiar with the language what is happening, and on the other, the programmer should never have to repeat himself or busy himself with excessive boilerplate.

Some languages, trying to hit this mark, are a bit verbose. Python is this way, in that it requires that every object use an explicit parameter, self, for every instance method and every instance variable. Python also creates explicit loop and iterator objects that make sense because everything is spelled out in the expression.

Ruby, in contrast, is as terse as can be, creating lisp-like implementations of iterated expressions that make my brain hurt. I've just gotten to the section on iterators and I stared at the the example (scroll down to the section "Ruby Compared with C++ or Java") for half an hour before it finally became clear what was happening.

It's just a difference of language: instance variables have an @ symbol in front of them, but instance methods don't. They're unadorned. Python is a language built around the idea that almost everything is a reference; Ruby around the idea the almost everything is a message. In Python, if you say object.foo, Python returns the value of the thing foo, which, if it's not a native value, is a reference to some other thing. In Ruby, if you say object.foo, it's a message to object saying "do message foo", which some rational defaults built into the root object type.

It's just that example, in which the yield message is used twice, refers to default behavior not obvious in the example, and contains no mention of the local variable which it is quite obviously using, that drives me crazy. When I finally understood it, I felt that mental twinge I get when trying to work in lisp. Either I have to work a whole lot more with this, in which case I will be a whole lot smarter when I'm done, or I'm never going to grasp it.

Date: 2005-12-02 02:56 am (UTC)
From: [identity profile] neowolf2.livejournal.com
Maybe you should just learn Common Lisp instead.

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 31st, 2025 02:23 am
Powered by Dreamwidth Studios