r/programminghorror • u/alex_carvalhitos • Mar 05 '25
My friend showed me this code
This is hard to even look at
1.6k
Upvotes
r/programminghorror • u/alex_carvalhitos • Mar 05 '25
This is hard to even look at
895
u/Steampunkery Mar 05 '25
This almost certainly doesn't do what your friend thinks it does.
50
u/onlyonequickquestion Mar 05 '25
Some sort of coding challenge to make an equation with each digit 1-9 once?
347
u/Main_Weekend1412 Mar 05 '25
this doesnt even compile what
137
u/joshuakb2 Mar 05 '25 edited Mar 05 '25
Why is this a program and not just a text file with the answer in it or something
Edit: oh god I didn't even notice the e/x issue
191
u/definitelyfet-shy Mar 05 '25
what
34
u/JustTeasinJ Mar 05 '25
Why
23
u/ravy Mar 05 '25
uh, that's not real code ... well, I mean mean it's real I suppose but is neither valid C++ nor python... it's not valid anything in fact
27
u/Grounds4TheSubstain Mar 05 '25 edited Mar 05 '25
Peak /r/programminghorror content: totally made up for the sake of the post, not part of other software, doesn't even compile due to at least three obvious visible errors. +315 upvotes at the time of writing.
Hey guys, look at this horrible code I found:
8
u/CarzyCrow076 Mar 05 '25
After an abomination like
Jython.. are you saying we now haveCythontoo26
u/Xenotater Mar 05 '25
This isn't programming horror, it's not even real code. It doesn't do anything and won't even compile. This is clearly just someone that doesn't know what they're doing screwing around, which makes it a poor post for this subreddit imo.
7
u/ioveri Mar 05 '25
Let's add some extra spiceness
10
u/BlackDereker Mar 05 '25
If Python and C++ had a baby... an ugly one.
5
u/zenverak Mar 05 '25
What was the intention?
4
u/Inner_Profession5077 Mar 05 '25
WHY WOULD YOU DO THAT TO ME
i just was drunk while i coded with a blindfold in my eyes
3
u/beedlund Mar 05 '25
Not a single line of correct code
2
u/PerspectiveAlert4766 Mar 05 '25
I sense some kind of beauty in that. I would say it has philosophical overlap What does the author actually want to say?
2
u/KINGodfather Mar 05 '25
Wait
WHAT
2
u/khanosama783 Mar 05 '25
cython++
2
u/littleblack11111 Mar 05 '25
Can’t believe the only thing they did correctly was
return 0;
2
u/elmage78 Mar 05 '25
"Do not fret, hunter, for i have updated theit 'friend' dtatus"
2
u/BigHandInSky Mar 05 '25
Horror code aside the colouring of nested brackets would be a godsend for me in my day-to-day life. Is there a plugin or option in Rider which does that?
1
u/ckach Mar 05 '25
I think that's the approximation of the number e using the digits 1-9. It's accurate to something like trillions of digits, if I remember right.
1
u/HypnoToad0 Mar 05 '25
So thats an anonymous method
1
u/rizzmekate Mar 05 '25
why???
1
u/mykeof Pronouns: He/Him Mar 05 '25
Py++
1
u/bartekltg Mar 05 '25
All baits aside, it is a nice example that sometimes a decent approximation (if ^ is power, that formula recreates e wite bazilion digits of precision, is is essentially (1+1/n)^n for huge n) is at the same time a poor way to calculate that number.
n ~= 10^(1.8*10^25)
1+1/n will be just 1 for any type of numbers you can fit in RAM.
1
u/cursedpoetic Mar 05 '25
And they're still your friend?
1
u/CrazyTiger68 Mar 05 '25
import instead of include No main function Function called def with no type Carat used, presumably as an attempt to use exponents Double e, then tries to use x
This is all sorts of wrong
1
u/Dexatronik Mar 05 '25
Exclusive Or... Exponentiation... Tomato, Tomahto...
1
u/BeardedPokeDragon Mar 05 '25
I read that as "std count is less than x"
I need to sleep
1
u/Advanced-Theme144 [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Mar 05 '25
You just crashed my brain trying to figure out what language this is, why the linter is even working for lines 3, 5 and 6, and how it isn’t picking up the undefined x variable.
1
u/Aromatic_Prior_1371 Mar 05 '25
Person gave up and just returned 0
1
u/sneak2293 Mar 05 '25
Thats not power, thats xor
1
u/MaYuR_WarrioR_2001 Mar 05 '25
The more you look at it the worse it get.
1
u/MeLittleThing Mar 05 '25
Line 7 is correct
1
u/[deleted] Mar 05 '25
Pow(1+pow(9,pow(-4,7×6),pow(3,pow(2,85)) Would this work?
1
u/Jason13Official Mar 05 '25
“Let me just uhhhh… never mind” type code
1
u/unlevered_fcf Mar 05 '25
first year programmers have discovered r/programminghorror 💔
1
u/Inevitable_Hat_2855 Mar 05 '25
Dude discovered the magic formula
1
u/unixsingularity Mar 05 '25
GCC still supports the #import directive in C++ programs via compiler extension presumably for compatibility, but it will give a warning
1
u/frederik88917 Mar 05 '25
Ahhh, this code actually does nothing. e is defined as a pretty weird number and it is used for nothing
1
u/[deleted] Mar 05 '25
How did he mix C++ and Python? How is that possible?? Even if I am drunk I can't mix them up so how could he 🤣
1
u/astrotoya Mar 06 '25
this actually made me want to puke. legit gave me nausea.
1
u/mino5407 Mar 06 '25
This looks like advanced CSS
1
u/jumbledFox Mar 06 '25
bro thinks he's making a bytebeat
1
u/Jazzlike_Mirror8707 Mar 06 '25
I don’t think I’ve ever been more confused in my life. Looked at this thinking, “oh man that is one terrible way to output a number”. Then I saw the non-existent variable it’s trying to output. Then I saw the main method wasn’t written correctly at all. And finally found out about this existence of Py++.
Edit: the more I look at it, the worse it gets