45
madcj
7y

Let me see 🙅

Comments
  • 2
    I immensely dislike 2.
  • 15
    I immensely dislike 1.

    2 forever.

    I feel like this issue has been posted here a few times before.
  • 3
    @corscheid probably. it goes in the same folder as tabs vs spaces and 'gif' vs 'jiff'
  • 2
    @CrashOverride yeah. I'm still on the fence about tab vs. spaces. I just hate for them to be mixed in one file or project. Let it all be spaces or let it all be tabs. Of the same width.

    Also, only hipsters true to the creator's will say jiff.
  • 4
    @corscheid I have said it once and I will say it again. It sucks when creators of things are wrong.
  • 0
    @projektaquarius 😂 I suppose that's true.
  • 2
    Back to OP tho. To those people like @projektaquarius who would rather...

    if (foo)
    {
    bar();
    }
    else
    {
    baz();
    }

    ...than...

    if (foo) {
    bar();
    } else {
    baz();
    }

    ... my question is, Why? What makes 1 better and what reasons are there to hate on 2? I love 2. (I originally was gonna make a derpy array index out of bounds joke because of 1,2 instead of 0,1 but meh. :P)
  • 1
    1 is easier on the eyes. More spread out so easier to see and read. I am lazy, I don't want to have to read extra words when all I want to know is where the damn loop starts.
  • 1
    @projektaquarius I use newlines for separating blocks and consistent indentation for knowing where stuff starts and ends. I otherwise love the compact nature of whatever the other version is. Why have an if else-if else-if else statement take up an entire page scroll when it could take up a quarter?
  • 4
    I mix them 😈
  • 4
    It's really interesting reading different opinions on this one..

    Personally, I find having the opening bracket on the same line as what defines it's contents makes it easier to see not only where it starts, but also what it does.

    Either way, all things considered I also like using ternary operators for the quick if/else checks. Less lines makes for quicker reading.
  • 0
    I just think you should be able to draw a straight line between each opening brace and each closing brace.

    The real question is why do those who like to scrunch up their code not also put the close brace at the end of the last line just like they put the opening brace at the end of the line?

    If you want your code scrunched up so that you can see more code at the same time on a screen then why aren't you consistent?

    I mean this seriously by the way. This isn't meant as a troll, I would genuinely like to hear the rationale behind it.

    I appreciate you do things differently to me, I just don't understand why. It looks like habit because that was how the K&R book did it. But we don't have tiny screens any more, so why continue doing it?
  • 0
    Depends on the language I am using. With PHP (and frameworks as symfony, laravel, etc), I will use the first. With java, the second.
  • 3
    Sorry... Is this the post where we talk about the difference between tab and four spaces?
  • 1
    @jacojvvdev 😱😥
  • 1
    @Wildgoose

    if (foo) {
    | bar();
    } // put this here for the exact same
    reason as you. But instead, I like drawing a straight line between the first character of the statement that opened a brace, to the closing brace.
  • 0
    It doesn't matter and u know it 😒
  • 0
    @sylflo this. My code all is of the 2nd style but in a php project I'm collaborating on, I'm using 1st style because that's how his code is.

    Consistency has precedence.

    Mixing them is evil unless the manner of mixing is consistent. e.g., ...

    class Foo extends Bar
    {
    public void baz()
    {
    quux();

    if (moo) {
    blah();
    } else {
    other ();
    }
    }
    }

    ...such as all class and methods use style 1 but all if, for, while, etc. use style 2. I think this is acceptable.

    EDIT: WTF, devRant keeps un-indenting my if statement.
  • 0
    My team has the both types of people and we all refuse to adapt.
    :/
  • 0
    @corscheid I think 1 is significantly easier to see where statements begin and end when you see code that has lots of nested if statements - at a glance you can immediately see this tabbed section comes under this if, and this one this if. I also think longer multiline conditional statements look cleaner this way too because it doesn't merge into the code
  • 1
    @JamiePed I think 2 looks just as good to my eyes with many nested ifs. I have many files with a whole bunch of these. Indentation is everything. I don't usually have very long conditions. If I ever split mine into multiple lines of the condition, yeah it would probably look a little weird. But as long as it is indented consistently it's not bad. I'm just so used to using and looking at 2, it just feels so strange and a waste of lines just to put only '{' on its own line. Sure you could say this about '}' on its own line, but the point with that one is, it aligns to the first char of the statement. '{' would IMO redundantly also align to the same on its own line.
  • 1
    @projektaquarius 2 puts the whitespace in the right spots though. It's confusing having an almost blank line between if statement and content.
  • 1
    @TheInitializer I disagree. I find it much more difficult to spot loops, conditionals, etc. at a glance in 2.
  • 1
    @projektaquarius with 1, while quickly skimming the code it appears that the if statement is its own line of code (not related to the content) which is confusing.
  • 0
    @TheInitializer I still disagree but to each their own.
  • 1
    I like JS minifiers 😆 so what do you think about this:
    if(s){t.d(z);t.o();}else{t.e(z);f();}
  • 3
    @Wildgoose I like 2, and I don't put the closing brace at the end of the last line because I like having the statements themselves on their own lines.

    Plus, if it's a long statement for some reason, you don't have to look at the end of the line to see if it's closed, you just look directly below.
    (Sorry for the double reply, the app glitched for me and wasn't loading my replies)
  • 0
    @TheInitializer That's a fair point - however I always put a blank line after a sequence of close braces, so it doesn't affect me.

    We have big monitors now, might as well use them! 🤓
  • 0
    @Wildgoose I don't 😔
  • 1
    Honey! Make me some popcorn and grab me a beer, I'm watching programmers having a brawl on the internet
  • 1
    @perfectdark no. A brawl is tabs versus spaces.
  • 0
    That more better @Khundzaka
  • 2
    @Khundzaka, minified code doesn't count here, this is about how you write it beforehand..

    @Andre, ++ for not only sharing my name, but also mentality. Lol. (:
  • 0
    @flonach

    int main(int argc, char **argv) {
    // this one.
    }

    //Who TF does the following??
    int
    main(int argc, char **argv) {
    /* Are return types not part of
    * the function signature anymore?
    */
    }
  • 0
    I use the first one for PHP, second one for JavaScript, idk why haha
  • 0
    I use the first one so much, that when someone forces me to use the second when writing js, I cry.
Add Comment