?

Log in

No account? Create an account

Earlier Spew | More Recent Spew

On Religion

Want to spark a religious debate amongst software developers? Which is the one true faith?
// Choice 1
if (condition) {
    // statements
}
else {
    // statements
}

// Choice 2
if (condition)
{
    // statements
}
else
{
    // statements
}
The only reason wars have not been fought over this is that war is so inefficient.

I had to review some code prior to a change and I looked at the history of the file in Source Safe before checking it out. It read like a history of hostilities between two sides of a hot religious or political debate. One person would use the first method above, the next would use the second. Some people indent by 2, others by 3, 4 or 5 spaces. Some always use // to comment, others always use /* */. Some use tabs to indent while others use spaces.

I, of course, adhere to the oldest, truest faith: I tailor my new code to match that of the code around it. That way, no one can blame me when the inevitable Code Wars break out.

Well, except for that tab/spaces thing. Clearly, coders who use spaces to indent are heretics and destined for coding hell: being frozen for 8000 years only to be revived to modify COBOL programs to be Y10K compliant. I've been known to convert all mutli-space indents to tabs before checking code into source control.

I mean, come on. There's heresy and then there's insanity.


Atheists Are People, Too  Antispam  

Comments

( 9 hisses — Hiss at me! )
etherial
Sep. 26th, 2009 05:16 am (UTC)
Clearly I should move to HOTlanta
I've never seen anyone (other than me) use Choice 1.

I tend to use /* */ because I tend to not know how long the comment will be and I tend to code/comment in stream of consciousness. That, and // only looks good in a fixed-width font so I can put layers of comments

...//.like
..//..this
.//...one
//....here

Edited at 2009-09-26 05:16 am (UTC)
joeylemur
Sep. 26th, 2009 06:07 am (UTC)

if (condition) {
  // foo
} else {
  // bar
}


Which works well, since I write in Ruby mostly:


if condition then
  # foo
else
  # bar
end



Edited at 2009-09-26 06:08 am (UTC)
thespian
Sep. 26th, 2009 08:18 am (UTC)
this. I always use } else { on one line.
oxlahun
Sep. 26th, 2009 01:01 pm (UTC)
If I'm working in someone else's code, I usually try to match their style. When I'm writing my own, I tend to favor something rather like your Choice 2, except that I also indent the braces.
# Indent using a single tab.
if ( condition )
    {
    # stuff
    }
else
    {
    # different stuff
    }

You didn't actually ask anyone to share their code preferences, did you? :)
dorsai
Sep. 26th, 2009 01:51 pm (UTC)
The only reason wars have not been fought over this is that war is so inefficient.

Well, and the whole physical exertion aspect of it as well. :)

In other news, I'm with you on the whole tabs vs spaces thing. There's someone in my office who not only uses spaces, but four of them to indent lines. How ridiculous is that?
(Anonymous)
Sep. 26th, 2009 04:56 pm (UTC)
Wait... you guys really don't know why using tabs can be an issue?
REALLY?
And you've been using computing equipment HOW long now?
-jp

hint: tab < x'20'
hoo
Sep. 27th, 2009 05:46 pm (UTC)
Fi! Fi I say!
hoo
Sep. 28th, 2009 02:30 pm (UTC)
As in Bash?

if [ condition ]
then
else
fi

? No? Funny?

*crickets*
ian_smith
Oct. 2nd, 2009 01:18 am (UTC)
Ummm... I often use spaces because I think tabs are too long. I only want two spaces.

And if you just adjust the tab size in your editor, it won't look right on other peoples machines and other peoples tabs look like crap on yours.

Whats wrong with two spaces instead of a tab?

I used to write with choice one, but now can't stand it and write with choice 2. A friend of mine that I programmed with used to do the same, until I started writing code and he switched to make life easier, but now he can't stand to see choice 1 either and changes it when he comes across it.
( 9 hisses — Hiss at me! )

Latest Month

April 2017
S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829
30      
Powered by LiveJournal.com
Designed by Paulina Bozek