Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

We use a standard because if someone has autoformatting enabled and replaces a } somewhere in your code it can screw up the whole diff in subversion and makes blaming code very difficult.

Adbot
ADBOT LOVES YOU

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Dooey posted:

Am I the only one who finds reading code in mixed styles not a big deal? I always use the same style for my own code, but at work we all have different styles and when I read other peoples code I have no problems at all.

I actually kind of like it in a way because I can generally tell who on my team has written a particular piece of code.

Profane Obituary!
May 19, 2009

This Motherfucker is Dead

Scaramouche posted:

I actually kind of like it in a way because I can generally tell who on my team has written a particular piece of code.

this is what blame is for.

Impotence
Nov 8, 2010
Lipstick Apathy

Profane Obituary! posted:

this is what blame is for.

Assuming you use version control at all.

Zamujasa
Oct 27, 2010



Bread Liar
Yeah, little quirks like that are actually useful. I can usually guess who wrote what because of subtle distinctions in syntax and spacing.

Well, those things and the fact that one of the former programmers (who quit years ago) still has heartbeat emails to his long-deleted account in the every-20-minutes cron script, among a lot of other "features" like that. For example, the head guy likes using "$verified = 'good';" (and other strange declarations that are never, ever referenced again), other people like using actual true/false booleans, etc.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

BigRedDot posted:

At my last job the mish-mash of styles and conventions was so terrible that I eventually transcended past the point of ego. I would have adopted any scheme whatsoever, even if I personally hated it, so long as every loving one else did too.

This is something Microsoft did a really good job on with C#. They came out of the gate with a style-guide so any bullshit bracing arguments can just be trumped with "follow the MS standard". It (usually) works.

Profane Obituary!
May 19, 2009

This Motherfucker is Dead

Monkeyseesaw posted:

This is something Microsoft did a really good job on with C#. They came out of the gate with a style-guide so any bullshit bracing arguments can just be trumped with "follow the MS standard". It (usually) works.

Python +pep8 makes this so nice too

leterip
Aug 25, 2004
Golang has a gofmt command that automatically reformats code so you can just run it in a pre-commit hook and never even think about it ever again.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Monkeyseesaw posted:

This is something Microsoft did a really good job on with C#. They came out of the gate with a style-guide so any bullshit bracing arguments can just be trumped with "follow the MS standard". It (usually) works.

Plus you can run FxCop on it

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

leterip posted:

Golang has a gofmt command that automatically reformats code so you can just run it in a pre-commit hook and never even think about it ever again.

Of course, for you to be "thinking about it" you'd have to find someone else that uses Go in the first place.

Ogive
Dec 22, 2002

by Lowtax

Zamujasa posted:

Yeah, little quirks like that are actually useful. I can usually guess who wrote what because of subtle distinctions in syntax and spacing.

Well, those things and the fact that one of the former programmers (who quit years ago) still has heartbeat emails to his long-deleted account in the every-20-minutes cron script, among a lot of other "features" like that. For example, the head guy likes using "$verified = 'good';" (and other strange declarations that are never, ever referenced again), other people like using actual true/false booleans, etc.

Style doesn't matter as long as it's used consistently. Personally, my style preference is to prefer the style of whoever is writing my paycheques. Nobody is going to live or die if an opening brace is on the same line or the next line as an if statement.

The function of style is to enable a group of people to easily read the same set of code in minimal time. It doesn't even really matter what the style is. Depending on style idiosyncracies when you can just fire off a p4-blame with the press of a button is like saying cars are stupid because they don't have hooves.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Ogive posted:

Nobody is going to live or die if an opening brace is on the same line or the next line as an if statement.

I don't think you've met many of the programmers I know.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
If you wrap your lines at 80 characters I literally hate you irl

Milotic
Mar 4, 2009

9CL apologist
Slippery Tilde
Arguing about coding style is for petty people. More cultured, intelligent people argue about the singleton pattern.

(I have had an almost blazing row about this in the past)

Zamujasa
Oct 27, 2010



Bread Liar

Ogive posted:

Depending on style idiosyncracies when you can just fire off a p4-blame with the press of a button is like saying cars are stupid because they don't have hooves.

Again, the only "blame" in this system is the owner of the file, because we don't use version control. And the owner of the file is always the same account, because while we all have different logins ("mainacct_ouracct"), it effectively logs us in as mainacct.

It's not that I want to rely on it, it's that I have to. This code has been muffed up by at least 8 different people over its lifespan and the style they use is the only real hint to how things work and what their variables are named like. Hell, even in the most recent stuff it's still similar to "pro_mod_someThingHereThere" and "pro_mod_someThingHere_now", inconsistent all over the place.


quote:

If you wrap your lines at 80 characters I literally hate you irl
I don't wrap at 80 unless I'm writing comments, and even then it's really more around 100-120 characters. Easier to read that way, I've found.

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug

Aleksei Vasiliev posted:

If you wrap your lines at 80 characters I literally hate you irl

I lost marks in first year for not doing this. I guess the professor still marked our code on an 80x25 terminal.

TheBlackVegetable
Oct 29, 2006

Zamujasa posted:

Again, the only "blame" in this system is the owner of the file, because we don't use version control. And the owner of the file is always the same account, because while we all have different logins ("mainacct_ouracct"), it effectively logs us in as mainacct.

It's not that I want to rely on it, it's that I have to. This code has been muffed up by at least 8 different people over its lifespan and the style they use is the only real hint to how things work and what their variables are named like. Hell, even in the most recent stuff it's still similar to "pro_mod_someThingHereThere" and "pro_mod_someThingHere_now", inconsistent all over the place.

I don't wrap at 80 unless I'm writing comments, and even then it's really more around 100-120 characters. Easier to read that way, I've found.

I just have to say, for those that don't use any sort of version control - as long as it doesn't get you fired - please, for the love of god and the sane companies you'll work for in the future, learn and use Mercurial, Git, Subversion, whatever, at least just on your own computer. The only people who don't love version control are those still ignorant of how much of a sanity saver it is, and those that shouldn't be anywhere near source code.

Lurchington
Jan 2, 2003

Forums Dragoon

Aleksei Vasiliev posted:

If you wrap your lines at 80 characters I literally hate you irl

pep8 supremacy :smug: 79 characters
I'm not sure if you're saying that's too few or too many characters to wrap at

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Good luck punching 80 characters on a card- where the hell do you plan on putting the identification sequence? Most compilers don't even accept more than 72 characters. I suppose next you guys are going to tell me you waste space on multi-character variable names.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Lurchington posted:

pep8 supremacy :smug: 79 characters
I'm not sure if you're saying that's too few or too many characters to wrap at

I'm a more advanced Python programmer than I am a Java programmer, but it seems like it's a lot easier to keep your lines short and readable in Python than it is in Java.

Also, PEP8 supremacy!

qntm
Jun 17, 2009

Thermopyle posted:

I'm a more advanced Python programmer than I am a Java programmer, but it seems like it's a lot easier to keep your lines short and readable in Python than it is in Java.

Also, PEP8 supremacy!

Yeah, Java is so verbose that there's no point in trying to keep your lines below any arbitrary maximum width. Just use word wrap. Oh, wait!

muskrat
Aug 16, 2004
Ran into this earlier. No additional context is needed, the readability speaks for itself :|

code:
            $css .=  "}\n";
            $css .=  "@-webkit-keyframes $type" .$i. "\n";
            $css .=  "{\n";
            $css .=  "0% {opacity:0;}\n";
            $still0 = ($i - 1) * $percentInc;
            $not0 = $still0 + $nextElement;
            $nextNot0 = ($i) * $percentInc;
            $next0 = $nextNot0 + $nextElement;
            $css .=  "$still0% {opacity:0;}\n";
            $css .= getAnimationCSS($percentInc, $not0, $elementArr[$i-1]);
            if ($nextNot0 < 100)
            {
                $css .= "100% {opacity:0;}\n";
            }
            $css .= "}\n";

Impotence
Nov 8, 2010
Lipstick Apathy

Internet Janitor posted:

Good luck punching 80 characters on a card- where the hell do you plan on putting the identification sequence? Most compilers don't even accept more than 72 characters. I suppose next you guys are going to tell me you waste space on multi-character variable names.

i, ́, í, î, ï are all perfectly valid variable names and I see them used far too often.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Lurchington posted:

pep8 supremacy :smug: 79 characters
I'm not sure if you're saying that's too few or too many characters to wrap at
too few. I use 100 characters and it works far better than 80. It's really easy to pass 80 characters on a line but pretty rare for me to pass 100.

Also I mainly program on a 16:10 screen so gently caress using only the far left of it.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Do you really only have one file open at a time?

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Otto Skorzeny posted:

Do you really only have one file open at a time?
I have multiple files open at any one time in my tabbed IDE.

I almost never deal with diffs/merging since I'm only working on my own projects.

tripwire
Nov 19, 2004

        ghost flow

Aleksei Vasiliev posted:

I have multiple files open at any one time in my tabbed IDE.

I almost never deal with diffs/merging since I'm only working on my own projects.

Split that panel! Feel the productivity blasting you to your core

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
79 characters is silly and it seems transparently inspired by emac's stupid behavior of adding the \ and empty line when a newline is in the last column. Which reminds me, controversial opinion alert: TTY simulators suck, fixed-width fonts suck.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Mustach posted:

fixed-width fonts suck.
:stare:

you're the horror.

TasteMyHouse
Dec 21, 2006

Mustach posted:

fixed-width fonts suck.
what

fixed width fonts are amazing

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
How do you get things to line up nicely with variable-width fonts?

qntm
Jun 17, 2009

Internet Janitor posted:

How do you get things to line up nicely with variable-width fonts?

Variable-width spaces, obviously

Shavnir
Apr 5, 2005

A MAN'S DREAM CAN NEVER DIE

Aleksei Vasiliev posted:

I have multiple files open at any one time in my tabbed IDE.

God I wish I had a real IDE to work with :( The closest I get is Understand.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

qntm posted:

Variable-width spaces, obviously

May we all shed a collective tear for Python and COBOL programmers.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
I think that monospace fonts are an eyesore. I sometimes think that people stick to them just so they can pretend their code is some kind of WYSIWYG and waste time with valueless formatting like this:
code:
{
    int  mybutt;
    char myass;
    etc  otherthings;
}
or even worse, this:
code:
struct flubber *a_dumb_person_did_this(int a, int b,
                                       long g, shlong s,
                                       derpaderpadoo z);

Internet Janitor posted:

How do you get things to line up nicely with variable-width fonts?
Consistent indentation is so much more important that lining up just about anything else offers no improvement to code readability. "Looks slightly nicer" just doesn't compel me to use fonts that I don't like and/or bother my eyes, spend time and effort counting spaces (and then re-doing it if another declaration is added to the group), or locking myself into a text editor that I don't like just so it can do the formatting for me. A specialized tool like gofmt is better than having an editor do it, but formatting like the declaration group above is a (very small) disincentive to using better fonts, because now the formatting looks kind of goofy in anything that isn't monospace, whereas this would look fine and readable on any configuration:
code:
{
    int mybutt;
    char myass;
    etc otherthings;
}

struct flubber *a_dumb_person_did_this(
    int a, int b,
    long g, shlong s,
    derpaderpadoo z);

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

code:
struct flubber *a_dumb_person_did_this(int a, int b,
                                       long g, shlong s,
                                       derpaderpadoo z);
is much more readable to my eye then this:


code:
struct flubber *a_dumb_person_did_this(
    int a, int b,
    long g, shlong s,
    derpaderpadoo z);

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
code:
struct flubber *a_dumb_person_did_this(int a, int b,
                                       long g, shlong s,
                                       derpaderpadoo z);
unpleasant, unless the grouping of (a and b) and (g and s) is compelling for some reason. Although then still not good, because the ); ought to be on its own line in the case where multiple lines are spanned.

code:
struct flubber *a_dumb_person_did_this ( int a,
                                         int b,
                                         long g,
                                         shlong s,
                                         derpaderpadoo z
                                         );

struct flubber *a_dumb_person_did_this (
    int a,
    int b,
    long g,
    shlong s,
    derpaderpadoo z
);

struct flubber *a_dumb_person_did_this (
    int a, int b, long g, shlong s, derpaderpadoo z
);

struct flubber *a_dumb_person_did_this (int a, int b, long g, shlong s, derpaderpadoo z);
all fine.

Hammerite fucked around with this message at 17:24 on Jul 30, 2011

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Thermopyle posted:

is much more readable to my eye then this:
How do you quantify the difference?

I mean, this isn't something that I'm really mad about, and I know that plenty of people disagree with me, but today I am feeling convinced that monospace rules the coding world more due to the influence of history than any true benefits.

Hammerite posted:

unpleasant, unless the grouping of (a and b) and (g and s) is compelling for some reason.
Agreed, but it's something I see a lot, so I stuck with it for the alternative, too.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Mustach posted:

code:
    int mybutt;
    char myass;
    etc otherthings;
I do this

in a monospaced font because I'm not insane

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

code:
struct flubber *a_dumb_person_did_this ( int a,
                                         int b,
                                         long g,
                                         shlong s,
                                         derpaderpadoo z
                                         );
Actually, that's the way I prefer it.

Mustach posted:

How do you quantify the difference?

How do you quantify that red is your favorite color instead of green? It just looks better and easier to read to me.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply