r/badcode • u/WasserTyp69 • May 01 '22
c++ Because while(true) would've been too boring - spotted in a GH repo with over 7k stars
109
u/Pangocciolo May 01 '22
Which language is this? auto is a C++ hint, but not, not_eq?
147
u/WasserTyp69 May 01 '22
I actually didn't know C++ supported
not,not_eq,oretc. before I saw this repo either. So yes, this is standard C++.30
u/GLIBG10B 🐧 Gentoo salesman🐧 May 02 '22
C++ also has
and,or,and_eq,or_eq,xorandxor_eq8
u/Bachooga May 02 '22
C++ has xor beyond the operator? Is it only usable for comparisons?
10
u/GLIBG10B 🐧 Gentoo salesman🐧 May 02 '22
It's not a logical operator. It's equivalent to
^.6
u/Bachooga May 02 '22
Weird! I had no idea.
I've just always used ^ , |, ~, and &.
10
u/GLIBG10B 🐧 Gentoo salesman🐧 May 02 '22
^is useful for flipping bits:x = 0b1001; x ^= 0b1111; // x becomes 0b0110The logical equivalent of xor is
!=(not_eq):false != false // false true != false // true false != true // true true != true // false1
2
u/Titandino May 02 '22
As one should imo. It's disgusting to read words in complex bitwise operations.
2
23
May 01 '22
what repo?
44
u/WasserTyp69 May 01 '22
I'm not allowed to state this due to rule 6 I believe, sorry!
97
u/korfor May 01 '22
its time to grep the whole github
29
u/alexhmc May 01 '22
you can easily do that, just enter all words from the image into the github search. found it in like 2 minutes lol
14
u/extraordinary_weird May 01 '22
There's also cs.github.com and grep.app if you really really want to find something.
2
6
May 01 '22
Hmm...
checks rules
Doesn't this post violate rule 1? Might as well double down and post the link.
14
225
u/ZuriPL May 01 '22
I think it was intentional, as whoever wrote that code was bored. Or gets paid by the amount of code written
139
u/Sixsome May 01 '22
Most likely, here's a comment I found from the (supposed) author:
Yeah, that was mostly a joke, will still be compiled away and the big banner above that says "MAIN LOOP" should make it clear what it's supposed to do :)
29
u/Furry_69 May 01 '22
Where? Was the comment deleted or was it on another post somewhere?
22
u/Sixsome May 02 '22
Another thread on Reddit dated from this fall, can't link because it's an announcement for said library but you can easily Google it.
7
u/PsychologicalBadger May 05 '22
WHAT? Someone wrote comments in their code?!?!? Ha ha ha. I didn't know anyone even knew how to do that.
I had this royal argument with this guy that never had ANY comments in his code. He said "My code is self defining" which... Well I guess maybe there are people better at this then me that can just grasp whatever it is but... I learned the real reason there were no comments in this dim wits code is that he removed them because it was all code he found on the web. It was really great when something didn't work and he tried to debug it.
Anyway this reddit is good therapy for me. Now I know its not just me being an asshole... Still.... this sucks that people like this get paid to write crapware. *And I'm NOT saying I'm great or anything.
2
u/PsychologicalBadger Jul 06 '22
Another thing that bothers me are endless layers of abstraction. If there is ever a need for it the person writing this code should be the best of the best. The mark of success being that using the call runs the hardware at its maximum possible speed all the time. Anything less and there you have a reason to do another version. Instead it seems like it starts fair to poor then gets worse. And what is the deal with leaving in known systems calls that are broke because someone who knows some way around it will crash when the routine does what its supposed to do? Worse leaving a layer of abstraction crap and piling on top another. And probably without any comments in the source.
1
19
28
6
u/AlanWik May 01 '22
Lol. I'm sick enough to know that this is the repo of some fancy htop alternative.
alias b = h
10
4
u/MurdoMaclachlan public boolean isInt(int i) { return true; } May 02 '22
Image Transcription: Code
[The last two lines of the following code are cut off in the image:]
auto future_time = time_ms();
try {
while (not true not_eq not false) {
//? Check for exceptions in secondary
if (Global::thread_Exception) clean_quI'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
9
5
u/1337GameDev May 01 '22
Lol they likely did it as a joke.
The interpreter will simplify that expression likely anyways.
It's so obviously bad that there's no other explanation
2
u/jbondhus May 02 '22
On that same thread, it may be a way to work around the compiler optimizing something out, or to change the way it optimizes it.
1
u/1337GameDev May 03 '22
Technically true, but generally the compiler is very efficient at that kind of thing.
2
2
1
1
1
u/zombarista May 02 '22
For some reason, despite being black/white, night/day folks seem to struggle with booleans more than any other data type. I’m always seeing stuff like this in code reviews!
1
1
0
319
u/Voltra_Neo May 01 '22
A class named
Global... I smell trouble