r/badcode • • Dec 29 '22

rust My friend just started learning Programming and showed me THIS xD (It compiles) NSFW

Post image
717 Upvotes

81 comments sorted by

310

u/npafitis Dec 29 '22

One image a thousand words, most documented piece of code I've encountered in years

31

u/rotteegher39 Dec 29 '22

Is this a sarcasm or for real?

116

u/npafitis Dec 29 '22

It's up to the reader to decide.

158

u/mteblesz Dec 29 '22

5th and 6th penis line would be moved a bit to left

10

u/powelles Dec 29 '22

5

u/rotteegher39 Dec 30 '22

Playground keeps telling me to remove parentheses

7

u/francopan Dec 30 '22

6

u/rotteegher39 Dec 30 '22

This code is a state of art, but playground tells what to in change it.That's what I meant. It is not supposed to be fixed. xD

edit: now I think if it falls under rule 1. of this subreddit...

8

u/rotteegher39 Dec 29 '22

I know what are you thinking, but that will also shift the structure of the symbol picture inside the code.
If you add up a space inside that string to compensate that it will showed shifted at runtime

5

u/F54280 Dec 29 '22 edited Dec 30 '22

Code as shown will shift part of the display at runtime, right?. That's what u/mteblesz meant.

Edit: wording

93

u/malsomnus Dec 29 '22

5th and 6th penis line would be moved a bit to left

Yes, that's a common pitfall in Rust.

35

u/[deleted] Dec 29 '22

Also a common pitfall of penises

1

u/ivorybishop Dec 30 '22

Just dress to the side it hangs towards.

3

u/RFC793 Jan 07 '23 edited Jan 08 '23

Or just borrow a different penis, this is Rust

23

u/dirice87 Dec 29 '22

Some of us are curved ok

37

u/Oman395 Dec 29 '22

This looks a lot more like either an experienced programmer making a joke, or a beginner programmer trying to find a way to have the strings line up in the code. I'm betting on the former, because who the hell learns rust as their first language?

14

u/rotteegher39 Dec 29 '22 edited Dec 30 '22

I understand what are you thinking, but...My friend is just crazyI told him that learning Rust as his first language will be hard. He didn't listen to me.

This is one of his first programs... xD

It's going better than I expected...

He started about 1 month ago.

But he is an Archlinux user. He always does everything the hard way...

7

u/CodingNShit Dec 30 '22

“first programs” lmfao ok.

48

u/DangyDanger Dec 29 '22

uhhhh, why wouldn't it compile if it's part of a string?

-57

u/rotteegher39 Dec 29 '22

I don't get what do you mean by that.

This compiles on my machine xD (Read the title again)

68

u/_PM_ME_PANGOLINS_ Dec 29 '22

Why are you surprised that it compiles?

37

u/TheBuckSavage Dec 29 '22

Because its rust. The compiler wants to agonize you before it compiles.

/S

3

u/Live-Profit3063 Dec 29 '22

interesting but whats the language used

2

u/rotteegher39 Dec 29 '22

See the flair. (reddit tag)
It's Rust Programming language.

1

u/Live-Profit3063 Dec 30 '22

ohh ok thanks

3

u/FrezoreR Dec 30 '22

What's bad about this code? Bad as in sexy bad?

1

u/rotteegher39 Dec 30 '22

Yes, you are the first one to get this !

5

u/NetherFX Dec 29 '22

what's bad about it? apart from the humor

4

u/MarquisTheWizard Dec 30 '22

Having the balls, shaft, and head all in the same for loop with a bunch of ifs instead of separate loops.

Also it prints the 'x' line twice.

1

u/rotteegher39 Dec 30 '22

My friend said:"It's not much, but at least it works!"

2

u/CarpinchoNotCapibara Dec 30 '22

Who tf messures balls when messuring dick?

2

u/rotteegher39 Dec 30 '22

I asked this my friend, he added this feature to make it more interesting, cause just printing dick size is not enough...

He said:"I should've probably added other characteristics like thickness or headsize"

2

u/CarpinchoNotCapibara Dec 30 '22

No I mean that I find it weird to add balls size to the dick size, balls should not count to dick size

57

u/mistahspecs Dec 29 '22

Least sexually obsessed rust programmer

112

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Dec 29 '22 edited Dec 29 '22

Image Transcription: Code


use rand::Rng;
fn main() {
    let x: i16 = rand::thread_rng().gen_range(14..=24);
    let balls: f32 = (((x as f32)/10.0)*3.0);
        let ballz: i16 = balls as i16;
    let balltop: i16 = ballz + 1;
    let headbot: i16 = x - 4;
    for cm in 0..=x{
        if cm==0               {println!("*{}--        |‾‾‾‾‾‾‾‾‾| |‾‾‾‾‾‾‾‾‾|    ", cm);}
        if cm<ballz&&cm!=0     {println!("*{}--        |         | |         |    ", cm);}
        if cm==balltop         {println!("*{}--        ‾‾‾‾‾‾|‾‾‾‾‾‾‾‾‾|‾‾‾‾‾‾    ", cm);}
        if cm>balltop&&cm<10   {println!("*{}--              |         |          ", cm);}
        if cm>=10&&cm<headbot+1 {println!("*{}--             |         |          ", cm);}
        if cm==(headbot+1)      {println!("*{}--           |‾‾‾‾‾‾‾‾‾‾‾‾‾|        ", cm);}
        if cm==(headbot+2)     {println!("*{}--           \_           _/        ", cm);}
        if cm==(headbot+3)     {println!("*{}--             \\         /          ", cm);}
        if cm==(headbot+4)     {println!("*{}--              \___|___/           ", cm);}
    
    }
    for i in (x..=26) {println!("*{}--", i);};
    println!("Balls size: {}", ballz);
    println!("Your **** is {}cm! :)", x);
}

I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!

97

u/[deleted] Dec 29 '22

Man, are you okay?

60

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Dec 29 '22

Yep, fine! =)

14

u/SirNoodlehe Dec 29 '22

Genuine question: who is the intended audience for these?

I assumed that these transcriptions were mainly intended for people with impaired vision, but I imagine this would be incredibly hard for a human to parse using non-visual senses.

16

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Dec 29 '22

There are actually a lot more ways transcriptions can be useful than just that - a (non-exhaustive) list can be found at section 1, here.

27

u/machine3lf Dec 29 '22

These are the days you live for, right?

7

u/account_is_deleted Dec 29 '22

There's a lot of :'s where there should be ;'s in your transcription.

10

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Dec 29 '22

Fixed, thanks for the heads up!

2

u/[deleted] Dec 30 '22

Gonna compile this later I hope you typed it out correctly

3

u/Cephlot Dec 29 '22

Honestly, starting with Rust is a bit ballsy

3

u/rotteegher39 Dec 29 '22

Yea, my friend Is crazy, I told him it's gonna be hard.

He is an Archlinux user. Always does everything the hard way...

This is what he showed me after 1 month of learning...

He said it was one of his first programs.

1

u/Cephlot Dec 30 '22

Yeah, that's an r/woosh

39

u/koenigsbier Dec 29 '22

Your friend decided to learn programming... with Rust. Yeah, right...

12

u/CorruptedStudiosEnt Dec 29 '22

Not the craziest thing. I started on C++. Well, I mean technically I originally started on ASM (a little practical joke by my father, real funny fucker), but that lasted all of a couple months before I threw in the towel. C++ was the first language I actually learned through and through, though.

3

u/getshrektdh Dec 30 '22

Started with lua, jumped to assembly no joke. Lua isnt even a programming language is a scripting language (blame cheat engine):

4

u/CorruptedStudiosEnt Dec 30 '22

ASM is the devil, and I haven't touched it since then, around 15-16 years ago now lol.

I'm sure I'm more than experienced enough that I could probably get into it far more easily now, but every time I think about actually trying again, I have a mental brick wall that goes right up.

3

u/getshrektdh Dec 30 '22 edited Dec 30 '22

After spending weeks to build a simple program by assembly only you get an immersive pleasure and you also get to show off how you manage to build a simple program and its source and how much you are stupid to do so with asm.

3

u/CorruptedStudiosEnt Dec 30 '22

People say that same thing about OpenGL, but I just can't imagine my enjoyment making a colored triangle in a few hours being that much more than making a whole prototype in a day using a prebuilt engine lol

3

u/getshrektdh Dec 30 '22 edited Dec 30 '22

Let me explain why in a different matter. You have a goal, lets say you want to buy a house, So you get a job for example in a factory, you work hard for minimum wage just to save up money but you have a goal on your mind, so you work tirelessly to achieve that goal, and once you accomplish it you get a dopamine overdose or endlessly pleasure that you achieved it (ignoring any expenses and time for this example). Now lets say you are a manage in that factory, sure you work also hard (maybe a bit less harder) and eventually also accomplish reaching your goal and get that dopamine high and pleasure (maybe less, that can be up to debate, also here ignoring expenses and exact time). Now lets say YOU own that factory, you work (much) less and and accomplish your goal, but you wont get the same dopamine and pleasure as your employees.

My point is, its not about the goal, its about the journey that excites and gives you that pleasure once you accomplish it even if it takes a lot of time.

I came from poverty and my mom always dreamt of having a house but being in the lower/middle class its a difficult task to accomplish, I begun messing around with cheat engine and learning about computers and programming in my teenager period, and slowly begun earning nice amount of money by studying programming and working hard developing a small community and platform/program because i had a goal, helping my mom accomplishing her goal which is living in a house and not in a small rented apartment. It took me 4 years working hours after school until morning (slept most of the time in school, but did graduate), i had lots of challenges and difficulties in the way but had also fun along the way especially overcoming them, and once i helped my mother getting her own house i got that dopamine high, and all that thanks specifically to assembly. After that i accomplished that goal i did not thought of any other goals, other the basic ones like getting a degree which am now getting (computer science), starting a family which is my and my mom mutual goal.

In short it does not matter how or how quick you accomplish your goal, its the way (journey) that matters (in my opinion), as long as you can allow yourself that and be happy with what you have and where you are, and that is life all about in my opinion (again).

My apologies getting philosophic and for the long and off main topic response.

Small edit: Also by creating your own stuff from ground up is more meaningful to you and rewarding, in my opinion again. Im not depended on programming, its basically begun as my hobby and still is. I get your point though, if i want to develop for example a game for profit i wouldnt go nor recommend assembly (if its not a small and simple). I do develop projects with python and currently with Nim (Nim programming language, if you want to find it in google).

And regarding opengl you could be more efficient the hardway, as not every compiler is "smart"/effecient.

3

u/rotteegher39 Dec 30 '22

Me and My friend support your idea

1

u/getshrektdh Dec 30 '22

Thank you :)

1

u/getshrektdh Dec 30 '22

But i still love it, its like playing with lots of lego pieces and you are not sure what you are trying to do with it but you eventually come up with something

8

u/LetterBoxSnatch Dec 29 '22

??? What is weird about this? It was a couple decades ago, but I learned with C++. Rust seems nicer

11

u/koenigsbier Dec 29 '22

Rust and C++ are probably equally hard to learn on the long run, but Rust starts with a much steeper learning curve which (in my opinion) makes it a very bad first programming language.

Give it a try, read The Rust book and I'll understand what I'm talking about 😉

4

u/[deleted] Dec 30 '22

Rust has one of the most helpful compilers I've ever used, yes it has a lot of concepts but it guides you pretty well. C++ both has far more concepts and it screams nonsense at you.

1

u/LetterBoxSnatch Dec 29 '22

Fair enough!

2

u/apoooows Dec 29 '22

yeah I thought I was the only one noticing this

7

u/[deleted] Dec 29 '22

a work of art

7

u/TarkFrench Dec 29 '22

there's worse out there

8

u/T-Skittle Dec 29 '22

We will watch your career with great interest....

1

u/fnieidhfenmbvfekh Mar 24 '23

It’s upside down.

1

u/rotteegher39 Mar 25 '23

That depends on how and who's you are looking at. xD

3

u/[deleted] Dec 29 '22

One of us one of us gooble gabble one of us

3

u/[deleted] Dec 30 '22

Programming noob and also a girl so I don't know much about the design but... Can't all those if statements be replaced by a case? If not, can you explain why?

2

u/getshrektdh Dec 30 '22

Only if the case is open i guess...?

2

u/MalbaCato Dec 30 '22

they can, and rust has guard clauses on match arms [= if clauses on switch cases in other languages terms] to help with these kinds of use-cases.

although I doubt it would improve the readability of this art piece.

7

u/ablablababla Dec 29 '22

6/10, needs to be longer and wider

2

u/BobFellatio Dec 30 '22

Fuckin dismissed, head outta here,

2

u/TheTimBrick Dec 30 '22

The crazy thing is I know exactly what this does and I have little experience with Rust

2

u/[deleted] Dec 30 '22

I don't speak rust, can someone explain what's going on here? This reminds me of my first exposure to java when I wanted to mod minecraft as a kid

2

u/Pangocciolo Dec 30 '22

Well, it could be rewritten by splitting it in two loops interleaved with hardcoded output... but who really wants to get it split?

1

u/Ceros007 Dec 29 '22

Why is "balls size" okay to print but not penis?

2

u/jarfil Dec 30 '22 edited Dec 02 '23

CENSORED