News for hackers. Stuff that matters.
Re:Rusty Ownership and the Lifecycle’s Stone by ok123456 on Sunday November 27, 2022 @01:56PM (#33765506)
A linked list is the simplest data structure there is.

Is a Red-Black tree simpler than a linked list to implement than a linked list in Rust? What about a Fibonacci heap?

Re:Rusty Ownership and the Lifecycle’s Stone by mtlmtlmtlmtl on Sunday November 27, 2022 @02:10PM (#33765658)
I think using data structures as an example is sort of missing the forest for the trees. It's definitely harder to do, but you generally don't need to as there's an excellent standard library and wider ecosystem of libraries that do this for you.

And implementing data structures in any language is hard. It's just a harder thing to do than most things because there's always gonna be a lot of gnarly implementation details and edgecases.

Re:Rusty Ownership and the Lifecycle’s Stone by ok123456 on Sunday November 27, 2022 @02:17PM (#33765729)
> implementing data structures in any language is hard.

Why make it harder.

> excellent standard library.

The standard library is intentionally bare-bones. They don't want to maintain libraries in std, and want you to use crates.

> wider ecosystem of libraries

The quality of these is quite poor in a lot of cases. People literally make blog posts into crates.

Re:Rusty Ownership and the Lifecycle’s Stone by mtlmtlmtlmtl on Sunday November 27, 2022 @02:36PM (#33765939)
As someone coming from C I find the stdlib is fine. It has all the datastructures you need for the vast majority of code. It doesn't have very domain specific things like the kind of structures a text editor might use, for instance. That's fine.

As for the quality of crates, yes, this is the case in any language. Using a library includes the responsibility of making sure the quality is up to scratch. This is not unique to Rust.

Re:Rusty Ownership and the Lifecycle’s Stone by antonvs on Sunday November 27, 2022 @04:10PM (#33766992)
> Why make it harder.

To achieve static memory safety.

If you don’t need or want that, you’re probably better off sticking to other languages. Although hopefully, not something like C or C++ which the US government now advises against using for security reasons.

Re:Rusty Ownership and the Lifecycle’s Stone by howinteresting on Sunday November 27, 2022 @02:18PM (#33765732)
The simplest data structures are pairs (A, B) and Option<T>.
Re:Rusty Ownership and the Lifecycle’s Stone by ok123456 on Sunday November 27, 2022 @02:34PM (#33765915)
Wouldn't call those data structures. Those are data types.
Re:Rusty Ownership and the Lifecycle’s Stone by howinteresting on Sunday November 27, 2022 @05:26PM (#33767661)
They are structured data. The restriction of the term "data structures" to what's asked in interview puzzles is ridiculous IMHO.

Edit: and even among "interview puzzle data structures", stacks and queues have much simpler semantics than linked lists.

Re:Rusty Ownership and the Lifecycle’s Stone by bitwize on Sunday November 27, 2022 @06:08PM (#33767975)
The simplest data structure there is (aside from scalars) is the array or vector.

Which you should be using anyway instead of linked lists so you don't blow up your cache.