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

My favorite example of a safety feature in Rust which also improves runtime performance is string slices, which are implemented as a pair of a pointer to the first character and the length (used for bounds checking). Not only does this avoid having to scan for the NUL terminator to find the string length (that is, O(1) instead of O(N), which can make the difference between an O(N) and O(N^2) algorithm), but also it allows taking substrings without copying or modifying the original string (also helped by the borrow checker allowing the programmer to safely omit defensive copies of strings).


Made this C lib for exactly the reasons you mention. I love C but got mad at the constant bounds errors and copying.

https://github.com/alcover/buffet




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

Search: