this post was submitted on 15 Jul 2023
546 points (98.1% liked)

Programmer Humor

19694 readers
118 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 1 year ago
MODERATORS
 
top 35 comments
sorted by: hot top controversial new old
[–] [email protected] 25 points 1 year ago (1 children)
[–] [email protected] 4 points 1 year ago (1 children)
[–] philm 4 points 1 year ago (1 children)
[–] tatterdemalion 1 points 1 year ago* (last edited 1 year ago) (1 children)

Are you copying a Result or Option?

[–] philm 2 points 1 year ago (1 children)

I don't understand...? I think I never explicitly run a method/function that is called copy (there isn't at least not for the trait Copy)

[–] tatterdemalion 2 points 1 year ago (1 children)

Lol yea I think the .copy() comment was a little gaslighting or something.

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

no its not youre crazy

[–] [email protected] 24 points 1 year ago* (last edited 1 year ago) (1 children)

I thought it was randomly adding Send and Sync traits to function signatures until rustc is happy.

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

Randomly wrapping things in Arc::new()

[–] [email protected] 22 points 1 year ago (1 children)

This was me in courses that used C. Keep adding and removing * and & until the IDE was happy and it usually worked.

[–] philm 8 points 1 year ago (1 children)

Ah the good old times with C, when things were much more simple (but unsafe...)

[–] [email protected] 3 points 1 year ago (1 children)

(void*) flashbacks intensify.

[–] philm 3 points 1 year ago

The "best" way to program dynamically typed...

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

I'm gonna have to borrow this book

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

Me too. I also want to make some changes to it at the same time.

[–] [email protected] 4 points 1 year ago

Better apply for a mutable library card now before someone else does

[–] [email protected] 16 points 1 year ago (1 children)

Hahaha yes tfw Rust forces you to put your shit in a Rc<Cell<Option<>>>

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

New your program deadlocks instead of crashing, peak safety.

[–] tatterdemalion 9 points 1 year ago

EVERYBODY STOP. Nobody make a move or the memory dies. We have a Mexican Memory Standoff.

[–] Blackthorn 13 points 1 year ago

Follow up of: "Mmm... should I put lifecycle annotation in these 10 structs or just use and Rc and call it a day?". Rc and Box FTW.

[–] [email protected] 12 points 1 year ago

So... now the rustc borrow checker is the new video game boss that is nearly impossible to beat for newcomers, right?

[–] [email protected] 5 points 1 year ago* (last edited 1 year ago) (1 children)

I think that's the only thing I dislike about rust. Not having to use * to dereference but later having to use is tad confusing. I know it's still clever solution but in this case I prefer c++'s straightforward consistency.

Using ampersand never was problematic for me.

[–] [email protected] 24 points 1 year ago

C++ does have the problem that references are not objects, which introduces many subtle issues. For example, you cannot use a type like std::vector<int&>, so that templated code will often have to invoke std::remove_reference<T> and so on. Rust opts for a more consistent data model, but then introduces auto-deref (and the Deref trait) to get about the same usability C++ has with references and operator->. Note that C++ will implicitly chain operator-> calls until a plain pointer is reached, whereas Rust will stop dereferencing once a type with a matching method/field is found. Having deep knowledge of both languages, I'm not convinced that C++ features "straightforward consistency" here…

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

Replace that with golang and now we’re talking

[–] BravoVictor 2 points 1 year ago (1 children)

Yeah, popped in the comments to say the same.

I dont know what my damage is with pointers…

[–] [email protected] 3 points 1 year ago

honestly with Go in general I’m in a perpetual cycle of being annoyed with it and then immediately being amazed when I find some little trick for efficiency - with stringer interfaces and the like

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

Same for C, & yields a pointer to a value, and * allows you to access the data. (For rust people, a pointer is like a reference with looser type checking)

[–] aloso 7 points 1 year ago (1 children)

We have pointers in Rust, too :) see documentation

[–] [email protected] 3 points 1 year ago (1 children)

I doubt many people have ever use that or any of the other low level memory API. The main appeal of rust is not having to do that.

[–] aloso 1 points 1 year ago

Sure, but raw pointers and unsafe Rust are still covered in the official learning material, so I assume that most Rust devs know about raw pointers.

[–] [email protected] 0 points 1 year ago (2 children)
[–] [email protected] 12 points 1 year ago (1 children)
[–] [email protected] 7 points 1 year ago

Here is an alternative Piped link(s): https://piped.video/watch?v=TGfQu0bQTKc

Piped is a privacy-respecting open-source alternative frontend to YouTube.

I'm open-source, check me out at GitHub.

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

Here is an alternative Piped link(s): https://piped.video/watch?v=co3ewqQlX-8

Piped is a privacy-respecting open-source alternative frontend to YouTube.

I'm open-source, check me out at GitHub.

load more comments
view more: next ›