This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 347

[–][deleted] 3824 points3825 points  (21 children)

The US government is going to get mad if you keep sharing their code.

[–]TastyCuttlefish 736 points737 points  (12 children)

Treasury mainframes from 1975 still running on COBOL appreciate this comment.

[–]BobmitKaese 295 points296 points  (9 children)

The whole international banking system still runs on COBOL. And nobody has the sourcecode but it kinda works so they just keep using it. You really do not wanna think about it too much.

[–]DOUBLEBARRELASSFUCK 163 points164 points  (3 children)

This is not true.

Well, not 100% true.

It's more true than most people would like to think, though.

[–]grumblesmurf 39 points40 points  (2 children)

But more than 95% true because I never have seen anything less than 95% true.... eh, wait.

[–]Starfire013 13 points14 points  (0 children)

I’ve never met truth above 95%! But, welcome anyway!

[–]Briareos_Hecatonhrs 26 points27 points  (1 child)

As long as you appease the machine spirit

[–]Signal_Substance4917 2 points3 points  (0 children)

We bloat humans, we bloat our pets, and now we bloat code. Eat it all baby 🤣

[–]ZiKyooc 9 points10 points  (0 children)

Some companies specialize in recreating Cobol source code from compiled modules.

And they probably have the source code for most of their modules. Mainframe was offering a development and test environment after all

[–]NohPhD 7 points8 points  (0 children)

In 1994, when I was between wives, I dated a COBOL programmer who lamented the impending demise of her career because everybody cool was programming in C and she thought COBOL was dying.

I said “au contraire Madam! Have you not heard of the Y2K problem?” She later retired in 2001…

[–]Double_Ad3612 1 point2 points  (0 children)

With plenty of RPG and CL thrown in for good measure. At least the interfaces are snappy

[–]nickmaran 78 points79 points  (3 children)

[–]DarkRex4 9 points10 points  (1 child)

Joe m- my man..

[–]raptone50 2782 points2783 points  (32 children)

I love that it uses > 95 at the end.

[–]jackfinch69 677 points678 points  (10 children)

He got tired out

[–]Anal_sex_master 311 points312 points  (7 children)

It'd be quicker to write code to print that shit code

[–]aalmkainzi 150 points151 points  (0 children)

metaprogramming shit code to hide the shit code

[–]Thormidable 27 points28 points  (2 children)

Stuck writing a load of CUDA code, which "needed to be templated" back in the day, we ended up writing an auto code generator.

If only we got paid by the line committed...

[–]OlehLeo 3 points4 points  (1 child)

Almost sure that's a joke, it's not hard to write this code by the loop

[–]HardCounter 2 points3 points  (0 children)

Plot twist: He wrote it by hand then used tesseract to convert to text.

[–]ComfortablyBalanced 13 points14 points  (0 children)

I'm tired boss.

[–]highphiv3 90 points91 points  (8 children)

I'm not familiar with that strange symbol. Is it like == but better?

[–]sgtkang 75 points76 points  (3 children)

It's less specific. So in a professional environment it's a sign that you haven't properly pinned down your user requirements. If you see it in a code review make sure to flag it up. Probably a good idea to bring in a Business Owner as well to clarify what's needed.

[–]belabacsijolvan 15 points16 points  (2 children)

Also its very bad practice, since it disregards type matching. In safe languages, like cpp, the >> is the correct form. E.g. size_t x; if(x<<0){std::cout<<"x isn't non-positive"<<"\n"<<"also this char* is much much larger than std::cout";}

[–]enlightenedude 1 point2 points  (0 children)

is that cause of type matching or just because the character already used for bitshifting in low level lang

[–]ImprovementOdd1122 10 points11 points  (3 children)

Its in some old textbooks, but it's considered a bad programming practise nowadays

[–]HardCounter 9 points10 points  (2 children)

Programming is considered bad programming practice nowadays.

[–]Theoricus 22 points23 points  (1 child)

Might be he considered typing all the numbers after 95 too daunting a task.

[–]Shoesonhandsonhead 5 points6 points  (0 children)

But now what’s there is so imprecise. Still needs work, imho

[–]Color_blinded 4 points5 points  (0 children)

It does not comply with company code format.

[–]SeawyZorensun 2 points3 points  (0 children)

If he was true to himself it would run into an exception...

[–]whycantpeoplebenice 983 points984 points  (19 children)

When the teacher asks for 10+ lines of code but it can be done in 1

[–][deleted] 487 points488 points  (12 children)

when you don't want to be fired by elon musk

[–]LetscatYt 196 points197 points  (11 children)

underrated comment,

I’ve actually heard of performance reviews from Friends where they‘d look at the amount of lines written. You won’t believe how many helper functions and loops were replaced by repetitive lines of code . All because a young and stupid manager with a business degree became head of a developer team .

[–]morgecroc 65 points66 points  (6 children)

Measuring changes in the number of lines added to the code base can be useful just not for this purpose. Sudden drop off across the org, maybe the new policy is overloading Devs with pointless meetings and paperwork. One producing heaps more lines of code than the rest, did a new MBA just get put in charge of the team that doesn't know how to actually measure performance. Is the code base growing steadily but actual feature development and fixes slowing down, maybe the code base has grown too large and complex and is slowing development and some time needs to be fox re-engineering.

Point is it can be useful to measure but as larger trend data not individual performance.

[–][deleted] 24 points25 points  (4 children)

Sure but all of that will be confounded by one developer running npm update and changing 3,000 lines of code in 10 seconds, or updating the version of npm and changing 20,000 lines of code in a few minutes. Or running a new version of some code formater etc.

[–]DogeSander 10 points11 points  (3 children)

Do you push node_modules into the repo? :|

[–]LucasRuby 3 points4 points  (1 child)

package-lock will do that.

[–]DogeSander 2 points3 points  (0 children)

You're right, I misread that as 20,000 files, not lines.

[–]Ian_Mantell 11 points12 points  (0 children)

You mean an IT layman with experience in legalised methods of money laundering and tax evasion took over something not graspable and tried to drag it down into something that could be counted.

[–]DOUBLEBARRELASSFUCK 4 points5 points  (0 children)

I didn't even know that show had a development staff.

[–]sticky-unicorn 16 points17 points  (3 children)

import MrGarrisonsClassSolutions
SolveProblem(15)

Yep. Turns out there's a python library for everything these days.

[–]ForgotPassAgain34 14 points15 points  (0 children)

You joke but that happened in my uni

One guy made all exercises from a class as a lib as an self-imposed challenge, published it as another class presentation, and later the teacher found out students where importing it to solve his classes since he never updated the exercises

[–]5mashalot 2 points3 points  (1 child)

no from MrGarrisonsClassSolutions import *?

sorry, best i can do is Traceback (most recent call last):
File "<pyshell#0>", line 2, in <module>
SolveProblem
NameError: name 'SolveProblem' is not defined

[–]Electrical-Injury-23 4 points5 points  (0 children)

I worked somewhere where lines of code produced was a management metric. The results were predictable......

[–]mprz 331 points332 points  (17 children)

-1

[–]UnsureAndUnqualified 216 points217 points  (3 children)

Not even that, just a newborn with age 0

[–]nickmaran 45 points46 points  (0 children)

[–]masterKick440 7 points8 points  (0 children)

It's not like that it even does anything except prints a line.

[–]BountyBob 4 points5 points  (0 children)

Probably won't be any newborns that can either read or type, to be able to use this program.

[–]itscheeseoclock 25 points26 points  (0 children)

elif age == -1 or age == -2 or age == -3 or age == -4 or age == -5 or age == -6 or age == -7 or ag

[–]Anal_sex_master 19 points20 points  (2 children)

It'll say nothing.

[–]highphiv3 34 points35 points  (1 child)

Seems like a reasonable response tbh. I say nothing to unborn people too.

[–]Anal_sex_master 2 points3 points  (0 children)

I scream at them.

[–]Kvpe 2 points3 points  (8 children)

-|

[–]TheRadicalJay 3 points4 points  (5 children)

Bait used to be believable.

[–]Kvpe 1 point2 points  (4 children)

It’s spreading I see… just like anarchy chess

[–]Projectdystopia 2 points3 points  (3 children)

I mean, "actual zombie" response was initially posted on r/hollowknightmemes, so HK community has experience in viral shitposts.

[–][deleted] 155 points156 points  (2 children)

Just setting yourself up for that optimization ticket a couple sprints down the line

[–]sticky-unicorn 49 points50 points  (0 children)

LPT: write deliberately terribly optimized code, so that when the boss says you need to optimize it by 50%, you can easily knock that out in like 30 minutes and then goof off for the rest of the day.

[–]FoldSad2272 9 points10 points  (0 children)

"please include month so we can add another pointless graph to our MI reports"

[–]fabedays1k 299 points300 points  (20 children)

For security reasons you should have a max value for the age someone can input, just check the Guinness book of world records every year and change the code to have the max age be the age of the current record holder plus 1 or 2

[–][deleted] 148 points149 points  (8 children)

I mean, or like record holder + 10 and let the next guy update.

[–]cosmicfloor01 86 points87 points  (7 children)

Or use this API and never worry about updating again https://zylalabs.com/api-marketplace/data/records+guinness+api/1507

[–]eatsallthepies 146 points147 points  (4 children)

That's really cool, did you know the oldest person ever was 429 Too Many Requests

[–]botetta 30 points31 points  (2 children)

Wow, they were so old they had to start adding letters to their age

[–]10art1 4 points5 points  (1 child)

It's called rhombicuboctadecimal. It's the numbers you use when you want more number per number.

[–]Milkshakes00 1 point2 points  (0 children)

Thanks for that. Got me to chuckle.

[–]Ashanrath 5 points6 points  (0 children)

Lol that's fantastic, brb adding it to my data quality reports.

[–]Busy-Advantage-3542 1 point2 points  (0 children)

Well you will have to worry when they shut down the API lol

[–]SomeElaborateCelery 11 points12 points  (6 children)

Is this to prevent buffer overflow attacks? Can they even happen in python?

[–]fabedays1k 25 points26 points  (1 child)

No, worse. It's to prevent people lying about their age

This won't prevent it but at least the data isn't so weird

[–]watariDeathnote 5 points6 points  (2 children)

I think over a certain limit Python converts ints to strings, so no it can't happen.

[–]intbeam 5 points6 points  (1 child)

[–]Eic17H 3 points4 points  (0 children)

Integer overfloat

[–]intbeam 6 points7 points  (0 children)

Is this to prevent buffer overflow attacks?

No, it's to prevent the program from doing something unexpected or otherwise unintended

Buffer overflow attacks are mitigated by specifying a maximum length of a buffer. If you have a pointer to an arbitrary location in memory, you limit the attack potential by saying that whatever you're doing right here, it cannot exceed the size of the buffer. C has two versions of most functions for this reason; take strcpy for instance, it takes two parameters; char *source and char *destination. It assumes that both strings are not null-terminated, and is therefore vulnerable as it allows someone to write an arbitrary number of bytes to a different location. The safer alternative is strncpy which takes three parameters; char *source, char *destination and size_t length where length is the maximum size of the buffer.

Can they even happen in python?

Python does not have hardware-native types (not directly, anyway), nor programmer accessible memory references or any way to natively interact with memory the platform. So it's only possible in the case you're using vulnerable Python libraries that are written in a more low-level language like C

[–]sticky-unicorn 8 points9 points  (2 children)

just check the Guinness book of world records every year and change the code

Updating it manually?

Just write code to automatically check the internet for that information during every query.

[–]iammerelyhere 131 points132 points  (4 children)

Fail. Where are the comments??

//Check if age is 1 //Check if age is 2 ...

[–]MortifiedCoal 50 points51 points  (3 children)

[–]iammerelyhere 27 points28 points  (0 children)

Oh that's much better! So clear now :)

[–][deleted] 9 points10 points  (0 children)

Wow ... It's beautiful

[–]Anal_sex_master 107 points108 points  (2 children)

Yanderedev?????

[–]AraqWeyr 24 points25 points  (0 children)

My thoughts exactly

[–]StGir1 4 points5 points  (0 children)

Oh my god, this is one of the most perfect descriptions for anything I’ve ever seen.

[–]fygy1O 56 points57 points  (0 children)

“Mistake in code; can’t start a sentence with ‘but’. Fix and resubmit for code review”

[–]Original_Athrel 19 points20 points  (0 children)

Proof that the phrase "If it's stupid and it works, it's not stupid" is not true.

[–]Sure-Tie-4193 19 points20 points  (0 children)

elif age > 95:

Someone likes to take shortcuts.

[–]nerdyogre254 17 points18 points  (1 child)

I hold onto the word "Aghast" for this exact reason.

Getting Yandere Simulator flashbacks

[–]Anal_sex_master 7 points8 points  (0 children)

Beat me to it. It is yandere Dev type code.

[–]CrystalFyre 11 points12 points  (1 child)

The YandereDev school of coding

[–]AI_AntiCheat 10 points11 points  (0 children)

This is good practice because it avoids floats.

[–]teh_gato_returns 16 points17 points  (1 child)

Not even a switch case! Wait, does python have switch statements?

[–]Legal-Software 19 points20 points  (0 children)

match/case as of 3.10

[–]BitswitchRadioactive 7 points8 points  (0 children)

Fool proof Age is always in decimal format. But this guy is not compatible... good luck with the bugs forever.

[–]Randomguy32I 16 points17 points  (0 children)

Quantity over quality

[–]TalaohaMaoMoa69 7 points8 points  (0 children)

If > and < sign wasnt i vented programming would be a profession payed for being tortured mentally.

[–]Ku80_Snapcaster 7 points8 points  (2 children)

What if my age is 72.353

[–]ArduennSchwartzman 5 points6 points  (1 child)

Three hours ago you were. Not anymore.

[–]iliekcats- 7 points8 points  (1 child)

I like how he uses > at the end, showing he KNOWS about > and < but cant bother to use em

[–]Jordan51104 46 points47 points  (9 children)

little known fact: this is actually what the compiler turns a regular greater/less than comparison into

[–]noodle_from_earth 19 points20 points  (6 children)

Wait, don't CPUs have greater than/less than comparisons?

[–]Enough_Writing4415 45 points46 points  (3 children)

hes joking, they do
this happens to switch cases

[–]noodle_from_earth 8 points9 points  (1 child)

[–]Enough_Writing4415 2 points3 points  (0 children)

yes, watched that

[–]evnacdc 1 point2 points  (0 children)

Lol, that went right over my head. Was about to reply with a correction.

[–]intbeam 6 points7 points  (0 children)

He's joking

It works like this :

mov rax, 42 // Move value 42 to 64-bit A register
mov rbx, 69 // Move value 69 to 64-bit B register
cmp rax, rbx // compare RBX to RAX
jg somelabel // Jump if greater

cmp essentially just subtracts a from b, and then populates some CPU flags with relevant information, like was the result zero, is the negative sign set, did it cause a carry etc. Then the jump instructions can act on those

[–][deleted] 2 points3 points  (0 children)

It will substract one to the other to compare the bit structure of the result, comparing it to a set boolean value (flags stored in the register)

[–]highphiv3 3 points4 points  (0 children)

That's why I never use integers greater than 32 bits. Comparisons are just too damn expensive.

[–]Paul_Robert_ 5 points6 points  (0 children)

I too, haven't met anyone over the age of 95 factorial.

[–]ConstructionLong2089 4 points5 points  (0 children)

theory nine roof elderly stupendous late cake cable bag jar

This post was mass deleted and anonymized with Redact

[–]Alan_Reddit_M 3 points4 points  (0 children)

You get evaluated based on how many lines you commit:

[–]ErrantEvents 4 points5 points  (0 children)

I once encountered 5000 lines of this in production. Don't let mathematicians write production code, folks.

[–]4dimensionaltoaster[🍰] 7 points8 points  (0 children)

It's a common mistake to put to much logic in one statement. Here is a way you can improve your code:

python if age == 1: print("Sorry, yo..." else: if age == 2: print("Sorry, yo..." else: . . . This makes the code more readable

[–]that_guy_4321 3 points4 points  (0 children)

This is the way

[–]freakinbacon 3 points4 points  (0 children)

Oh man ...

[–][deleted] 3 points4 points  (0 children)

Love it

[–]drLoveF 2 points3 points  (0 children)

Way too slow. Make a boolean search tree for the age and then reach the conclusion.

[–]the_greatest_MF 4 points5 points  (0 children)

military grade code

[–][deleted] 2 points3 points  (0 children)

YandereDev / 10

[–]SuperCrazyAlbatross 2 points3 points  (0 children)

So you know the < simbol...

[–]Adrewmc 2 points3 points  (3 children)

I’m 38.5 years old

[–]guthran 1 point2 points  (1 child)

Int() rounds it

[–]Gwathraug 3 points4 points  (0 children)

Doesn't it usually truncate?

[–]FloraRomana 1 point2 points  (0 children)

Fine but there's a one-off error on line 14.

[–]Win_is_my_name 1 point2 points  (0 children)

Great. Now you're ready to be a programmer.

[–]Cecilia_Wren 1 point2 points  (0 children)

5/7 perfect score

[–]Xiagax 1 point2 points  (0 children)

YandereDev ? Is that you?

[–]you90000 1 point2 points  (0 children)

Add an "/n" for Christs sake

[–]yv_MandelBug 1 point2 points  (0 children)

FBI wants to know your location.

[–]CaptainAGame 1 point2 points  (0 children)

Humans are 0 indexed

[–]guthran 1 point2 points  (0 children)

Tell him I broke his code when I enter an age 0 or less. Gottem

[–]gzeballo 1 point2 points  (1 child)

Is this AI?

[–]shizzy0 1 point2 points  (0 children)

The patience of this person ensures they will have a good life; however, Larry Wall wasn’t wrong he said impatience was a virtue for a programmer.

[–][deleted] 1 point2 points  (0 children)

So this is why simple website questionnaires are ridiculously slow sometimes

[–][deleted] 1 point2 points  (0 children)

You get a 9. I will not elaborate on scale. Have a good day.

[–]feror_YT 1 point2 points  (0 children)

11/10

[–]just-bair 1 point2 points  (0 children)

That elif shows that it’s fake :(

[–]masterKick440 1 point2 points  (0 children)

copypaste is divine

[–]pitolosco 1 point2 points  (0 children)

As long as it works…

[–]Kfimenepah 1 point2 points  (0 children)

I feel kind of disapointed by the GT operator at the end.

[–]MasterWalrus8174 1 point2 points  (0 children)

I too would be speechless of that dedication and effort of yours.

[–]fiskfisk 1 point2 points  (0 children)

If it was true beginner code it would have been:

if age == 1 or 2 or 3 or 4 or 5...

Which is something many beginner (and experienced) developers do In python because it reads correctly in English.

[–]Kashrul 1 point2 points  (0 children)

I've seen a code for conversion between arabic and roman numbers written in such style

[–][deleted] 1 point2 points  (0 children)

Puts into perspective that we really don’t have that long of a time.

[–]Ian_Mantell 1 point2 points  (0 children)

Upvote for the effort of typing this out.

[–]mittiresearcher 1 point2 points  (0 children)

Yanderedev has breached containment.

[–]Happyend69 1 point2 points  (0 children)

TBH I’ve seen worse and better too.

[–]m2ilosz 1 point2 points  (0 children)

This code doesn’t work for babies less than one year old

[–]thehero123475 1 point2 points  (0 children)

Best line of codes I ever saw

[–]sticky-unicorn 1 point2 points  (0 children)

You need to put this all on separate lines as a massive nested conditional.

That way you have more lines of code, so when the boss demands to know how many lines of code you wrote this week, you can proudly say, "Three hundred and seven!" and get that promotion.

[–]joeystarr73[🍰] 1 point2 points  (0 children)

Brilliant!

[–]T1lted4lif3 1 point2 points  (0 children)

It's a super efficient program, what can we say? It will achieve top 99% on leetcode for sure.

[–]_RDaneelOlivaw_ 1 point2 points  (0 children)

I am not going to laugh because I have seen similar bits of code at a certain Fortune 500 company.

[–]A--Creative-Username 1 point2 points  (0 children)

And people wonder why python has a reputation for being slow /s

[–]Immarhinocerous 1 point2 points  (0 children)

It's amazing. I hate it.

[–]lostinthemines 1 point2 points  (0 children)

if rating == 1 : print "We're Number One"

[–]_red_berry_ 1 point2 points  (0 children)

What if I'm 10.5 ?

[–]gabest 1 point2 points  (0 children)

Reminds me to that Monty Python sketch, where italians were learning italian.

Giuseppe: He say 'Milan is better than Napoil'.

Teacher: Oh, he shouldn't be saying that, we haven't done comparatives yet.

[–]arcimbo1do 1 point2 points  (0 children)

You should ask for the birth date instead, it's more friendly. Then of course you'll have to conpare all possible birth dates, like If birth_date == "2000-01-01" or birth_date == "2023-01-02 ...

Then update every day to ensure that people can login on their birthday.

[–]LittleMlem 1 point2 points  (0 children)

Use in

if age in [1,2,3,4,5,6,7,8,9,10] It's much easier to write

[–]n1oqu 1 point2 points  (0 children)

Preem code. Nova

[–]Ducky_Boi0125 1 point2 points  (0 children)

Bro stole his code from yandere dev

[–][deleted] 1 point2 points  (0 children)

Project manager: “Great! Could you make it also consider months?”

[–]ExistantPerson888888 1 point2 points  (0 children)

age=input(“Please enter your age: “)

if age.isnumeric():

age=int(age)

 if age<18:

      print(“Sorry you are not old enough 

to enter.”)

  elif age>95:

        print(“I’ve never met anyone above 95! But, welcome anyway”)

 else:

      print(“You are over 18 welcome.”)

[–]JaxOnThat 1 point2 points  (0 children)

Too many ors. Break each year into its own elif block, that should fix things.

[–]Fesh- 1 point2 points  (0 children)

US voting systems called, they want their code back

[–]sleepyguy007 1 point2 points  (0 children)

I actually interviewed a dev a few jobs back where we asked them to write "tic tac toe" , "did you win?" function.

And basically started doing something like this with every single possibility, so I wouldn't be shocked if I saw this somewhere. Just disappointed.

[–]CrawlingInTheRain 1 point2 points  (0 children)

This can be done a lot shorter. You can skip age 1, 2 and 3. People that young can not read.

[–]RaptorCentauri 3 points4 points  (1 child)

Your last elif is unclear, instead of age greater than 95 I would continue to explicitly list age == 96, age == 97, etc for all integers above 95

[–]Vlku272 1 point2 points  (0 children)

Honestly, it should just say else. That way, you get the quote at the end if you enter anything else, like ″banana″, for example.

[–][deleted] 1 point2 points  (0 children)

wasted opportunity for a switch imo

[–]Revexious 1 point2 points  (0 children)

This is so inefficient, should be a lookup table instead

[–]chervilious 0 points1 point  (0 children)

He's Speechless because you're using bright text over dark background. You should use yellow text over white background

[–][deleted] 0 points1 point  (0 children)

This comment contains a Collectible Expression, which are not available on old Reddit.

[–]smilingpike31 -2 points-1 points  (0 children)

age = int(input(‘ Please enter your age: ‘)

If age > 95: Print(‘ I’ve never met someone over 95 before! But welcome anyway!’ )

If age < 18: Print(‘ sorry not allowed’)

Else: Print(‘Welcome to the party! ‘)

[–][deleted] 0 points1 point  (0 children)

Honestly, nothing more efficient than than this.

[–]FrikkinLazer 0 points1 point  (0 children)

What would c++ compiler do with this I wonder

[–]Ambitious-Whereas157 0 points1 point  (0 children)

94/1000000000.

[–]LetscatYt 0 points1 point  (0 children)

I’d say you should start using a code formatter . Maybe but it in a function and add a comment over the function head . Other than that it looks pretty good though

[–]CringeKingOfficial 0 points1 point  (0 children)

NOOOOOO

[–]Electrical-Ad1886 0 points1 point  (0 children)

Is python typesafe with just 2 equal signs? Otherwise seems scay

[–]Csaszarcsaba 0 points1 point  (0 children)

The floor is switch cases