Re:I've just learned Rust and I think I'm in love
by sp332 on Friday March 30, 2018 @01:17PM
(#16717933)
I think I understand this. It's difficult to write concurrency-safe linked list operations in C too. This is a case where I would lean on the standard library for sure. Is there a different kind of problem you'd recommend to just dip your toes in?
Re:I've just learned Rust and I think I'm in love
by oconnor663 on Friday March 30, 2018 @01:25PM
(#16718007)
Implementing a singly-linked list in Rust is much easier, because you can use `Option<Box<...>>`. (That is, each node in the list can hold the unique pointer to its tail, so it's easier for the compiler to prove to itself that everything you're doing is fine.)
Working through the Entirely Too Many Linked Lists book in general is super helpful, since it deliberately runs into the cases that are hard.
Implementing a hash table in Rust would probably be fine as a toe dip too. It's that multiple-references-to-each-object part that really burns you in the doubly-linked list case.
Re:I've just learned Rust and I think I'm in love
by curun1r on Friday March 30, 2018 @11:57PM
(#16721636)
https://github.com/carols10cents/rustlings
http://exercism.io/
These are probably the two best sites for small, exercise training programs in Rust. Once you've gotten through a few of them, you'd probably be ready to build something useful, which might be more interesting.
Re:I've just learned Rust and I think I'm in love
by v_lisivka on Friday March 30, 2018 @01:24PM
(#16717995)
Important correction: unsafe Rust is as hard as C or C++. It means that for many developers it's just impossible to write their own linked list in Rust.
Re:I've just learned Rust and I think I'm in love
by adrianN on Friday March 30, 2018 @01:42PM
(#16718173)
Writing a linked list in C is an exercise for undergraduates. I hope that almost all developers can do it with a little effort. Writing a linked list in C is not hard. Using it correctly is the hard part. In a safe language like Rust you can write your linked list using unsafe code and then build a safe interface around it.
Re:I've just learned Rust and I think I'm in love
by galangalalgol on Friday March 30, 2018 @06:46PM
(#16720449)
It isn't even a college level exercise to do linked lists in any language. The gp is probably getting at c being hard to write safe code at large scales, which I agree with, but linked lists are not large scale.
I'm not suggesting this is a good idea, but I'm tired of the linked list argument which kind of implies Rust is much harder than C for an equivalent linked list implementation. If you explicitly choose to lose the extra guarantees, Rust is about as easy as C to write a linked list in.