Hacker News new | past | comments | ask | show | jobs | submit login

There are penalties, they are just relatively marginal.



Specifically, Rust does runtime bounds checking when you index into an array. LLVM is theoretically capable of optimizing these checks out if they're unnecessary, but it's far from guaranteed. It would take a dependent type system to perform compile-time bounds checking, and Rust isn't that sophisticated.

However, indexing is far, far less prevalent in Rust than it is in C, due to the existence of iterators. I've asked the Servo team on multiple occasions whether the cost of bounds checking shows up in performance profiles, and they never have, likely because they just aren't doing very much indexing to begin with.


> There are penalties, they are just relatively marginal.

What are the penalties, specifically?




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

Search: