r/programminghorror • • Feb 25 '25

I pity the girl who has to make sense of this math to port it...

Post image
964 Upvotes

r/programminghorror • • Feb 25 '25

Indentation Oriented Programming

Post image
166 Upvotes

r/programminghorror • • Feb 24 '25

Why can I overload ⚔️ as an operator but not 💗?

Post image
1.3k Upvotes

r/programminghorror • • Feb 24 '25

An Interesting Choice of Enumerated Constants

122 Upvotes

I was working on a Boolean solver awhile back, printing the logic values and trying to debug why I was getting incorrect results. I thought the state variables were Booleans, but no, they were integers:

#define 0 NOTSET
#define 1 ZERO
#define 2 ONE

What!?


r/programminghorror • • Feb 25 '25

O(1) Sorting algorithm, but with a twist...

0 Upvotes
import random
def prob_swap(l, p=1000):
    if len(l) <= 1:
        return l
    arr = l.copy()
    for _ in range(p):
        i1, i2 = 0, 0
        while i1 == i2:
            i1, i2 = random.choice(range(len(arr))), random.choice(range(len(arr)))
        l1, l2 = arr[i1], arr[i2]
        if not ((i1 < i2) == (l1 <= l2) or (i1 > i2) == (l1 >= l2)):
            arr[i1], arr[i2] = l2, l1
    return arr
    
TEST_CASE = [722, 191, 799, 208, 466, 849, 870, 66, 519, 606]
print(prob_swap(TEST_CASE))

There is only a high probability that the list is sorted!


r/programminghorror • • Feb 22 '25

Python Gotta make sure it works

Post image
3.8k Upvotes

r/programminghorror • • Feb 23 '25

Ram killer sort! Kill your ram!

65 Upvotes
def ram_killer_sort(l):
    """
    A sorting function that sorts in O(size_of_list + highest_number_in_list) and only works with natural numbers.
    This sort sacrifices your space complexity however, which is O(highest_number_in_list).
    """
    assert all(map(lambda x:x%1==0and x>=0, l)) # O(n)
    r = [""] * (max(l) + 1) # O(n + m) where m is highest item in list
    for item in l:
        r[item] += f"{item}\n" # O(n)
    return [*map(int, "".join(r).split("\n")[:-1])] # O(n + m) where m is highest item in list
    
TEST_CASE = [15, 10000000, 1730, 739814, 13, 89, 7, 0]

print(ram_killer_sort(TEST_CASE))

Will create a really big list.


r/programminghorror • • Feb 22 '25

Python A better version of sleepsort, I present: Tantime Sort

174 Upvotes
from multiprocessing import Pool
import time
import math

def sleep_function(x):
    return math.atan(x)+math.pi/2

def worker(x):
    time.sleep(sleep_function(x))
    print(x)

def tantime_sort(l):
    with Pool(len(l)) as p:
        p.map(worker, l)

TEST_CASE = [3, 21, 1000, 17, 69, -2, 1.0, 10000, 0.1]

tantime_sort(TEST_CASE)

Now it will only take pi seconds at most!


r/programminghorror • • Feb 21 '25

Recently wrote this line

Post image
686 Upvotes

r/programminghorror • • Feb 20 '25

Spec_life runs every game tick; he pasted this for four different species

Post image
128 Upvotes

r/programminghorror • • Feb 19 '25

Copy + Paste + Interns

Post image
115 Upvotes

r/programminghorror • • Feb 19 '25

Perfectly readable

30 Upvotes

r/programminghorror • • Feb 19 '25

Looks horrible but it works

Post image
68 Upvotes

r/programminghorror • • Feb 18 '25

Production ready code :)

267 Upvotes

This was definitely not found in a legacy API at my work... A magnitude of JS database queries all sending to the frontend


r/programminghorror • • Feb 18 '25

Python Who let me cook…

Post image
800 Upvotes

Needed to combine data from 2 CSVs & output 1 for a project. Cooked up the most disgusting code I think I’ve ever written…works perfectly though, & in technically only 3-lines of code in main’s definition


r/programminghorror • • Feb 17 '25

Wrote a basic OS on Assembly and printed its source code

Post image
639 Upvotes

These are 4 pages in one, from left to right, top to bottom.


r/programminghorror • • Feb 16 '25

Python Who needs assert when you have whatever this is

Post image
1.6k Upvotes

r/programminghorror • • Feb 14 '25

Remember that old area 51 roblox map? This is the code that opens the doors

Post image
3.0k Upvotes

r/programminghorror • • Feb 14 '25

Anyone Can Push Updates to the DOGE.gov Website — "These 'experts' left their database open."

Thumbnail
404media.co
1.1k Upvotes

r/programminghorror • • Feb 16 '25

AI is Killing Software Engineering, and No One Wants to Admit It

0 Upvotes

I don’t care how many people say “we’ll always need developers” or “AI is just a tool.” The truth is, software engineering as we know it is dying, and it’s happening much faster than anyone predicted.

AI coding assistants can now write production-ready code, debug, optimize, and even deploy without needing a human in the loop. What used to take teams of engineers now takes one person with good prompting skills. Why hire a junior dev when AI does their job better and instantly?

Companies are waking up to this. Look at the layoffs, hiring freezes, and plummeting job postings. The entry-level software job? Gone. The mid-level dev? Almost useless. Only the top 1%—the ones working on AI itself—are still thriving.

This isn’t some distant future. It’s already here. AI is eating the industry alive. In 5 years, traditional software engineering won’t exist. Adapt or get left behind.

Change my mind.


r/programminghorror • • Feb 14 '25

"What if I coded like this too - would I be more engaged?"

Post image
568 Upvotes

r/programminghorror • • Feb 13 '25

C# Fortunately (or unfortunately), this isn't called by anything but itself

Post image
1.5k Upvotes

r/programminghorror • • Feb 13 '25

c The biggest spaghetti ive written so far. Yes this is all one expression.

Post image
243 Upvotes

r/programminghorror • • Feb 13 '25

SQL port allocations

Post image
91 Upvotes