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
TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
Yeah, honestly this discussion looks an awful lot like

:eng101: "Don't shitpost"
:btroll: "YOU CAN'T TELL ME WHAT TO DO"

Adbot
ADBOT LOVES YOU

Soricidus
Oct 21, 2010
freedom-hating statist shill

Volte posted:

All of his pronouncements were about as high and mighty as "don't play on the freeway"

Idk, about half of them boiled down to "don't write idiomatic code" which is kinda high and mighty iyam

Azerban
Oct 28, 2003



TooMuchAbstraction posted:

Yeah, honestly this discussion looks an awful lot like

:eng101: "Don't shitpost"
:btroll: "YOU CAN'T TELL ME WHAT TO DO"

Your posts will always look like poo poo to someone else. Do whatever you want and gently caress the shitpost haters.

ChickenWing
Jul 22, 2010

:v:

you can take my postfix increment from my cold, dead hands

Depressing Box
Jun 27, 2010

Half-price sideshow.
Can we at least agree on "be consistent"? Whether it's your own coding style, your team's, or a larger standard, pick something and stick with it.

xzzy
Mar 5, 2009

Depressing Box posted:

Can we at least agree on "be consistent"? Whether it's your own coding style, your team's, or a larger standard, pick something and stick with it.

Pretty much. There is nothing worse than doing a pull and looking at some new files only to see the indentation all the gently caress over the place. It triggers a bunch of "do I fix this? do I update my tab preferences? is this a new standard?" type questions and it just pisses me off.

Especially when a standard was agreed upon in a meeting last month and the passive aggressive dissenter keeps on doing things their way and wins by wearing everyone else down. :argh:

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

JawnV6 posted:

Neither does "wait for the TX interrupt bit to be unset" but that generally trips the "no empty loops" condition. But I'm pretty sure breaking that out into
code:
while(true) {
  if(TXREG & TXINT == 0) {
    break;
  }
}
is taking a dump on readability.

That would fail code review at my workplace because it's missing a timeout check for when the hardware breaks and the bit remains stuck.

JawnV6
Jul 4, 2004

So hot ...
... and is that common code structured with the verbose non-empty loop
code:
while(true) {
    if(TX_REG & TXINT == 0) {
        break;
    }
    else if (timeout > TIMEOUT_CHECKS) {
        timed_out = true;
        break;
    }
    timeout = timeout + 1;
}
or something like
code:
while( (TXREG & TXINT != 0) && (timeout++ < TIMEOUT_CHECKS) ) { }
You know, the thing that was actually being discussed? I don't think all the extra flow control gains you anything, but I could see the need to break everything out explicitly if the checks were more complex.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
Completely unrelated, but why do some people...

JawnV6 posted:

code:
while( (TXREG & TXINT != 0) && (timeout++ < TIMEOUT_CHECKS) ) { }

...put spaces between parens like that? That's one stylistic thing I've never really understood; it doesn't improve legibility for me anyway.

Sinestro
Oct 31, 2010

The perfect day needs the perfect set of wheels.

TooMuchAbstraction posted:

Completely unrelated, but why do some people...


...put spaces between parens like that? That's one stylistic thing I've never really understood; it doesn't improve legibility for me anyway.

It makes it easier to keep track of nesting at a glance. Granted, mismatched parens aren't exactly the most insidious kind of typo, but it still makes it clearer at a glance.

Volte
Oct 4, 2004

woosh woosh
I don't actually like that style but I do like it whenever I read id software's C++ code. I like their style but I would hesitate to ever adopt it for my own projects.

xzzy
Mar 5, 2009

The extra spaces feel more legible to me, it seems easier to pick out the tests.

If you're putting spaces around the operator it feels lopsided too. ((maths) && (maths)) looks weird to me, and ((maths)&&(maths)) is even worse.

That said, nested parenthesis are a legibility disaster no matter how you dress it up so I don't sweat the specifics too much.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

xzzy posted:

Your code will look like poo poo to yourself six months from now.

My opinion on my code from six months ago is largely the same was when I wrote it, and my thoughts on code from a few years ago tends to be more along the lines of "oh, I could improve this by doing X" rather than "wow this is garbage".

I've never understood why some programmers apparently flop instantly from loving the code they wrote to hating it as soon as it exits their short-term memory.

brap
Aug 23, 2004

Grimey Drawer
It's kind of a problem that programmers knee-jerk rage about code that they don't understand/recognize at first glance.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

fleshweasel posted:

yes, we can tell now that the "and" heuristic is not that useful if you contrive your description of the code.

code:
int x = 4;
Allocate an integer AND name it x AND set its value to 4 :smug:

qntm
Jun 17, 2009

xzzy posted:

Your code will look like poo poo to yourself six months from now.

I have never had this problem.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Plorkyeran posted:

My opinion on my code from six months ago is largely the same was when I wrote it, and my thoughts on code from a few years ago tends to be more along the lines of "oh, I could improve this by doing X" rather than "wow this is garbage".

I've never understood why some programmers apparently flop instantly from loving the code they wrote to hating it as soon as it exits their short-term memory.

I don't hate the code I just wrote, but I do fall out of love with it quickly; if I'm still chuffed about the code I wrote then I overlook its flaws or resist removing it even when other evidence suggests a different direction.

Saying you hate code you wrote six months ago is a way to avoid the sunk cost fallacy.

nielsm
Jun 1, 2009



I have the opposite problem. I've had a burnout on programming, getting better still not entirely over it, and sometimes when I read my old code I end up amazed that I ever managed to write something that good. It's probably nothing amazing compared to what else is out there, but far better than what I can imagine myself coming up with today.

Soricidus
Oct 21, 2010
freedom-hating statist shill
sometimes, on the internet, people make extreme statements that are not wholly true, for rhetorical or comedic purposes. for example, they may claim that a piece of code they wrote 6 months ago makes them scream out loud or feel physically sick, when in reality it merely causes them to frown slightly and think about how they'd write it today.

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that

xzzy posted:

That said, nested parenthesis are a legibility disaster no matter how you dress it up so I don't sweat the specifics too much.

Every language should have an equivalent to the haskell $ operator.

Thermopyle
Jul 1, 2003

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

Soricidus posted:

sometimes, on the internet, people make extreme statements that are not wholly true, for rhetorical or comedic purposes. for example, they may claim that a piece of code they wrote 6 months ago makes them scream out loud or feel physically sick, when in reality it merely causes them to frown slightly and think about how they'd write it today.

This is the best analysis I've ever read.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

TooMuchAbstraction posted:

Completely unrelated, but why do some people...


...put spaces between parens like that? That's one stylistic thing I've never really understood; it doesn't improve legibility for me anyway.

I don't think it looks good to put spaces between bracket delimiters. But I have started to appreciate adding spaces inside brackets in one context, which is the "not operator in an if condition":

if ( ! condition)
{
    ...


I feel like ! is quite easy to overlook without this, so it improves the readability of the code, even though the first time I saw it I thought it was ugly.

Xerophyte
Mar 17, 2008

This space intentionally left blank

Pavlov posted:

Every language should have an equivalent to the haskell $ operator.

On that note, it remains slightly annoying to me how English and US-centric a lot of the character conventions in programming are. ${}[]| and co aren't particularly easy to type on a good half of the world's keyboards, yet languages keep using them all over the drat place. Backticks are by far the worst in the swedish/nordic/german layouts, since ` is a chord resulting in a dead key meaning half the time you end up writing á instead of `a.

You might reply that I should use a US layout. I do, which has the cost that if I want to write something in my native language then that's a bunch of additional effort instead. The entire situation could be avoided by sticking to basic text-oriented symbols available everywhere but some jackass just had to give distinct meanings to all their special keys. I nurture a small, vindictive hope to some day introduce the ¨ and € operators in a major language to ensure that person will be as mildly annoyed as I have been.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Hammerite posted:

I don't think it looks good to put spaces between bracket delimiters. But I have started to appreciate adding spaces inside brackets in one context, which is the "not operator in an if condition":

if ( ! condition)
{
    ...


I feel like ! is quite easy to overlook without this, so it improves the readability of the code, even though the first time I saw it I thought it was ugly.

Hm. Yeah, I can see that. It's always bugged me how many languages don't have a "not" keyword that is isomorphic to the ! operator. Having a syntax-highlighted word is just so much more visible than sticking a ! in front of something.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Xerophyte posted:

On that note, it remains slightly annoying to me how English and US-centric a lot of the character conventions in programming are. ${}[]| and co aren't particularly easy to type on a good half of the world's keyboards, yet languages keep using them all over the drat place.

You could try trigraphs. Or persuading someone to make a programmer keyboard for your language.

Xerophyte posted:

You might reply that I should use a US layout. I do, which has the cost that if I want to write something in my native language then that's a bunch of additional effort instead.

Pressing a single keyboard shortcut to toggle layouts: "a bunch of additional effort"

seriously I have like three languages that I type in regularly, and flipping between them (or making sure I'm in English mode for code) really isn't a problem.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Soricidus posted:

sometimes, on the internet, people make extreme statements that are not wholly true, for rhetorical or comedic purposes. for example, they may claim that a piece of code they wrote 6 months ago makes them scream out loud or feel physically sick, when in reality it merely causes them to frown slightly and think about how they'd write it today.

Okay, so I understand that saying that you hate all of your old code is obviously exaggeration, but even a mild dislike is still entirely unlike my typical reaction to my old code. As a general rule, I don't have negative feelings about my old code when I come back to it later months or years later. If I was prouad of it when I wrote it, I'm usually still happy with it months or years later, even if I would no longer write it that way, thinking about how I could write it better now makes me happy that I've learned how to better address the problems that I ran in to at the time.

If anything I'm considerably more positive about my old code than when I'm actively writing it.

Xerophyte
Mar 17, 2008

This space intentionally left blank

Soricidus posted:

Pressing a single keyboard shortcut to toggle layouts: "a bunch of additional effort"

seriously I have like three languages that I type in regularly, and flipping between them (or making sure I'm in English mode for code) really isn't a problem.

Good for you. I do find swapping layouts annoying, especially since the US physical key placement doesn't match, and I'd rather not have a reason to swap.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Xerophyte posted:

On that note, it remains slightly annoying to me how English and US-centric a lot of the character conventions in programming are. ${}[]| and co aren't particularly easy to type on a good half of the world's keyboards, yet languages keep using them all over the drat place. Backticks are by far the worst in the swedish/nordic/german layouts, since ` is a chord resulting in a dead key meaning half the time you end up writing á instead of `a.

You might reply that I should use a US layout. I do, which has the cost that if I want to write something in my native language then that's a bunch of additional effort instead. The entire situation could be avoided by sticking to basic text-oriented symbols available everywhere but some jackass just had to give distinct meanings to all their special keys. I nurture a small, vindictive hope to some day introduce the ¨ and € operators in a major language to ensure that person will be as mildly annoyed as I have been.

you could use haskell or scala and add your own € operator right now!

necrotic
Aug 2, 2005
I owe my brother big time for this!
or uh... perl6? is that the one you can arbitrarily change the parsing behavior?

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

qntm posted:

I have never had this problem.

I wonder if there's a correlation between the so-called "imposter syndrome" and thinking you have writen bad code (regardless of the truth of that thought).

I haven't experienced imposter syndrome yet either and I think it's due to reading a lot of code. Code that tends to be pretty bad. My speculation is that people with imposter syndrome are somewhat isolated and therefore overcritical of self.

Totally biased and anecdotal, but still, a thought.

pseudorandom name
May 6, 2007

qntm posted:

That line of code also sets src to point at the end of the string. And moves dst forward by the number of bytes which were read from src...

E: I guess it doesn't have to be bytes.

I wasn't aware that industry best practices frowned on the modification of local variables.

M31
Jun 12, 2012

Xerophyte posted:

On that note, it remains slightly annoying to me how English and US-centric a lot of the character conventions in programming are. ${}[]| and co aren't particularly easy to type on a good half of the world's keyboards, yet languages keep using them all over the drat place. Backticks are by far the worst in the swedish/nordic/german layouts, since ` is a chord resulting in a dead key meaning half the time you end up writing á instead of `a.

You might reply that I should use a US layout. I do, which has the cost that if I want to write something in my native language then that's a bunch of additional effort instead. The entire situation could be avoided by sticking to basic text-oriented symbols available everywhere but some jackass just had to give distinct meanings to all their special keys. I nurture a small, vindictive hope to some day introduce the ¨ and € operators in a major language to ensure that person will be as mildly annoyed as I have been.

Just use Java!

code:
public static void main(String\u005B\u005D args) \u007B
    System.out.println(\u0022Hello, world!\u0022);
\u007D
Or C!

code:
main(int argc, char *argv<::>) <%
    printf("Hello World");
%>

M31 fucked around with this message at 21:42 on May 31, 2016

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

necrotic posted:

or uh... perl6? is that the one you can arbitrarily change the parsing behavior?

There's also TECO, the programming language in which every string is a valid program. It stands to reason that € must do something in TECO...well, except that I'm pretty sure the language predates the Eurozone.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
And TeX.

necrotic
Aug 2, 2005
I owe my brother big time for this!

TooMuchAbstraction posted:

There's also TECO, the programming language in which every string is a valid program. It stands to reason that € must do something in TECO...well, except that I'm pretty sure the language predates the Eurozone.

Predecesor to EMACS, huh?

quote:

one could use the following TECO session (noting that the prompt is "*" and "$" is how ESC is echoed) to change "Hello" into "Goodbye":

code:
*EBhello.c$$                     Open file for read/write with backup
*P$$                             Read in the first page
*SHello$0TT$$                    Search for "Hello" and print the line (pointer placed after searched string)
    printf("Hello world!\n");    The line
*-5DIGoodbye$0TT$$               Delete five characters before pointer (ie "Hello"), insert "Goodbye", and print the line
    printf("Goodbye world!\n");  The updated line
*EX$$                            Copy the remainder of the file and exit
Looks about right.

fishmech
Jul 16, 2006

by VideoGames
Salad Prong

Xerophyte posted:

On that note, it remains slightly annoying to me how English and US-centric a lot of the character conventions in programming are. ${}[]| and co aren't particularly easy to type on a good half of the world's keyboards, yet languages keep using them all over the drat place. Backticks are by far the worst in the swedish/nordic/german layouts, since ` is a chord resulting in a dead key meaning half the time you end up writing á instead of `a.

You might reply that I should use a US layout. I do, which has the cost that if I want to write something in my native language then that's a bunch of additional effort instead. The entire situation could be avoided by sticking to basic text-oriented symbols available everywhere but some jackass just had to give distinct meanings to all their special keys. I nurture a small, vindictive hope to some day introduce the ¨ and € operators in a major language to ensure that person will be as mildly annoyed as I have been.

Let's face it, the problem is that a lot of "national" keyboard layouts out there were bad from the very start, and "makes it annoying to type programming languages" is just one facet of the issue. With many of them, it would be very hard to create a punctuation standard for replacing the use of [{ etc in current languages.

Athas
Aug 6, 2007

fuck that joker

Xerophyte posted:

You might reply that I should use a US layout. I do, which has the cost that if I want to write something in my native language then that's a bunch of additional effort instead. The entire situation could be avoided by sticking to basic text-oriented symbols available everywhere but some jackass just had to give distinct meanings to all their special keys. I nurture a small, vindictive hope to some day introduce the ¨ and € operators in a major language to ensure that person will be as mildly annoyed as I have been.

I am Danish and I use the US International (us-intl) layout everywhere. It is Good. Better for programming, not really more effort to write the æ's, ø's and å's than with a Danish layout, and I get all kinds of other international squigglies as well!

raminasi
Jan 25, 2005

a last drink with no ice

pseudorandom name posted:

I wasn't aware that industry best practices frowned on the modification of local variables.

Hello friend, do you have a few minutes to talk about immutability?

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that
Even with a US keyboard, I would use a language that uses 「Japanese quotation marks」, just because I think they look spiffy.

e: Holy poo poo they got 『』, 《》, and【】 too. Think of all the special nesting types we could have.

Adbot
ADBOT LOVES YOU

Xerophyte
Mar 17, 2008

This space intentionally left blank

fishmech posted:

Let's face it, the problem is that a lot of "national" keyboard layouts out there were bad from the very start, and "makes it annoying to type programming languages" is just one facet of the issue. With many of them, it would be very hard to create a punctuation standard for replacing the use of [{ etc in current languages.

Oh yes, the layouts themselves are horrors in a lot of ways. I maintain that the person who looked at the $ character and thought "that'd make a good special character in my spiffy programming language" was a bit blinkered, though.

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