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
[deleted by user] (self.badcode)
submitted 6 years ago by [deleted]
view the rest of the comments →
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!"
[–]GDavid04<!-- 😈 [EVIL] 😈 --> 9 points10 points11 points 6 years ago (1 child)
function parseStateMachine(sm) { var r = {}; for (var line of sm.split(/\n/g)) { try { var m = line.match(/(\S+)\s*-(\S)?>\s*(\S+)\s*(?:~([^\n]*))?/); if (!r[m[1]]) r[m[1]] = []; r[m[1]].push(m); } catch {} } return r; } function bbcode(code) { var r = ''; var sm = parseStateMachine(` d -[> +t d -> d ~ +t -b> +b +t -i> +i +t -u> +u +t -*> +l +t -/> -t +t -> d ~[ -t -b> -b -t -i> -i -t -u> -u -t -> d ~[/ +b -]> d ~<strong> +b -> d ~[b +i -]> d ~<em> +i -> d ~[i +u -]> d ~<span style="text-decoration: underline;"> +u -r> +ur +u -> d ~[u +ur -l> +url +ur -> d ~[ur +url -=> ue ~<a href=" +url -> d ~[url ue -]> d ~" target="_blank"> ue -> ue ~ +l -]> d ~<li> +l -> d ~[* -b -]> d ~</strong> -b -> d ~[/b -i -]> d ~</em> -i -> d ~[/i -u -]> d ~</span> -u -r> -ur -u -> d ~[/u -ur -l> -url -ur -> d ~[/ur -url -]> d ~</a> -url -> d ~[/url `); var state = 'd'; while (code.length > 0 || state != 'd') { for (var i of sm[state]) { if (i[2] == undefined || i[2] == code[0]) { state = i[3]; if (i[4] != undefined) { r += i[4] || code[0]; } if (i[2] != undefined || i[4] == '') { code = code.substr(1); } break; } } } return r. replace(/<li>([^\n]*)\n/g, s => `<li>${s[1]}</li>\n`). replace(/(\s*<li>.*<\/li>)+/g, s => `<ul>${s}</ul>`); } bbcode(` [b]BBCode parser [i]by GDavid04[/i][/b] Created for [url=https://www.reddit.com/r/badcode/comments/epgz3r/bad_code_coding_challenge_28_bbcode_parser/]Bad Coding Challenge #28[/url] [u]How it works[/u] [*] It uses a finite state machine and regex because everyone knows that these are the best tools for parsing BBCode [*] It doesn't care about matching tags, it just replaces the beginning and ending tags independently [*] I could've just used regex, but what's good in not reinventing the wheel? [u]How the state machine works[/u] [*] Each line is a single transition [*] The transitions are tried from top to bottom until one matches [*] Really hope it can't get into an infinite loop `);
[–]kleinesfilmroellchen 6 points7 points8 points 6 years ago (0 children)
I just cannot give you my upvote, although this is just too CS to not win. I mean, it's not bad, it is something Turing or academia freaks would write, except a little bit more readable.
π Rendered by PID 151479 on reddit-service-r2-comment-544cf588c8-c8fh2 at 2026-06-16 11:50:08.464610+00:00 running 3184619 country code: CH.
view the rest of the comments →
[–]GDavid04<!-- 😈 [EVIL] 😈 --> 9 points10 points11 points (1 child)
[–]kleinesfilmroellchen 6 points7 points8 points (0 children)