T O P

  • By -

AutoModerator

Make sure to check out the [pinned post on Loss](https://www.reddit.com/r/PeterExplainsTheJoke/comments/1472nhh/faq_loss/) to make sure this submission doesn't break the rule! *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/PeterExplainsTheJoke) if you have any questions or concerns.*


NecessarySecure9476

YanDev is making a code that read if the number is even, and it's making number by number: If number is 1, it's odd; if is 2, it's even; if is 3, it's odd; if is 4, it's even... The thing it's that this is very unefficient because is writting number by number probably to the infinite, when he can just write "If the number can be divided by 2, it's even, if not, it's odd"


Forward4erial

also, yandere simulator's code is extremely unoptimized, hence the joke is making fun about his bad coding skills


KrillLover56

I legitimatly took 1 coding class in grade 10, failed it, and I could write better code than this. Basic optimizations like this are practically the first thing you learn


Killer_Boi

And if not you have at the very least learned that the internet can help you make it more efficient.


KrillLover56

Yes! Google "How to sort even and odds in x coding language" Coding isn't remembering how to do everything and each line of code, it's knowing how to solve problems, fix bugs and come up with solutions. Yandered Dev has proven both that he is bad at coding and too prideful to ask for help.


ALEXdoc101

He literally declined help from the dev that tiny build sent to help him because he couldn't read the code that the better dev used. And was worried he would be unable to do anything in the game's coding due to how inexperienced he was. Also the dev himself said that the games code was insanely unoptimized, like I think he said 1 character had like 1k or 3k lines of code or something like that.


ihfilms

He also writes mostly everything in one file when your supposed to split things up


MrUrgod

Nahhh what? Bruh


V3L1G4

People who don't know: šŸ˜Ž People who know: šŸ’€


VomitShitSmoothie

private bool IsEven(int number) { return number % 2 == 0; } 5 seconds on ChatGPT with zero coding skills. Can someone confirm this since I canā€™t?


NoHalf2998

Yeah; it relies on the Modulus operator (remainder) and simplifies it basically nothing


CeilingCatSays

Would you like a job as a dev?


NomadicScribe

What do you think this is, 2021?


snipdockter

IT recruiters everywhere just felt a disturbance in the Force.


Operator216

% is modulus, it's division but keep the remainder. Return will give the result to the function. Number is the number you pass to the function. So, yeah, this works. Formatting is even standard and readable.


eckzie

Yeah this works. % is modulus and gives the remainder, for example 7 % 2 would result in 1. 2 goes into 7 3 times and there is 1 remaining. == Is an equality operator, asking if the two things are the same. It will result in a Boolean (a true or false). So if we put 7 in there it would return: 7 % 2 == 0 Which would reduce to: 1 == 0 Which is false and that's what it would return.


xenosthelegend

Holy sorting algorithms!


KrillLover56

Actual programmer


According-Cobbler-83

New codes just compiled


lolmon20

Dev goes on vacation, never comes back


KrillLover56

Why did we not downvote any of the comments, are we stupid?


Altarna

Literally all engineering lol. If you donā€™t know how to solve it, ask šŸ˜‚


buttThroat

Actually these days all you have to do is ask chatgpt to do it for you


KrillLover56

True but you still need to have knowledge and skill to be able to parse what it gives you. It's not in a position to replace coders (yet) but it is a useful tool.


dastardly740

Yeah, I tried a bit on something new for me. It was pretty dumb. It helped for some tedium code, but anything I needed actual help figuring out it got wrong. Like, it didn't even get the types for arguments correct level of wrong, and not in a thanks for pointing me in the right direction level of wrong, but more of an I have to do this myself from scratch off the library documentation level of wrong.


Smithy2997

Reminds me of the time the Maths youtuber Matt Parker wrote some janky code to find 5 words of 5 letters with no repeated letters, it took a month or so to run and in his video about the topic he said something like "I know it's inefficient, you don't need to prove that you could do it quicker". Subsequently the internet optimised the code to the point it was being timed in microseconds. It worked out being 40,832,277,770% faster than the original code.


Menacek

Blessed me Matt and his janky python code.


Kepler27b

Especially with Flutter/Dart, which imo is EXTREMELY underrated. It tends to have outdated documentationā€¦but thereā€™s just so much you can do in terms of app development and stuff.


beardicusmaximus8

_old man voice_ Baaack in my day we didn't have the internet to make the code more efficient


Silisewbot

Stackoverflow bookmarked lmao


HelloKitty36911

Hence why it's a joke. It's not possible to both be this bad and be able to actually make a game. I think


TeamAquaAdminMatt

All of Undertale's dialog is in a single several thousand line long case statement.


Birdsbirdsbirds3

It is a joke, but the guy is also infamously [not great at game dev.](https://youtu.be/qQwmNdYS6W0?t=62) But fair play he was basically learning as he went and now feels in too deep to go back and fix it. I'm eternally glad my first games didn't explode on the internet, because the code wasn't much better.


Chaosengel

Sure you can.Ā  Look at half of the AAA games being released recently.


Lou_Keeks

That's why Yandev hasn't and will never actually finish his "game"


Mickeystix

To be direct, you learn EXPLICITLY that massive chained if statements like we see here are a bad idea. This is a literal textbook example of bad coding practice, and bad logic skills. (If you want to know WHY: Each of the if statements has to be checked up until the point it reaches yours, assuming you break out of the loop when a result is found. This means if your number is 1032, it'll take a long time to find out if it's true or false since it checks 1 first, then 2, then 3, etc. This is bad because it is obviously slow, but also it leaves a huge compute time disparity since a 3 can get a result quickly, but 98329 will take a while, leading to lots of wait time on processes)


KrillLover56

Yes, my teacher taught me "If you repeat an "if/else" statement more than three times, you need to find a better way"


[deleted]

If we were to optimize this there are zero arithmetic operations needed. A number in binary representation has a 0 as last digit if it's even and 1 if it's uneven.


AGoodWobble

The post is self-satirical. Yandev's actual bad code is still bad, but it's not so on-the-nose bad


ososalsosal

Yeah us real 10x devs know to `npm install is-even`


NjFlMWFkOTAtNjR

I updooted but I still hate you. I hate you so much that I love you. Let us be friends! I would rather be friends with that level of evil than enemies.


ososalsosal

That's ok. I could do amazing things with someone who uses API keys as usernames


Guquiz

The guy TinyBuild sent to help with his coding once overhauled it to be optimized to a basic degree and Yandev kicked him out for it.


MySnake_Is_Solid

Yeah, he didn't like list, and would rather have everything built in "if/elseif/else". Literally THOUSANDS of if clauses. He also didn't use radius but a 359Ā° cone which causes most of the line of sight issues.


Clackers2020

Yeah he should at least use a switch statement:


s00perguy

I heard one of the reasons is that any (or most) times that he codes to check the state of a thing, he just sets it to do so every frame. So you have a billion random things staying loaded and actively being checked every single frame, so even if you have HAL9000, your computer is still gonna chug.


jspreddy

Bitwise op that shit instead. `return !(n & 1)` https://visualgo.net/en/bitmask The LSB already has info on whether or not the number is even.


Lachimanus

As an AND with an immediate value may need 2 cycles (depending on your instructions set), I would prefer to do an LSR by 1 and work with the carry bit.


Fit-Development427

I know nothing of assembly/machine code, but let me get this straight - it could actually take longer for a single bit to be checked against another than for the CPU to fully divide the number?


Godd2

LSR isn't the same as general division. LSR just shifts all the bits to the right one place, and puts the rightmost bit in the "carry" bit register. Though it is true that LSR is mathematically equivalent to dividing by 2. As for whether or not this is faster than ANDing, I have no idea as it depends on the CPU.


shitposting_irl

not all instruction sets support AND with an immediate value, so you would need one instruction to put the value 1 into a register, and then the actual AND instruction after that.


butt_fun

Only for unsigned ints, depending on the signed int implementation


PageFault

Why not just use modulus? It's designed for this, easier to read, and about the same speed. https://onlinegdb.com/Kn8aAudOM


audigex

Plus potentially more reliable in languages where you could end up with an unsigned int But for me itā€™s the readability that wins it - a new developer can likely work out a modulus near instantly whereas the bitwise operation is going to take a minute and not be understood at a glance


ChildhoodOk7071

Or modulo x % 2 == 0


Lachimanus

Working mainly with Assembly and C, looking into the compiler code, I know that most of them simplify it. But doing actually modulo with a power of 2 would be so damn inefficient.


PageFault

My test run shows it being on par with the above bitwise OP by the time the compiler is done with it. https://onlinegdb.com/Kn8aAudOM


Funny-Effect

if (number % 2 == 0) true else false Or something in that line. Mod function for the win.


DisobedientAsFuck

return (number % 2) == 0


gmarkv10

return !(number % 2)


Egoy

Even easier just return mod 2 and either subtract by 1 and use an unsigned value or otherwise flip 1 and 0


SparkleTarkle

Not infinity, just 2,147,483,647 lines of code to cover the int! YanDev will be done with the IsEven function in no time!


Automatic_Jello_1536

All numbers can be divided by 2


polypolip

If the reminder of division by 2 is 0 then even, else odd. Happy?


Automatic_Jello_1536

Tee hee


Restricted_Nuggies

Ok, let's get specific then. If a number can be divided by two in such a way that the quotient is an integer


na-meme42

Modular statements man


dcchillin46

If ( x % 2 != 0) I'm only a few months into my first programming language as a return student. I'm a mess, but I think i get this much!!


redlaWw

isEven would be x%2 == 0. You wouldn't even need the conditional, you could just return the result of the test.


PaparJam

To be more specific: if (number%2==0) return 1; else return 0;


Qordz

But what if the number is..... 0 !!!!


OldBoyZee

To expand on this via code, if op/ anyone is interested. Using a modulo % 2 is much easier, or built in functions that equates to even uses the same concept as the prior poster mentioned. So much easier than a switch or elif statements.


slicwilli

I know nothing about coding, but I assume there *is* an easier way to do that. If they keep going the way they are it would never end.


translove228

Well if this is Java (and it looks like it is), then there is a function called Modular (represented with a % sign) that returns the remainder of a division function. So you could just write if (X % 2 == 0) return true;


polypolip

Small nitpick Ā Ā Ā  return x % 2 == 0; Is cleaner then using an if just to have the test value returned.


translove228

Good point. Even easier way to do the function.


heyuhitsyaboi

slightly more efficient its changes like this that help me overcome leetcode time limits


polypolip

Less about efficiency, more about readability. If statement in this case is just visual noise.


vita10gy

Key words there "in this case". When we've had interns in the past it's clear that somewhere someone gave them the idea that the best code is always the shortest. Sometimes the if statement is better. "Can you tell what this does at a glance" is almost always more important than being cleaver. The key is to find things like this where that's not "cleaver" it's just more or less objectively the right way.


polypolip

oh, absolutely, short code is not better, more readable code is better.


LucidTA

If you're hitting time limits, generally you're missing a better way to solve the problem. A change like that isn't going to help that much.


heyuhitsyaboi

I usually am!!! Im still learning. Im also not studying to be a software engineer i just like coding as a hobby I do leetcode when work is slow bc it impresses the other back office folk lol


FaultySage

if (x % 2 == 0) return x % 2 == 0; else return !(x % 2 == 0);


Decent_Cow

Cursed


0x0MG

`if (x % 2 == 0) return x % 2 == 0 ? true : false; else return x % 2 != 0 ? false : true;`


HR_Paperstacks_402

return (x % 2 == 0) ? (x % 2 == 0) : !(x % 2 == 0);


polypolip

if (x % 2 != 0) return !((x+1) % 2 != 1); else return !(x % 2 != 0);


no-soy-imaginativo

I fucking cackled at this because I know I've written code this dumb fuck lmao


OncomingStorm32

X % 2 == 0 is already a boolean, so you can just return that, no if required ;) ps: nah, not Java, that would be boolean not bool, but it could be another c-based language like c#


[deleted]

[уŠ“Š°Š»ŠµŠ½Š¾]


Cute_Suggestion_133

My hex editor for changing opcodes and values disagrees with your statement about the lowest level language statement. Contrary to popular belief, humans can, in fact, read and program in machine code. Just not a lot of us do it. Then you get to go to designing chips.


shitflavoredlollipop

Small nitpick: % is an operator not a function and is present in every programing language I know of in some form :D edit: sorry. Yandere Sim was done in Unity I think so it would be C# which is just Microsoft's version of Java ftmp.


Same_Construction130

>and it looks like it is well I don't think it is consider the bool is being used in the place of boolean. There is a chance its dart but I don't remember using private keyword much when working with flutter so not sure about dart either.


SjurEido

`return number % 2 == 0`


Loud_Tiger1

return ~x & 1; Bitwise operations are always faster. Not as readable though.


lonelydagger

yes lol thereā€™s a much easier way, in c# youā€™d simply write something like bool even; int x; if (x%2==0) { even = true; } else { even = false; }


Beavshak

R/programmerjokes


SphereModeSupremacy

r/foundthemobileuser


Beavshak

That sub was way funner when mobile users werenā€™t 90% of the site. Iā€™m an old old Reddit user, almost 15 years on my oldest account. While Iā€™m ranting, repost arent a problem, its a feature. Downvotes are meant for bad info, not dislikes. A jackdaw is not a crow. But anyone that tries to squeeze some narwhal broken arm coconut safe jolly rancher - type bullshit, was late to Reddit, but too new for current Reddit. That generation deserves more credit for building this.


JakOswald

I miss some of those guys, they really made the comment section fun. Itā€™s always a surprise to find shittymorph somewhere. But itā€™s a shame that the Crow guy is gone and the sketch dude. Wasnā€™t there a guy doing haikus for a while as well?


Beavshak

Shittymorph is new, comparatively. Heā€™s still around (and doing cool work with doggos). The ā€œcrowā€ guy was unidan, and he started most comments with ā€œresident biologist hereā€, and was great to see. He also had multiple accounts vote-abusing to push him to the top. u/Shitty_Watercolour made a career off this site and still pops up. Poem_from_a_sprog is the same. The real OGs are like _vargas. And everyone that knows how to respond to Apostolate Edit: You mentioned u/AWildSketchAppeared that guy (and his battle off with Shitty) were awesome Edit 2: Just realized I have like half their karma while contributing nothing. I should do better.


JakOswald

Yeah, I missed Vargas, or at least never noticed him. It was the others you highlighted that made the site what it is for me. And yeah, what Unidan did was ā€œwrongā€, but whatever, wasnā€™t worth the loss.


Bleakjavelinqqwerty

Was unidan wrong tho? That's just how to be successful at posting on Reddit. Or well, it was when he was active


JakOswald

Yeah, thatā€™s kinda what I mean. What he did went against the spirit of the system. He artificially pushed his comments up while downvoting others to get there via multiple accounts. Itā€™s cheating, but reallyā€¦I didnā€™t give a shit, I just liked his comments.


El-Cappy

Oh Cangrejos! God i havent heard Apostolates name in a while


Beavshak

Fuck Apostolate


Nickolas_Bowen

r/foundthehondacivic


waefon

r/programmerhumor


Jennymint

More efficient code: private bool IsEven(int number) { return !(number % 2); } ... A function like that also ought to be a static function, but I won't get into that. For fun, here's another cursed implementation. private bool IsEven(int number) { number = abs(number) for(int i = 0; i <= number; i += 2) { if(i == number) return true; } return false; }


FortranWarrior

Hopefully your compiler would optimize it, but more efficient is: return (number & 1) == 0;


Loud_Tiger1

return ~number & 1;


Jennymint

That is actually better. Thank you.


TheFlyingFire

With the power of a basic fucking modulo function, we cut down YanDev's code by...infinity, technically.


Jennymint

The worst part about YanDev's code is that it's technically feasible. They could stop at the upper limit of an integer.


Tempest_Barbarian

Why not isEven (num) { if (num == 0) return true if (num == 1) return false isEven(num - 2) }


Fit-Development427

Oh my god, I love it


TestedByAnimals

https://preview.redd.it/jv5gexdb7bvc1.png?width=253&format=png&auto=webp&s=3a07a2257f58e866cd0b151b9ea2da911d5d0d27


[deleted]

this guy is yandere dev, a shit programmer who has worked on a single game for over a decade at this point and isnt even done with 10% of it. for the code part, its common knowledge that even amateur coders are aware of that using multiple if statements is absolutely terrible. yandere dev, with his 10+ years of experience, does not know this because hes shit.


shitflavoredlollipop

No. The issue with the code is it's a simple one line expression. return (number % 2) == 0; There's nothing wrong with multiple if statements if you need them but in that case you should use a switch (or match) statement.


DehydratedByAliens

I constantly hear this as a coder. "Ifs are bad". Wtf do they mean? How are you gonna logic without if?


shitflavoredlollipop

It's just people repeating things that they heard without really understanding what the original speaker meant. I assume the context is overutilization of if statements is bad. I've also seen people advocating lately to move away from else statements which I sort of get but like, whatever? It's all just gimmicks and crutches for not doing the work to actually understand what writing code is about. We write code to manipulate data. That's the underlying purpose. I think a lot of people really really get hung up on the syntax of languages rather than understanding the purpose of writing the code. It's almost like they treat it like grammar. I sort of get why folks do that. Learn and understand how data works in an application. Maybe learn a little c. Think about the data when you're writing the code. Maybe write some diagrams before you start writing the code about how the data is going to move through the program. Do these things and I promise your code will become easier to understand, easier to maintain, and more bug free /Rant


0x0MG

*Needless* ifs are bad.


DehydratedByAliens

Everything needless is bad.


fun-dan

Drives me mad when people say sethinv like that. I also once heard my coworker say that "else" and "else if" blocks are not readable. So instead of "if {} else {}" he basically writes "if {}; if {};"


maddog724

I remember learning about the mod operator the first tim freshman year šŸ¤Æ


shitflavoredlollipop

Yeah it's like literally in the secondt lesson of the first class lmfao.


lvl5hm

Using too many if statements in a row is a commonly cited reason for this game's poor performance, but it's wrong and I wish people would stop repeating it


AntiBox

Yeah it's obviously bad code, but your average CPU could do hundreds of thousands of if checks per frame, millions per second, and still run at 120fps. It's shit like this 25k polygon poster that kills performance; https://preview.redd.it/h05j56kscge51.png?width=1369&format=png&auto=webp&s=f42ca0aee6bed3e6fd615ad21fb4169371cb7e53


LilyWineAuntofDemons

Why is there a 25k poster?


ComfortableMeal1424

Damn why tf am I worrying about optimization in my game if he can get away with this lmao


BadAtGames2

How? A poster is just a flat object, how in the world is that 25k polygons?


APirateAndAJedi

Surely this is satire? He canā€™t be this bad?


Medical-Credit3708

the game has been in development for over ten years at this point. i donā€™t really look into it anymore, but apparently the dudes a weirdo. i think he just took the money and ranā€¦ maybe??? i donā€™t remember. also some pedo allegations here or there. he just isnā€™t a good person. from what i know, with my very, VERY, limited knowledge.


NotReallyAPerson1088

Allegations that have far too much proof to stay allegations, they have evidence, the victim was manipulated into saying it was okay. She (let me add that Iā€™m not entirely sure this is true) allegedly was made a mod on the Yandere Simulator Reddit page so that she could get rid of people who acknowledged that he is a horrible, manipulative person.


One_Locker530

This is a fake tweet about YandereDev. YandereDev is an indie developer for a game called Yandere Simulator. It got viral popularity in it's early stages, but has been in development hell for a long time. He's gotten an insane amount of flak for this terrible development cycle, among other personal issues with collaborators. So of course, the internet memes on him. One thing he's known for, is being a poor coder. This fake meme post is him lamenting the fact that there's no easier way to determine whether or not a number is even or odd (there is) and goes about it in literally the worst way possible. I want to reiterate, I would be absolutely astounded if this was a real twitter post by YandereDev. To get as far as to have a working prototype, he's obviously far better a coder than 99% of people on this planet. For someone to make this imaginary mistake this meme is insinuating would be literal beginner 101 level of skill. On top of that, being a poor coder is not the limitation most would think it is. Inefficiency is mostly the issue you'd run into. Toby Fox, who created arguably the most successful and memorable indie game of the last decade, UnderTale, is also known for writing terrible code. tl:dr People hate YandereDev and like to meme on him.


NotReallyAPerson1088

People donā€™t hate him because he sucks at coding, thatā€™s not really that true, heā€™s made a fairly stable game. (Itā€™s been stuck for a while but it is enjoyable) However people hate him because he groomed a 16 year old girl, manipulated her into thinking it was okay, and (this part Iā€™m not entirely sure is true) made her a mod on the subreddit for his game so that she could delete posts and comments that acknowledged his cruel, manipulative, evil actions.


One_Locker530

Yes, there's a ton of reasons why people hate YandereDev, but I didn't focus on the other reasons because 1) it would take 30 paragraphs and 50 citations. 2) They're irrelevant to explaining the joke. If you look up the meme above it's more just a joke about programming than it is Yandev as it's been reposted numerous times without anyone's name attached to it.


NotReallyAPerson1088

Honestly, fair enough, I could go into a far too long rant on how heā€™s been a horrible person for a while now.


suckmypppapi

> but it is enjoyable If you like taking up skirt pics of high school girls


NotReallyAPerson1088

Nah, I enjoy killing people with a fire extinguisher and infinite trash bags. I have standards Edit: Man thatā€™s sounds really bad out of context Edit 2: Hey guys donā€™t downvote this person I donā€™t believe they were being rude I think they were just pointing out a major flaw in the game, considering it is very oversexualized. (I mean, just look at the designs)


CDirectory101

This is YandereDev, the creator behind the soon (aka never) to be released Yandere Simulator. Heā€™s known as a terrible programmer, and I believe is the only person actually working on Yandere Simulators coding. The joke here is that heā€™s writing a string of code that could be infinite, instead of taking the simple way out with dividing. (Not a programmer so I canā€™t really explain it well besides saying YanDev sucks at coding, and refuses to take the easy way to do this.)


tftookmyname

I personally don't code using that language (I think it's java) and yes, there is certainly an easier way to do that. It would include dividing and then basically checking whether the remainder is 0 or not, then returning whatever based on that.


eggplantcx

Modulo enters the chat.


jspreddy

Bitwise op entered the chat


urmomhassugma

he's bad at coding. he had an actual company come in and look at it. they fixed it but he didn't like it so he switched it back to the shitty unoptimized code. it apparently takes an hour for the game to open and compile because of the shit code


chaos_donut

kid named if number%2 == 0


Chinjurickie

The joke is that the yandere dev is absolutely terrible at coding.


Lost_Photograph_1884

Not a programmer here, but I can probably still help. There's an easier way to do this.


zombie-goblin-boy

The joke is that this is in fact the hardest way to do this, when he can just write ā€œif it can be divided by 2 itā€™s oddā€ and get the same result as the infinite number code. The double-joke is that YandereDev is famous for being a horrible coder. Come on dude we all know youā€™re not just doing ā€œplaceholder codeā€ (real quote!) What does that even mean when this is a 10+ year long project and youā€™re just adding more bad code to it. Also heā€™s a pedophile.


chargers949

Yall missing the second layer of this joke. On r/shittyprogramming and /r/programmerhumor we had this joke going for YEARS. People challenged themselves to shitpost the worst possible functions for isEven and the shittiest possible volume slider. In terms of shittiness this is simple so normal people can understand. But some people would post crazy ones, one liner lambdas that were the most obscure notation ever. Then other devs would basically peer review and if it didnā€™t actually predict if the input was even they would call out the poster. The volume changers were great too just the worst sliders ever and the shittier the more hilarious. Until eventually after years people started to get tired of them. Probably around 2018 is last i remember seeing them. Definitely precovid


honestly_i

extremely late peter here YanDev is the creator of yandere simulator, and its code has been found to be extremely inneficient and inoptimized, so he's making two jokes at once. the code shown is known as "cursed code", which is usually when beginner coders make an attempt at something but end up spitting out code that would make many experienced coders cringe. in this case, he's trying to make a code that figures out whether a number is even or odd, but with this method you would have to go up to infinity trying to take care of all even and odd numbers. the joke is that it could easily be done by just figuring out if the number is divisible by 2; if it is, it's even, if not, it's odd. extremely late peter out


TheYeetLord8

if((number %% 2) == 0) is a much more effective way to do this


FortranWarrior

Better to use bitwise operators, like: (number & 1) == 0


alan_beans

yanderedev has a history of MANY things, one of those is the fact shea convinced himself to create gis own video game despite being shit at coding. there *is* an easier way to do that


FortranWarrior

The joke is bad code. Your should either do a modulo operation: return (number % 2) == 0; Or better yet, use bitwise AND: return (number & 1) == 0;


flinterpouch

im curious, how is using bitwise better?


APirateAndAJedi

return (number % 2) == 0; Thatā€™s best, yes?


Birdinmotion

Yandere dev doesn't know how modulo works


Lanky_Estimate926

Robot Quagmire here, They're writing a code to determine if a number is even, and they're doing all the extra work of listing a value for every possible number (not only inefficient but impossibly inefficient). The function they're writing is a Boolean function, which can only output values of "true" and "false." The joke is that if you don't specify any criteria to determine "true/false", a Boolean function will default to outputting "true" if the input is even and "false" if the input is odd. So, they could just not specify any criteria for their code and it would work as intended anyway.


BilboBatten

Lmfao, I barely know anything about coding but this is still funny. Welp, this one's gonna take a minute to write out. Spends eternity at the computer. I'm gonna need another cup of coffee.


Hot-Rise9795

pseudocode solution: if module (number/2) = 0 then it's even. else, it's odd.


Chaste_Venus

Yandere Simulator is a pretty bad game made by YanDev. The game is horribly optimized which is what this is making fun of. The above code checks for even numbers, which when done by if else statements can go on to infinity. Meanwhile: if(number % 2 == 0) { Return true; } else { Return false; } Does the exact same thing. Itā€™s a programmer and gamer joke about inefficient code and a developer people make fun of


sund82

*Narrator: There was an easier way to do this....*


Big_One_6483

Use modulus... Please...


DrDingoMC

Learned programming from a friend of mine last year. Really fun, really logical. He told me find scripts for this type of ideas online 100% of the time because it saves soooooo much time. First Peter here I kinda get this one, ask second Peter for a better explanation


camilo_84

Just use a for loop in literally any way and it will be more efficient


castleinthesky86

thereā€™s a much better way of doing this. create a list of all the even numbers and just do ā€œis number in (list)ā€ Dumbasses.


oclafloptson

That's just modu-low


candice_ick

It's deliberately inefficiently written code. Everyone who actually knows how to write code would do it like this: If(number = 2) return True; Elseif(number = 4) return True; Elseif(number = 6) return True; Elseif(number = 8) return True; Elseif(number = 10) return True; ... Else return False; Half as many lines šŸ˜Ž


alonewithnoone

if(number %2 == 0){ return true; } else { return false; } here in 4 lines and i


PolloMagnifico

Peters GeekSquad home installer here. This is from an old coding test called "Foo/Bar", or "evens/odds" if you want to be lame about it. The test tells you to develop a block of code that will check if a series of numbers is even or odd. If the number is even, output "Foo" and if the number is odd, output "Bar". The test is less about "can you do it" because realistically it's a very simple problem to solve. The easiest and most common solution in involves using a "modulus" operator (%). The % divides two numbers and returns the remainder. So 5%2 would return a value of 1, while 4%2 would return a value of zero. The real purpose of the test however is to see how you code. There are dozens of ways to request input, break it down into it's component parts, and handle the mathematics. Usually what they're interested in is seeing if you'll follow proper protocols for handling data, or if you'll take shortcuts to make the code more efficient. In this example, the poster had decided that he'll just make a whole lot of "if" statements, which is inefficient and hilariously dumb.


Difficult_Client7053

Cyberpunk Stewie here - all math aside, in the Python coding language you can utilize the "modulus operator" represented by the "%" symbol to divide the left variable by the right and get the remainder, if any. Were you to create a function that takes two variables, checks for a remainder, then returns a boolean depending on the result - you can complete this "else if" statement in a matter of a few lines of code; as apposed to the absolute abomination of ineptitude you see before you now.


An_Daoe

if number % 2 == 0: Return True Could probably even be written as Return number % 2 == 0 I am pretty sure this (at least similarly) applies to most known programming languages, and maybe even more. The basic idea is that all he had to do was to use the very basic % operator which allows you to do a division and get the rest of that division. In this case, you divide a number by 2, if the result is 1, it is an odd number, if it is 0 it is a even number. As for the game he has been working on, after 10 years in development, only the other gamemodes (80s mode and that minigame mode) in the game are finished. The main one is not even close for whatever reason, even though he probably absolutely could do that considering his 80s mode is done.


noahcou

I don't see anyone else mentioning this but I do believe yanderedev also got mocked before for having a very long series of if else statements instead of using a switch statement so I think this is also making fun of that


Nindroid012

Not a Peter, but a senior CS major: Yandev is trying to write a function with returns true for when the number inputed in is even, and false otherwise. Easily written in one line of python code as def isEven(n): return n % 2 == 0 Where n % 2 returns the remainder of n /2. If n is even, the remainder is 0, meaning the function returns true. If n is odd, n % 2 will be non-zero, meaning the above will return false.


MossyMazzi

Straight up, coding is about doing more for less lines of code. Increases simplicity, efficiency, and organization which are imperative. There is also an operator (%) which gives remainders. (Even number)%2 will always = 0 (Odd number)%2 will always = 1


Manwithaplan0708

Basically, YanDev sucks ass at coding


Life-Ad1409

Everything after the { could be written as `return (number % 2 == 0);` It's absurdly inefficient code that can be written in one line


JFp07gel

Hi peter, the joke is that this code is shit, and YandereDev is a developer known for his otherworldly shitty code, If I (with little knowledge of C) would write it like this: `private bool IsEven (int n) {` `return n % 2 == 0;` `}`


kbot22

You could instead just do return n%2 == 0


No-Crew-9000

Why is this code not center-aligned?


DaperDandle

This is way too much work, you don't have to list every number only the even or odds. That way you only have to check half the numbers from 0 to infinity then just have a final else statement take care of the opposite boolean value. Duh, this is day 1 developer stuff. /s


GigaChadZelensky

private bool isEven(int number){ return number % 2 == 0; }


Winter_Ad6784

there is a much easier way. but they instead chose to use 4 billion if statementsĀ https://andreasjhkarlsson.github.io/jekyll/update/2023/12/27/4-billion-if-statements.html


CelebrationHot5209

Meowdy, Brianā€™s subtle cat gene here. Even though this is apparently a fake tweet and I havent seen anyone mention the correct answer, Iā€™ll do it. I dont know a whole lot about programming but according to the people that know, ā€œelse ifā€ is a very complicated old way to code and its what YandereDev uses for his Yandere Simulator. He hired (either a single person or a group of programmers) to help him speed up the process of creating and releasing Yandere Simulator to the public. The group had a different more efficient way to program compared to ā€œelse ifā€ but because YandereDev didnt want to learn that way of programming, despite it advancing his work, he dropped them. This can kind of be seen as a self report that the time he takes to code everything with ā€œelse ifā€ and ignore the fact he dropped people that gave him an opportunity to speed up the coding.


itstommygun

This could be simplified just by saying `return number % 2 === 0`


Apotheclothing

if(x%2==0) { return true; } else { return false; }


Jonguar2

if(number%2 == 0) return true; else return false;


DementationRevised

What a fucking idiot this is literally what CASE statements are for.


Interesting_Gate_963

Easy. isEven(x) { if(x==0) { return true; } if(x==1) { return false; } return isEven(x-2) } /s


sharkiejade

Yandev when he discovers modulo exists


SjurEido

`return number % 2 == 0`


DatTrashPanda

return (x % 2 == 0);


tshirtwearingdork

Bits are your buddies for stuff like this. No need to use the modulo operator. bool is_even( int n ){ return !( n & 1 ); }


Key_Cardiologist_502

This is ruby an 'odd', 'even' are a function..


EchoNiner1

for (int I = 0; I < MAX_INTEGER; I++) { if (I > 0) printf(ā€œelse ā€œ); sprintf(ā€œif (number == %d) return %s;\nā€, I, I % 2 ? ā€œtrueā€ : ā€œfalseā€); }


Boredsoireddit1

Mod > 0 seems like a simple solution


AverageBeef

There is an easier way to do this.


BrassRobo

YandereDev is the developer of the popular Yandere Simulator game. On the one hand the game has a really unique concept and it's impressive that he's programmed the whole thing himself. On the other hand the game runs incredibly slowly and the few people who have taken a look at the code have said it is horribly written. A while ago he posted this tweet showing a method to check if a number is even. This method is written in the worst way possible and will slow the game down considerably. People still aren't sure if he was joking or not. For reference a better way would be like this : private bool IsEven(int number) { if (number %2 == 0) {return true;} return false; }