From: JamesBritt Date: 2002-09-07T03:03:44+09:00 Subject: RE: Larry Wall's comments on Ruby > The main problem I see with Ruby is that the Principle of Least Surprise > can lead you astray, as it did with implicit lexical scoping. The > question > is, whose surprise are you pessimizing? Experts are surprised by > different > things than beginners. People who are trying to grow small programs into > large programs are surprised by different things than people who design > their programs large to begin with. This may have to do with the granularity of surprise. For example, if I use an object n a string context (e.g., puts my_obj), I would be surprised if there wasn't an implicit call to to_s or to_str. An I believe that is how Perl does it; the parser "knows" the context, be it scalar, or vector, or whatever, and does The Right Thing. On the other hand, I tried testing some blogging code on a different box, and was "surprised" it failed. (Turns out the code needs to know if it is run under CGI, or mod_ruby, or command line.) But I'd be *really* surprised if anyone thought this point was the responsibility of anyone but the developer. I'd be interested to know if anyone was surprised by something in Ruby when they moved a small app to a large app. The POLS is sort of an 80/20 thing. Certain things (like some_string[x] returning a number, not a character) surprised me, but by and large the least surprise grows from a consistency of design principles, not from Matz's mood on any given day. > > For instance, I think it's a violation of the Beginner's Principle of > Least Surprise to make everything an object. To a beginner, a number is > just a number. A string is a string. They may well be objects as far as > the computer is concerned, and it's even fine for experts to > treat them as > objects. But premature OO is a speed bump in the novice's onramp. " > > Personally, I like Ruby's scoping rules a lot better than Perl's. > > Also, I think that everyting being an object is actually helpful for > beginners - It's much easier to pick up OO programming ideas if you learn > them first, I think. It also tends to make things much more consistent. > > Thoughts? I, too, think it makes more sense to present objects first, then show concrete examples later. Because, later on, if you have various execptions to Everything Is An Object (see Java), you have to mentally track more stuff. So, rather than some possible brief discomfort when learning the language, you have mild discomfort all the time (see Java). I don't think Lary is giving OO newcomers enough credit. James > > Phil >