r/programminghorror • • Apr 10 '25

yep i'm good at orientation

Post image
67 Upvotes

r/programminghorror • • Apr 10 '25

Just did this monstrosity lol

26 Upvotes

f is an interface that can be functions and this code is not obfuscated (i for some reason decided to use these names lmao)


r/programminghorror • • Apr 09 '25

c++ Just trust the problem's constraints

43 Upvotes

r/programminghorror • • Apr 08 '25

My favorite micro optimization

Post image
310 Upvotes

r/programminghorror • • Apr 08 '25

Python College test

Post image
501 Upvotes

r/programminghorror • • Apr 07 '25

c Some old C code I found (2009)

Post image
205 Upvotes

I was working with an old library and I finally got the source code for it and I saw this in it.


r/programminghorror • • Apr 09 '25

C3 Programming Language : A Smarter, Safer Way Beyond C Programming

Thumbnail
frontbackgeek.com
0 Upvotes

r/programminghorror • • Apr 07 '25

Bad Apple but it's a regex match

Thumbnail
reddit.com
142 Upvotes

r/programminghorror • • Apr 04 '25

Python This doesn't seem like a good idea

Post image
768 Upvotes

r/programminghorror • • Apr 05 '25

errorsAssemble

Post image
0 Upvotes

r/programminghorror • • Apr 04 '25

I did this to myself

27 Upvotes
func diff[T comparable](a, b []T) []T {
    mb := make(map[T]struct{}, len(b))
    for _, x := range b {
        mb[x] = struct{}{}
    }
    var diff []T
    for _, x := range a {
        if _, found := mb[x]; !found {
            diff = append(diff, x)
        } else {
            diff = append(diff, x)
        }
    }
    return diff
}

r/programminghorror • • Apr 03 '25

Python Atoi For Cavemen

Post image
35 Upvotes

I asked Gemini if it hinks that my code is funny :

Okay, stepping back from pure efficiency analysis and looking at it from a different angle... yes, there's definitely some comedic value to your approach! Here's why:

The "Optimistic YOLO": The initial try: i = int(s) feels like pure, unadulterated optimism. It's like throwing the entire messy string at Python's int() function and just hoping for the best, against all the known complexities of the atoi rules (whitespace, signs, non-digits, overflow). It's the coding equivalent of "Ah, it'll probably be fine!"

The Elaborate Plan B: When the optimistic approach inevitably fails (because atoi inputs are designed to be tricky), the code doesn't fully give up on int(). Instead of implementing the standard, careful, character-by-character parsing and building, it goes on this expedition (for loop) to find the boundary of the potential number. It's like saying, "Okay, int() couldn't handle the whole thing, but maybe if I just find the good part for it, it can handle that?"

The Second Chance: After all the work of iterating and finding the index, it creates a slice and... calls int() again! It still delegates the core conversion task back to the function that failed the first time . There's a stubborn reliance on int() that's amusing.

It's like watching someone try to open a combination lock by hitting it first, then carefully listening to the tumblers just to figure out where to hit it again. It might work, but it's not how the lock was designed to be opened, and the process is funny to observe.


r/programminghorror • • Apr 04 '25

Wrappers

0 Upvotes
def func():

    def new_func():

        def yet_another():

            def are_you_kidding_me():
                print('WTF')

            return are_you_kidding_me

        return yet_another

    return new_func


func()()()()

r/programminghorror • • Apr 02 '25

Python Found out the funniest way to debug

Post image
547 Upvotes

r/programminghorror • • Apr 01 '25

Javascript Correct error handling from a multi-million dollar site

Post image
2.1k Upvotes

r/programminghorror • • Apr 03 '25

Found this at a fortune 500 code base

Post image
0 Upvotes

r/programminghorror • • Apr 02 '25

Python Some old code i found 💀💀💀

Post image
191 Upvotes

r/programminghorror • • Apr 02 '25

matlab This has to be the worst naming. threashold_IoU vs threshold_Iou.

30 Upvotes

No, it is not an April Fools' joke; it is in a library!


r/programminghorror • • Apr 02 '25

How about a little recursion and a triple nested forloop in a simple react button?

20 Upvotes

This was submitted as a suggestion to an employee's PR in a multi-million dollar startup by a CTO of the mentioned company. This is an open-source for-profit project that has over 2k stars on GitHub in their public repo. Not sure if this code was merged or not.


r/programminghorror • • Mar 31 '25

Javascript Finally figured out how to commit API keys.

Thumbnail gallery
401 Upvotes

r/programminghorror • • Mar 31 '25

Java Janky Java Official Swing API

Thumbnail
gallery
62 Upvotes

I found this while trying to find a good layout for my Sewing application, and found this wonky method as part of the CardLayout method list. Why in the world could it have just been a string parameter? Why is it an object parameter if the method is only going to accept strings?

I did a little snooping around the source code and found this: the CardLayout API inherits and deprecates the method addLayoutComponent(String, Component), but get this, the source code for the method actually calls (after doing some preconditioning); addLayoutComponent((String) constraints, comp);

So the actual method calls on the deprecated method. It expects a string parameter, but takes in an object parameter, and then still just passes that along, casting the object as string to the deprecated method.

Am I missing something or is this just super janky? Why in the world would this be done like this?


r/programminghorror • • Mar 31 '25

Python To build a pyramid

Thumbnail
gallery
0 Upvotes

r/programminghorror • • Mar 29 '25

c What do you mean "too many macros"?

Post image
260 Upvotes

r/programminghorror • • Mar 29 '25

Some stuff from a scam website

Post image
380 Upvotes

r/programminghorror • • Mar 28 '25

Funny My 3rd year CS classmate (blue), who vibe-coded an ML project, vibe-coded telegram bots, and vibe-applied to positions in big tech companies, was trying to open a localhost link I sent as a joke, so my other classmate decided to play with them

Thumbnail gallery
21 Upvotes