Too close to home

522 points · 39 comments · view on lemmy.world

39 Comments

Guilvareux@feddit.uk · 24 pts · 3y (6 replies)

Oh and .clone()

meisme@lemmy.world · 4 pts · 3y (5 replies)

And .copy()

philm@programming.dev · 4 pts · 3y (4 replies)

.copy()?

tatterdemalion@programming.dev · 1 pts · 3y (3 replies)

Are you copying a Result or Option?

philm@programming.dev · 2 pts · 3y (2 replies)

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@programming.dev · 2 pts · 3y (1 reply)

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

darcy@sh.itjust.works · 2 pts · 2y

no its not youre crazy

pulaskiwasright@lemmy.ml · 24 pts · 3y (2 replies)

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

theory@feddit.uk · 1 pts · 3y (1 reply)

That too

charolastra@programming.dev · 4 pts · 3y

Randomly wrapping things in Arc::new()

danwardvs@sh.itjust.works · 21 pts · 3y (3 replies)

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

philm@programming.dev · 8 pts · 3y (2 replies)

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

rikudou@lemmings.world · 3 pts · 3y (1 reply)

(void*) flashbacks intensify.

philm@programming.dev · 3 pts · 3y

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

mvee@lemmy.ml · 18 pts · 3y (2 replies)

I'm gonna have to borrow this book

HeavyRust@lemm.ee · 6 pts · 3y (1 reply)

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

mvee@lemmy.ml · 4 pts · 3y

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

SubArcticTundra@lemmy.ml · 14 pts · 3y (2 replies)

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

nothacking@discuss.tchncs.de · 5 pts · 3y (1 reply)

New your program deadlocks instead of crashing, peak safety.

tatterdemalion@programming.dev · 9 pts · 3y

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

raubarno@lemmy.ml · 12 pts · 3y

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

Blackthorn@programming.dev · 11 pts · 3y

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.

skomposzczet@lemm.ee · 5 pts · 3y (1 reply)

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.

Pfosten@feddit.de · 24 pts · 3y

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…

nothacking@discuss.tchncs.de · 4 pts · 3y (3 replies)

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@programming.dev · 6 pts · 3y (2 replies)

We have pointers in Rust, too :) see documentation

nothacking@discuss.tchncs.de · 3 pts · 3y (1 reply)

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@programming.dev · 1 pts · 3y

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.

nautilus@lemmy.dbzer0.com · 3 pts · 3y (2 replies)

Replace that with golang and now we’re talking

BravoVictor@programming.dev · 2 pts · 3y (1 reply)

Yeah, popped in the comments to say the same.

I dont know what my damage is with pointers…

nautilus@lemmy.dbzer0.com · 3 pts · 3y

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

preasket@lemy.lol · 0 pts · 3y (3 replies)
Anafabula@discuss.tchncs.de · 12 pts · 3y (1 reply)

The actual video, not the reaction: https://www.youtube.com/watch?v=TGfQu0bQTKc

PipedLinkBot@feddit.rocks · 7 pts · 3y

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.

PipedLinkBot@feddit.rocks · 2 pts · 3y

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.