this post was submitted on 17 Jun 2023
253 points (98.8% liked)

Programmer Humor

20229 readers
1532 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
top 35 comments
sorted by: hot top controversial new old
[–] drew_belloc 38 points 2 years ago (2 children)

Amateur! I use coments so it looks like this:

function main(){ /tab/if(fish==2){ /tab//tab/console.log("i need help"); /tab/} }

[–] [email protected] 9 points 2 years ago

I want to downvote you so, so bad, so take an upvote and leave.

[–] gnuswann 3 points 2 years ago

Him: I spend 3months on this project Me: how many lines does it takes now? Him: I would say around one line of code

[–] lasagna 19 points 2 years ago* (last edited 2 years ago) (2 children)

3 spaces is best because if the universe is chaos then everything in it should reflect that.

[–] [email protected] 23 points 2 years ago (2 children)

I'm more about increasing spaces exponentially to really highlight how important each line is

public boolean function() {
 if (method()) {
   if (otherMethod()) {
       for (Object o : list()) {
               if (o.isAlive()) {
                               return false;
               }
       }
   }
 }
 return true;
}

[–] lasagna 5 points 2 years ago

Good, good. The less consistency the better.

[–] [email protected] 2 points 2 years ago

Use the Fibonacci series so you can smugly claim your code incorporates the gold ratio

[–] [email protected] 6 points 2 years ago (1 children)

But what if the chaos plays favorites and favors tabs?

[–] lasagna 3 points 2 years ago

For line in lines: if char[0] == SPACE { del char[0]} else if char[0] == TAB {char[0] = SPACE*3}

save('overwrite')

[–] [email protected] 15 points 2 years ago (1 children)

This is horrifying, this is straight up blaspheny

[–] [email protected] 10 points 2 years ago (4 children)

For real. OP needs to give up on this ridiculous notion of tabbed whitespace and learn to use real, monospaced indentation. How wide is a tab? OP couldn't tell you because tabs are inherently dishonest -- a lie concocted by big keyboard to poison the unwashed programmer masses.

[–] [email protected] 7 points 2 years ago (1 children)

Tabs are one tab character wide, it's perfect

[–] [email protected] 2 points 2 years ago

You're one character wide

[–] gnuswann 4 points 2 years ago

I meant for my personal projects. For the code that only I see, tabs are much better for navigation. But it's true that if there are several of us working on the project, the spaces are much better.

[–] [email protected] 3 points 2 years ago

The big keyboard played us for an absolute fools!

[–] [email protected] 1 points 2 years ago

How wide is a tab? Who cares? I'm not pressing more buttons just to make you feel better.

[–] [email protected] 14 points 2 years ago* (last edited 2 years ago) (4 children)
int mostCursedIndentation (const int someVal) @safe {
{}{}if (someVal < 0) {
{}{}{}{}throw new Exception ("Value cannot be negative!");
{}{}}
{}{}return someVal * 5 - 3;
}

[–] [email protected] 18 points 2 years ago (1 children)

i dont wanna talk about the lua version of this

local function someFunction(arg)
do end local SomeLocal = 40;
do end if arg > SomeLocal then
do end do end SomeLocal = Somelocal + arg
do end elseif arg < SomeLocal then
do end do end arg = arg * 2
do end do end if SomeLocal > arg then
do end do end do end error("oh my god why are you trying to read this")
do end do end end
do end end
do end return SomeLocal
end

someFunction(-0.3000000000000124976137894613978561389741642978623178913786926473891)

[–] [email protected] 5 points 2 years ago (1 children)
[–] [email protected] 5 points 2 years ago

He has already left the chat

[–] gnuswann 5 points 2 years ago

This is the worst

[–] [email protected] 4 points 2 years ago (1 children)

Can you start randomly nest them too?

{{}}{}int foo = bar

[–] [email protected] 5 points 2 years ago

You made it even worse!

[–] [email protected] 1 points 2 years ago

Highly readable

[–] ndotb 9 points 2 years ago

I just want Coke to bring back Tab and Pepsi to introduce a competing drink called Space

[–] thkruz 7 points 2 years ago (1 children)

...this...this can't be real...no one is that much of a sadist are they?

This whole thread is what nightmares are made of.

[–] [email protected] 6 points 2 years ago

So at my work we've implemented a automatic code formatter. Instead of having discussions about the process of changing the configuration file we just put it up on GitHub. I think I might have found a fun April fool's prank.

[–] [email protected] 6 points 2 years ago

After 15 semicolons you’re legally allowed to leave.

[–] [email protected] 6 points 2 years ago

I know why it's there, but it still annoys me that there's a semicolon on the last line

[–] [email protected] 5 points 2 years ago
[–] [email protected] 5 points 2 years ago

TIL you can turn any language into Brainf**k with the right .vimconfig.

[–] [email protected] 3 points 2 years ago

An absolute mad lad

[–] lowleveldata 2 points 2 years ago

I use Ctrl+Alt+L for indention

[–] [email protected] 1 points 2 years ago

If people want me to write into my code what it does, I guess I'll label everything:

#include <iostream>
#include <cstdint>

#pragma GCC diagnostic ignored "-Wunused-label"

int main()
{
A:int a = 4;
B:if ((uintptr_t)&a & 0x100)
BA:std::cout << "hi" << std::endl; else
BB:std::cout << "hello" << std::endl;
C:return 0;
}

Note that this is much better for code style because - as opposed to the semicolon indentation- the single statement if and else branches still work. The trailing else is on the same line on purpose, it's so small it doesn't need its own line. Here's another style with similar properties:

[[,]]int a = 4;
[[,]]if ((uintptr_t)&a & 0x100)
[[,,]]std::cout << "hi" << std::endl; else
[[,]]std::cout << "hello" << std::endl;
[[,]]return 0;
[–] [email protected] 1 points 2 years ago

Oh, that's weird. Kinda not that bad- ... wait, where are the semi..co...lon..s... What? OH NO!! What the fuck! Hahahah, that's awful. There's some real bad stuff in this thread, but that first one is deceptively awful. Whew.

Really missing Haskell now :P

load more comments
view more: next ›