Introducing Cobra

Gabriel Sechan gsechan at hotmail.com
Wed Jan 2 15:46:17 PST 2008



----------------------------------------
> Date: Wed, 2 Jan 2008 15:36:23 -0800
> From: x at xman.org
> To: kplug-lpsg at kernel-panic.org
> Subject: Re: Introducing Cobra
> 
> Gabriel Sechan wrote:
>> ----------------------------------------
>>   
>>> Date: Wed, 2 Jan 2008 15:01:21 -0800
>>> From: kplug at davidb.org
>>> To: kplug-lpsg at kernel-panic.org
>>> Subject: Re: Introducing Cobra
>>>
>>> On Wed, Jan 02, 2008 at 04:57:05PM -0600, Gabriel Sechan wrote:
>>>
>>>     
>>>> The problem is that its much easier to get whitespace wrong than it is to
>>>> get braces wrong.  For example-  one of my most frequent refactors is
>>>> changing the nesting of a chunk of code-  either moving it into a loop,
>>>> out of a loop, or into a new function. If you use braces, the code will
>>>> work, but may be indented in an ugly matter.  If you do it with
>>>> whitespace, it will be broken.
>>>>       
>>> I would instead argue that this particular example is evidence of why
>>> indent-based blocking is a good thing, rather than bad.
>>>
>>> When I move a block of code in python, it is immediately obvious to me what
>>> kind of nesting change is needed.  It is just a few keystrokes to shift the
>>> block to the right place.  With braces, it is very easy to have them wrong,
>>> but get the indentation right.
>>>     
>>
>> I have never in my life seen the indentation wrong but the braces right.  I have seen the reverse, frequently.
>>   
> You need to get out more. If I had a dime for every time I've seen this
> crud:
> 
> if (blah)
>     doSomething();
>     doSomethingElse();
> 
> In some C code, I'd be retired.
> 

Admittedly a problem, not what I was thinking of in that argument.  C made a mistake, it should have required {} everwhere like Perl does.  Most good programmers use them for every block, even one liners, already.


> You rarely meet programmers who don't consistently indent, but it is
> pretty easy to find a team and/or collection of code that doesn't
> consistently indent.
> 

And?  Someone using 3 spaces vs 4 spaces in separate functions doesn't matter.  So long as its consistant within a block I don't give a shit.  ANd frankly anyone who does needs help, they're way too anal.


> By doing things the way Cobra does (or did ;-), you enforce a
> consistency that ensures people can confidently and quickly read the
> code correctly.

But still leaves open the high probability of getting indentation levels wrong while moving code.  No thanks, I want braces.  Hell, for that matter require both, but braces  have way too much utility to be removed.  Indentations as semanticly meaningful just causes more bugs.


>> You're right, I meant to type auto-shift.  Same issue though-  if your language requires an editor to have a specific tool to avoid a common bug, your language is fatally flawed.  Python isn't even a remote consideration for me due to this.  I've actually rewritten small (
>>   
> Umm... isn't this why people like/use auto-indenting editor for
> languages *other* than Python? This seems like an argument *for* using
> Python, not the other way around.
> 
I think you must have misread something, I don't see where you're getting that logic from.

Gabe
_________________________________________________________________
i’m is proud to present Cause Effect, a series about real people making a difference.
http://im.live.com/Messenger/IM/MTV/?source=text_Cause_Effect


More information about the KPLUG-LPSG mailing list