ACKCHYUALLY C had ++ -- operators because they transleted to cheaper/smaller instructions for increment/decrement than arbitrary addition; and there was no optimizing compiler and they were either too constrained or lazy to detect right-hand-size. it's a bit of a historical artifact that became redundant as soon as compilers started to have at least minimal optimizations
Anonymous
7/18/2025, 7:20:11 PM No.105948435
n+=1 is garbage too, i hate these in-place operators for me it will always be n=n+1
>>105949063 It's just a typical skub thread. Ni/g/gers love to bicker about pointless shit.
Anonymous
7/18/2025, 8:35:24 PM No.105949167
>>105949042 it's better for stl iterators. however, in recent years the main compilers will detect your skin color and fix it in the assembly
Anonymous
7/18/2025, 8:50:59 PM No.105949288
>>105949063 It's kind of fun. Entry level, but you still need to know something to participate. Should we just do another brand warz or ai thread instead?
its so u can do stuff like auto x = *ptr++. or auto x = a[ind++]. saves an extra line. ++x will increment before so say int a = 5; int b = ++a; they will both be 6. however if int a = 5; int b = a++ b will be 5 and a will be 6. n+=1 is the same as n = n + 1, so it cannot be used in expressions.
>>105950932 I hole-hardedly agree, but allow me to play doubles advocate here for a moment. For all intensive purposes I think you are wrong. In an age where false morals are a diamond dozen, true virtues are a blessing in the skies. We often put our false morality on a petal stool like a bunch of pre-Madonnas, but you all seem to be taking something very valuable for granite. So I ask of you to mustard up all the strength you can because it is a doggy dog world out there. Although there is some merit to what you are saying it seems like you have a huge ship on your shoulder. In your argument you seem to throw everything in but the kids Nsync, and even though you are having a feel day with this I am here to bring you back into reality. I have a sick sense when it comes to these types of things. It is almost spooky, because I cannot turn a blonde eye to these glaring flaws in your rhetoric. I have zero taller ants when it comes to people spouting out hate in the name of moral righteousness. You just need to remember what comes around is all around, and when supply and command fails you will be the first to go. Make my words, when you get down to brass stacks it doesn't take rocket appliances to get two birds stoned at once. It's clear who makes the pants in this relationship, and sometimes you just have to swallow your prize and accept the facts. You might have to come to this conclusion through denial and error but I swear on my mother's mating name that when you put the petal to the medal you will pass with flying carpets like itโs a peach of cake.
>>105952596 I like writing i++ a lot more than i += 1. I just hate reading code where they heavily rely on juggling the return values from ++ shit everywhere just so they can save a line.
>>105948431 Yes, and it's not code that stinks good
Anonymous
7/19/2025, 3:55:05 AM No.105952689
>>105947817 (OP) Postfix operators give you (non-atomic) exchange semantics. `+=` does not.
Anonymous
7/19/2025, 4:37:37 AM No.105952915
>>105948391 I hate this because it sounds exactly like something some smug asshole high on his own farts would put in a company style guide and lecture you about.
Is it weird that I prefer nCount++; SomeFunction(sTest, nCount, nLimit, fCharge); over SomeFunction(sTest, ++nCount, nLimit, fCharge); I feel like the first is more readable
>>105947872 Yep, and on x86_64 it's unused. Even if you use i++, it will get replaced with an ADD instruction. INC is no faster than an ADD, but doesn't set RFLAGS
Anonymous
7/19/2025, 8:35:08 AM No.105954229
>>105953985 holy fuck stay away from computers, for the love of god
Anonymous
7/19/2025, 8:45:54 AM No.105954276
>>105947817 (OP) As a physicist I just say that literally everything is better than n=n+1. At least ++ and += have no meaning in mathematics.
>>105953985 Why do you expect code that has undefined behavior to not be broken by compiler optimisation? And bringing TCC to the mix isn't even fair because no optimisation.
Anonymous
7/19/2025, 11:41:24 AM No.105955166
What does this function return? int foo (void) { int n = 0; return ++n + n++; } You should be able to solve this.
>>105955259 it's undefined behavior. any compiler is free to do whatever it wants with that expression. In fact, gcc and clang will warn you if you try to do that.
>>105952587 all compilers will emit the same instructions for i++ and ++i unless you explicitly use the rvalue from i++. Notable exceptions being the first C (ansi C) compiler which didn't have optimizations and would emit fewer insn for ++i. https://godbolt.org/z/WWrxjaTnq
Anonymous
7/19/2025, 12:37:50 PM No.105955490
>>105954070 >tail recursion >will overflow the stack chatgpt levels of confidently wrong
>>105949063 As opposed to what threads? Your shitty question that could be answered by an LLM and belongs in /sqt/? The trillionth brand war thread? Maybe the excuse of a thread to post weebshit?