Re: This sort of thing might push me to Scala

Mathieu Bouchard <matju-i8w/[email protected]> Thu, 17 Dec 2009 19:35:38 -0500 (EST)
Newsgroups gmane.comp.programming.language-of-the-year
Message-ID <[email protected]>
On Fri, 18 Dec 2009, Gordon Milne wrote:

> I see one useful statement (new MethodEditor()) in a sea of boilerplate. 
> How should I express that? 1 useful line in 7? 4 useful tokens out of 
> 24(ish). Lines was a convenient place holder for my initial rant. It 
> isn't a useful one for you. How do you suggest I talk about this kind of 
> useful code versus boiler-plate issue?

Lines can be a useful measure for me but it doesn't mean the same thing as 
it does to you. Whitespace that doesn't follow the rules can tell a story 
that the non-whitespace doesn't. Whitespace that follows the rules only 
tells you what you already know. I use whitespace to downplay certain {} 
and, by contrast, to emphasise some other {}. If all the {} are formatted 
alike, you can't downplay the {{}} that you wish wouldn't stand out so 
much.

In your case, you have to use any whitespace-independent method. when you 
think about how to count, think about whether the counting counts what you 
want it to count and, as importantly, doesn't count what you don't want it 
to count. That's all. Here are a few possibilities:

   1. number of characters it would take if there were as little whitespace
      as the compiler can accept

   2. number of non-whitespace characters

   3. number of tokens

   4. number of grammatical structures
      (e.g. while(){} could count as a single thing)

It depends on what your æsthetic is... but chances are that if you have a 
group dictating you a certain place where to put the newlines, then that 
group also wants you to use JAVA at all costs.

Besides, if what you wanted to write is really:

   runWithWaitCursor { new MethodEditor(title, file) }

then what about Ruby, which allows you to write

   runWithWaitCursor { MethodEditor.new(title, file) }

the other piece of the code would look like:

   def runWithWaitCursor
     LsWaitingCursor.new(frame)
     begin yield; ensure waitingCursor.disable end
   end

I can't say about Scala, though, cause I know nothing about it.

  _ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801