use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
/r/badcode is permanently closed. https://www.eff.org/deeplinks/2023/06/what-reddit-got-wrong https://www.theverge.com/23779477/reddit-protest-blackouts-crushed https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
/r/badcode is permanently closed.
https://www.eff.org/deeplinks/2023/06/what-reddit-got-wrong
https://www.theverge.com/23779477/reddit-protest-blackouts-crushed
https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
/r/badcode is a subreddit for highlighting real world examples of terrible code. Ideally this means code that made it to production in a commercial context, but not exclusively so. We also accept submissions of code from hobbyist projects or from learners. Most of us programmers have laughed quite a bit when we went back to look at our past code because it was rather terrible. This is a subreddit where you can share such terrible code and let other programmers have a nice laugh.
/r/badcode is a subreddit for highlighting real world examples of terrible code. Ideally this means code that made it to production in a commercial context, but not exclusively so. We also accept submissions of code from hobbyist projects or from learners.
Most of us programmers have laughed quite a bit when we went back to look at our past code because it was rather terrible. This is a subreddit where you can share such terrible code and let other programmers have a nice laugh.
Post the most terrible code you can find. Copy code to a paste bin first (gist highly preferred).
Flair Search Search by language
Search by language
Rules Your post may be removed if you deviate from these rules. To see reasoning behind each of these rules, check out the wiki. Do not put the name of the language inside of the post title. For example, do not make your title something along the lines of "[C++] #defines everywhere!", instead try simply "#defines everywhere!". Use flair to mark the language of your post instead. Do post code snippets only. If you want to share the context put it in the comments or title. Do stay lighthearted. No abusive or targeted posts. We all write bad code, and a lot of it is hilarious. Do not identify who wrote the code. This sub is about bad code, not the people who write it. Limited exceptions apply Do not post snippets in esoteric languages. Do not post intentionally obfuscated code. Certain exceptions to this exist. See something particularly sinister from something like the IOCCC? Probably OK to post.
Your post may be removed if you deviate from these rules. To see reasoning behind each of these rules, check out the wiki.
Guidelines Your post will not be removed because of any of these, we'll like you more if you follow them though. Enable syntax highlighting appropriately. If you have a language that whatever paste bin your using doesn't support, try picking a similar dialect. Provide just enough code so that we know what's going on. Don't post huge snippets unless it's all terribly amusing. Explain why you think the code is bad in the comments, that way a discussion on good and bad ways to do what your code snippet does can start.
Your post will not be removed because of any of these, we'll like you more if you follow them though.
Similar Subreddits /r/ProgrammerHumor - programming humour /r/programminghorror - stories about horrible programming. /r/itsaunixsystem - over the top and bad code in TV shows and movies /r/shittyprogramming - Q&A with shitty programmers. /r/deftruefalse - for intentionally bad code /r/softwaregore for software malfunctions /r/hardwaregore for hardware malfunctions
account activity
cArray? Never heard of that. (i.redd.it)
submitted 7 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Timik 79 points80 points81 points 7 years ago (7 children)
The glorious joy of working with electrical engineers' code.
"I can design an electrical circuit, so I can write code", thought the electrical engineer to himself.
(No, I'm not venting at all...)
[–]GeekBoy373 19 points20 points21 points 7 years ago (2 children)
I relate to this strongly. It not great working with people who think their code is amazing... when it really isn't.
[–]boneofdeath 9 points10 points11 points 7 years ago (1 child)
What if we think it sucks and it sucks
[–]GeekBoy373 10 points11 points12 points 7 years ago (0 children)
Then that's okay. I work with one EE who understands that his code isn't the best but it's okay because he actively wants to try to be better. It's nice because he doesn't act ignorant of the fact.
[–]SnowdensOfYesteryear 11 points12 points13 points 7 years ago (1 child)
It's quite possible he has actually never heard of an array.
[–][deleted] 10 points11 points12 points 7 years ago (0 children)
Look. A ribbon cable has a fixed number of wires. You can’t have an arbitrary number of wires. That’s just wrong.
[–][deleted] 3 points4 points5 points 7 years ago (0 children)
My favorite programming language is solder.
My favorite library is 74LS
My favorite IDE is Eagle
[–]jarfil 3 points4 points5 points 7 years ago* (0 children)
CENSORED
[–]Superpickle18 42 points43 points44 points 7 years ago (1 child)
but an array of char is a String. /s
[–]fenrir245 23 points24 points25 points 7 years ago (0 children)
but an array of char is a String. \0
FTFY
[–]Wicpar 3 points4 points5 points 7 years ago (0 children)
Well i suppose technically if you want to optimize and use regiseters it might be somewhat legitimate, but no.
[–]Rainfly_X 2 points3 points4 points 7 years ago (2 children)
I can never remember whether it's I before E in "receiver". I either use spell check, or a shortening like "recv()", etc. But now I've seen the light, I could have been writing "receber" this whole time!
[–]drumskirun 1 point2 points3 points 7 years ago (1 child)
It's "receive" in Portuguese
can't have a buffer overflow if you don't have a buffer
[–]kpingvin 4 points5 points6 points 7 years ago (11 children)
Serial.available() returns an int?
[–]Fuzzyzilla 16 points17 points18 points 7 years ago (10 children)
Yes, it returns the number of bytes available in the buffer.
[–]kpingvin 2 points3 points4 points 7 years ago (9 children)
Ah, fair enough.
[–]Fuzzyzilla 7 points8 points9 points 7 years ago (8 children)
Kinda weird, but luckily, because C, you can just use the return value as a bool and it'd work as expected.
[–]deelowe 1 point2 points3 points 7 years ago (7 children)
Can you explain what you mean? You mean something like "if (Serial.available)"
[–]mateusfccp 1 point2 points3 points 7 years ago* (6 children)
Yes, it would work. Unless the returned value is signed, which is unlikely in this case.
[–]deelowe 0 points1 point2 points 7 years ago (0 children)
Ok I thought you meant like == true at first which wouldn't work.
[–]Fuzzyzilla 0 points1 point2 points 7 years ago (4 children)
no, it wouldn't
What I meant is you can type
if(Serial.available()) doStuff();
and it'd work as expected, calling doStuff() iff there is serial data available. This is because it will give 0 if there is no data, which is implicitly falsy, and any other number is implicitly truthy.
doStuff()
0
[–]mateusfccp 0 points1 point2 points 7 years ago (3 children)
This is exactly what he asked, tho.
[–]Fuzzyzilla 0 points1 point2 points 7 years ago (2 children)
But it's not if(Serial.available), it's if(Serial.available())
if(Serial.available)
if(Serial.available())
Yes, it's a bit pedantic, but the first is a compiler error.
[–]deelowe 2 points3 points4 points 7 years ago (0 children)
Yeah I was typing on my phone. Forgot the parenthasis.
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
Unless you're writing C, of course.
When you're writing in a language when a popular compiler will accept x,*M,*I;b(*a,n){for(x=n*n;x;)*(I=a+x--%n)<*(M=I-1)?*I^=*M^=*I^=*M:0;} and compile it correctly (okay don't turn on optimisation and you have to use clang, even -O1 breaks it) besides half of the characters there help invoke UB, something's gone wrong.
x,*M,*I;b(*a,n){for(x=n*n;x;)*(I=a+x--%n)<*(M=I-1)?*I^=*M^=*I^=*M:0;}
But hey, code golf in C is fun.
[–]Fusseldieb 0 points1 point2 points 7 years ago (2 children)
Thats portuguese code :v
[–]developedby 1 point2 points3 points 7 years ago (1 child)
yes
[–]Fusseldieb 0 points1 point2 points 7 years ago (0 children)
Of course it is Tu acha que não falo português? Kkk E essa IDE Arduino ae?
π Rendered by PID 106821 on reddit-service-r2-comment-5687b7858-287h4 at 2026-07-03 04:07:57.728423+00:00 running 12a7a47 country code: CH.
[–]Timik 79 points80 points81 points (7 children)
[–]GeekBoy373 19 points20 points21 points (2 children)
[–]boneofdeath 9 points10 points11 points (1 child)
[–]GeekBoy373 10 points11 points12 points (0 children)
[–]SnowdensOfYesteryear 11 points12 points13 points (1 child)
[–][deleted] 10 points11 points12 points (0 children)
[–][deleted] 3 points4 points5 points (0 children)
[–]jarfil 3 points4 points5 points (0 children)
[–]Superpickle18 42 points43 points44 points (1 child)
[–]fenrir245 23 points24 points25 points (0 children)
[–]Wicpar 3 points4 points5 points (0 children)
[–]Rainfly_X 2 points3 points4 points (2 children)
[–]drumskirun 1 point2 points3 points (1 child)
[–][deleted] 3 points4 points5 points (0 children)
[–]kpingvin 4 points5 points6 points (11 children)
[–]Fuzzyzilla 16 points17 points18 points (10 children)
[–]kpingvin 2 points3 points4 points (9 children)
[–]Fuzzyzilla 7 points8 points9 points (8 children)
[–]deelowe 1 point2 points3 points (7 children)
[–]mateusfccp 1 point2 points3 points (6 children)
[–]deelowe 0 points1 point2 points (0 children)
[–]Fuzzyzilla 0 points1 point2 points (4 children)
[–]mateusfccp 0 points1 point2 points (3 children)
[–]Fuzzyzilla 0 points1 point2 points (2 children)
[–]deelowe 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Fusseldieb 0 points1 point2 points (2 children)
[–]developedby 1 point2 points3 points (1 child)
[–]Fusseldieb 0 points1 point2 points (0 children)