Author Topic: Programming Megathread  (Read 143528 times)

if google has a style guide for a language, that's usually the one I use
one exception is python, where I follow PEP 8 insteadshouldn't you use Event.preventDefault() for that? it's a lot more intuitive...

I looked at Google's c++ style guide and was disappointed at their ugly bracket style

Code: (Google) [Select]
namespace X {
inline namespace Y {
  void foo();
}
}

is so much worse than

Code: (Not Google) [Select]
namespace X
{
inline namespace Y
{
void foo();
}
}
« Last Edit: February 08, 2016, 10:59:45 PM by devildogelite »

I personally can't stand the second way
to each his own ¯\_(ツ)_/¯

I just use cs instead of brackets.

I personally can't stand the second way
to each his own ¯\_(ツ)_/¯

Agree. He kind of picked a bad example, IMO inline braces are significantly prettier.

i can't stand either
Code: [Select]
namepsace X
{
    inline namespace Y
    {
        void foo();
    }
}
for the win

when I'm just skimming, the first brace being on its own line confuses the heck out of me. I always see it as a blank line

It just makes the code look too spread out for me. If I see a function declaration, I know that the next line is going to be the contents of that function. Especially as proven by the indentation. I also don't like four-space or tab-style indentation. One or two spaces keeps it nice and compact: you can easily distinguish indentation levels and you aren't wasting a ton of space on the left side. It's especially annoying when you're being mindful of the width of your code and 1/3 the available space is occupied by whitespace on each line.

i can't stand either
Code: [Select]
namepsace X
{
    inline namespace Y
    {
        void foo();
    }
}
for the win

That's what I meant to do actually, didn't notice I screwed up the second one.

Code: [Select]
if difficulty == "easy" {randomize();randval = irandom_range(0,19);while randval = old_randval {randomize();randval = irandom_range(0,19);}showquestion = question[randval];old_randval = randval;} else if difficulty == "medium" {randomize();randval = irandom_range(20,39); while randval = old_randval {randomize();randval = irandom_range(20,39);} showquestion = question[randval];old_randval = randval;}


if difficulty == "easy" {
  randomize();
  randval = irandom_range(0,19);
  while randval = old_randval {
    randomize();
    randval = irandom_range(0,19);
  }
  showquestion = question[randval];
  old_randval = randval;
}
else if difficulty == "medium" {
  randomize();
  randval = irandom_range(20,39);
  while randval = old_randval {
    randomize();
    randval = irandom_range(20,39);
  }
  showquestion = question[randval];
  old_randval = randval;
}


Made it more readable for you. But what the hell is it?

Code: [Select]
if difficulty == "easy" {
    randomize();
    randval = irandom_range(0,19);
    while randval = old_randval {
        randomize();
        randval = irandom_range(0,19);
    }
    showquestion = question[randval];
    old_randval = randval;
}
else if difficulty == "medium" {
    randomize();
    randval = irandom_range(20,39);
    while randval = old_randval {
        randomize();
        randval = irandom_range(20,39);
    }
    showquestion = question[randval];
    old_randval = randval;
}
was that intentionally messed up, as a joke, since we're talking about formatting? or what

also I was wondering what language used brackets for if statements but didn't require parentheses around the condition, apparently it's that game maker thing, and that's kinda gross
Made it more readable for you. But what the hell is it?
:(



you people can nitpick about where the first brace should go and all, but the people who really need to go to hell are the people who pile all their code in one line

you people can nitpick about where the first brace should go and all, but the people who really need to go to hell are the people who pile all their code in one line
speaking of
i rewrote a static, 1,356 character long command today
https://github.com/TheBlackParrot/strimmer-redesign/commit/02efbf838d9b1a00dc9187677aea2f91b164ead0#diff-f16bfd5b13b9960879905cedef55d6c1L354