From: "David A. Black" Date: 2008-06-01T04:42:44+09:00 Subject: Re: splitting help needed Hi -- On Sat, 31 May 2008, Rick DeNatale wrote: > On Sat, May 31, 2008 at 8:11 AM, David A. Black wrote: >> Hi -- >> >> On Sat, 31 May 2008, Dave Bass wrote: >> >>> But this is Ruby, not Perl! :-D >>> >>> Coming from 10 years of Perl coding, I wish Ruby were *less* Perl-like, >>> as it can get confusing, especially when you're working in both >>> languages at the same time. >> >> I remember someone (I'm too lazy to look it up) saying long ago that >> while Ruby often strikes one as Perl-like initially, it actually is >> much less so than it appears at first. I think that's true. Perl also >> has more of a tradition of deliberate code obfuscation, though of >> course it's generally done in a playful way. Obfuscated Ruby code >> always looks kind of ridiculous to me, as Ruby really militates for >> a certain clarity, and there's such a tradition of love of clean code >> in the community. > > Some of the features Ruby 'stole' from Perl are things I use fairly > regularly, for example the if/unless/while statement modifiers. > > Others such as all the special and sometimes magical global variables > and pseudo-variables I don't find useful at all, and I don't see them > discussed much here. They're probably quite helpful if you are using > Ruby in the same kind of swiss-army knife adjunct to shell commands > way that perl is often used by wrapping a 'one-liner' in one of the > various loops implied by different command line options like i, n, > and p, but I never use that. > > Regular expressions are really a sub-language of their own. Ruby has > some extensions like %r{} which I think make them a little clearer. > >> For the first RubyConf, we were going to have a "Code De-Obfuscation" >> contest, since the idea of an obfuscation contest in Ruby seemed so >> against the grain of what people loved about the language. We got as >> far as getting some obfuscated contributions, ripe for de-obfuscation >> (including one from Dave Thomas), but unfortunately the timing of that >> conference -- October 2001 -- sapped some of our time and energy and >> that contest was one of the things that fell by the wayside. > > That sounds like a great idea. I wish that there were some kind of > anti-code-golf contest, where the objective was maximum > clarity/expressiveness rather than compactness. The problem is that > it's impossible to measure the former objectively, compared to 32 vs. > 33 character comparisons. I like code golf, as long as it's clear that it's code golf -- that is, a brain-teaser/exercise with the goal of coming up with the minimum number of "strokes". I've learned an awful lot about both Ruby and Perl by doing that. I don't consider it any more closely related to real code production than, say, abdominal crunches are to baseball. It's just a mind-stretcher. I suspend aesthetic judgment on code in code golf contests because I assume it isn't really being held up as anything other than what it is (maximally compressed). Then again, there are certainly cases of quasi-golf-like code that people just write, and that can be a problem.... The de-obfuscation contest idea was kind of a superset of what you're describing: looking to transform code that was opaque and badly written in various ways into something more clear and expressive. The de-obfuscations were going to be judged by a panel, as I recall, since as you say there's no automatic way to judge them. David -- Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin See http://www.rubypal.com for details and updates!