Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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.



> 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.)


>Rust gets memory safety without a hit in performance

Interesting. How does rust statically verify that array accesses are in bounds?


Rust defaults to run-time bounds-checked array accesses, but iterators mean that the bounds only need to be checked once.


>iterators mean that the bounds only need to be checked once.

How is that possible with random access or mutable containers?


A 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.


Array accesses are checked at runtime.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: