4 ms·
> It doesn't have memory safety as a core goal. There is always a trade off in memory safety vs. performance. > there's no strong sense of design and elegance
by sprash 11y ago
> It doesn't have memory safety as a core goal.
There is always a trade off in memory safety vs. performance.
> there's no strong sense of design and elegance.
I definitely see more elegance in Nims syntax as compared to Rust or even Go. But maybe this is because in real life python is by far the most productive language for me and Nim represents something like sane Cython alternative.
- burntsushi 11y ago> There is always a trade off in memory safety vs. performance. Well... no. The central premise Rust is to not make that specific trade off. Rust gets memory safety without a hit in performance. (It does of course make a trade off: memory safety comes at the cost of more compile time checks and a more sophisticated type system.)
- acconsta 11y ago>Rust gets memory safety without a hit in performance Interesting. How does rust statically verify that array accesses are in bounds?
- bjz_ 11y agoRust defaults to run-time bounds-checked array accesses, but iterators mean that the bounds only need to be checked once.
- acconsta 11y ago>iterators mean that the bounds only need to be checked once. How is that possible with random access or mutable containers?
- masklinn 11y agoA Rust object can be owned (T), mutably referenced (&mut T) or immutably referenced (&T). To a given owned object you can create either a single mutable reference or any number of immutable references (concurrently, sequentially is fine). When you create an iterator from a container, the iterator contains an immutable reference to the container. As long as the iterator is alive, it's not possible to take a mutable reference to the container, and thus not possible to modify it. Because a reference can't outlive its source, this also ensures the iterator can't outlive the collection.
- heinrich5991 11y agoArray accesses are checked at runtime.