@musicmatze @josias @janriemer Go is much more safer than C, for example access out of bounds or dereferencing a null pointer is caught properly with a nice message instead of plain "Segmentation fault" or reading/writing to random data.

Aside: I don't really understand why everyone fights for safety so hard. Do you not trust yourself writing code? Yes, safety features that languages provide are very useful and catch mistakes but it's not really something that is a yes/no question.

@musicmatze @josias @janriemer In Rust I happen to have the reverse - I always waste way too much time figuring out how to make the borrow checker happy, whereas in C stuff just works even if it involves a little bit of fixing.

@musicmatze @josias @janriemer They are sometimes cases where I had to .clone() all over the place just to make the borrow checker happy because objects are shared between two owners can have usually unrelated lifetime. In any other language - no problem

When you see yourself fighting the borrow checker this indicates a flaw in the overall design/data structure.
Especially when dealing with graph-like data structures you will run into problems when trying to model your data structure in "the traditional way" (via direct references to struct values).
Instead, try to model it via `Copy`able indices or ids.


@musicmatze @josias@theres.life

· · Web · 1 · 0 · 0


They actually do it in the compiler, too, for their AST:

Also see `GraphMap` in `petgraph`:

And if you really can't get around using multi-owner-references, you can use Rc and Arc like @musicmatze mentioned.

A great read on how to model linked lists with it is here:


@musicmatze @josias@theres.life

Sign in to participate in the conversation
Mastodon for Tech Folks

mastodon.technology is shutting down by the end of 2022. Please migrate your data immediately. This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!