r/programminghorror • • 15m ago

C++ NFS Most Wanted (2005) worked around an ABI mismatch with EA's own memory card library by manually writing mangled C++ symbols

Post image
40 Upvotes

Disclaimer: this isn't leaked code, but reverse engineered code based on debug info that was shipped with the game. The debug info shows that these use extern C and void* parameters with these names.

I've been poking around this game for 1.5 years and this is by far the worst atrocity I've seen. They used an EA library that was compiled with the -fshort-wchar flag, making wchar_t mangle as unsigned wchar_t which is invalid C++ so you can't type it out.

When they tried to link against it, they got a mismatch because their code was calling the wchar_t overload instead of unsigned wchar_t. I'm not sure whether they didn't know they could have just compiled with -fshort-wchar themselves or they had some reason not to, but they ended up coming up with this ugly hack.


r/programminghorror • • 8h ago

Obj-C How did people even think that this syntax was a good idea?

Post image
23 Upvotes

r/programminghorror • • 3d ago

C++ Some times some crimes go sippin' through the teeth flanges

Thumbnail
gallery
47 Upvotes

r/programminghorror • • 8d ago

Other WGSL code snippet posted by Notch (Yes, that Notch)

Post image
422 Upvotes

r/programminghorror • • 9d ago

nothingIsMorePermanentThanATemporaryFix

Post image
250 Upvotes

r/programminghorror • • 8d ago

JavaScript Dots and Boxes

Post image
0 Upvotes

r/programminghorror • • 9d ago

One pipe through String, Array, and Map

Post image
0 Upvotes

r/programminghorror • • 13d ago

Did I cook?

27 Upvotes

It compiles.


r/programminghorror • • 15d ago

Real code that's been in my game for 3 months

Post image
979 Upvotes

This was added when we translated the codebase from GDScript to C#, clearly some dead code slipped through. I did a double take when I came across it today


r/programminghorror • • 16d ago

Leider wahr

Post image
1.1k Upvotes

r/programminghorror • • 15d ago

c++ Named nullptrs

Post image
406 Upvotes

r/programminghorror • • 15d ago

What a mail sorting system is this

Post image
9 Upvotes

I lost my words for this thing

BigInteger One = 1;
BigInteger ascend(BigInteger x, int n, int p) => ~((x ^ ~-(One << p >> 1)) << n);
BigInteger dscend(BigInteger x, int n, int p) => ~((x | ~~(One << p >> 1)) << n);
nfs = new(nfs.Where(kvp2 => kvp2.Item2["deleted"] == 0).OrderBy(kvp2 =>
          ascend(kvp2.Item2["important"], 34, 2)
        & ascend(kvp2.Item2["read"], 32, 2)
        & dscend(kvp2.Item2["time"], 0, 32))
        .Select(kvp2 => new TypesElement<string, StringDictionary<int>, NestedFolderRuntime>(kvp2.Item1, kvp2.Item2, kvp2.Item3)).ToList());        BigInteger One = 1;
BigInteger ascend(BigInteger x, int n, int p) => ~((x ^ ~-(One << p >> 1)) << n);
BigInteger dscend(BigInteger x, int n, int p) => ~((x | ~~(One << p >> 1)) << n);
nfs = new(nfs.Where(kvp2 => kvp2.Item2["deleted"] == 0).OrderBy(kvp2 =>
          ascend(kvp2.Item2["important"], 34, 2)
        & ascend(kvp2.Item2["read"], 32, 2)
        & dscend(kvp2.Item2["time"], 0, 32))
        .Select(kvp2 => new TypesElement<string, StringDictionary<int>, NestedFolderRuntime>(kvp2.Item1, kvp2.Item2, kvp2.Item3)).ToList());

r/programminghorror • • 16d ago

Are we even?

63 Upvotes

Hello,

This subreddit has had an identity crisis for some time. Sharing naturally occurring outrageous code was the primary purpose, however many posts feature code that is weird on purpose (which would belong in other subreddits like r/ShittyProgramming in olden times).

I remember an is_even "hackathon" we had in r/ShittyProgramming a few years ago. Since that subreddit is not doing well, I decided to try to reignite the spark here. I hope the moderators and regulars don't mind some creative malpractice.

Anyhow, here is my entry:

def chi_squared_is_even_test(n: int, sample_size: int = 300, p_threshold: float = 0.1) -> bool:
    """Determine if an integer `n` is even by using a χ² test on a random sample determined by `n`.

    1. We generate a normally distributed sample.
    2. We raise it to (1 + (−1)ⁿ), so the transformed sample should follow a χ² distribution if `n` is even and be constant otherwise.
    3. We use a χ² test on the result.
    """
    samples = sp.stats.norm.rvs(size=sample_size)
    power = 1 + (-1) ** n
    transformed = samples ** power
    return sp.stats.chisquare(transformed).pvalue < p_threshold

I also have some older bad is_even implementations in this notebook.


r/programminghorror • • 14d ago

C# I've didn't know you could check if entity exists here ! (address me)

0 Upvotes

For those who didn't get the joke: Basically, this functions handles entity removal request and.. it has literally no admin check whatsoever


r/programminghorror • • 17d ago

Old Legacy Pagination System

Thumbnail gallery
55 Upvotes

r/programminghorror • • 19d ago

Python Learning Python; Have I made a good progress?

181 Upvotes

r/programminghorror • • 19d ago

SQL Selecting an intersection percentage between two fandoms

Post image
149 Upvotes

The amount of nesting is insane for something relatively simple

Edit: This subreddit has the "No Student Code" rule. Well my code is technically student code but I wrote it myself and I thought it would be fun to roast my own code so I guess it should be fine?


r/programminghorror • • 23d ago

Lua uhh my (not) c++ code is acting weird...

Post image
772 Upvotes

this thing is cursed...

it is valid syntax (many things are hidden outside of the screenshot!)


r/programminghorror • • 21d ago

c My friend told me that printf() and null-terminated strings are to insecure so i built it

Thumbnail reddit.com
0 Upvotes

r/programminghorror • • 23d ago

git stagesOfGrief

Post image
92 Upvotes

r/programminghorror • • 23d ago

Python First time coding

Post image
0 Upvotes

Sometimes I think about saving the world


r/programminghorror • • 24d ago

bad code - goto

Thumbnail reddit.com
0 Upvotes

r/programminghorror • • Nov 05 '26

c++ Old code I made years ago

Post image
124 Upvotes

r/programminghorror • • Nov 04 '26 Regret

Java Jenny mod deobfuscated funnies

Thumbnail
gallery
525 Upvotes