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
    // 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  


( 9 hisses — Hiss at me! )
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


Edited at 2009-09-26 05:16 am (UTC)
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
  # bar

Edited at 2009-09-26 06:08 am (UTC)
Sep. 26th, 2009 08:18 am (UTC)
this. I always use } else { on one line.
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
    # different stuff

You didn't actually ask anyone to share their code preferences, did you? :)
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?
Sep. 26th, 2009 04:56 pm (UTC)
Wait... you guys really don't know why using tabs can be an issue?
And you've been using computing equipment HOW long now?

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

if [ condition ]

? No? Funny?

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
Powered by LiveJournal.com
Designed by Paulina Bozek