davidhyde 34 minutes ago

If you learned Rust first but find yourself reading a lot of C then this is also a good thing to read because of the parallels it draws with the languages.

kookamamie an hour ago

AFAIK, auto-vectorization has the same limitation in Rust as in C and C++ - it cannot be required. Hence, it is very easy to break the vectorization in brittle ways, without even noticing the issue.

It would be nice to have a sort of autovec-or-error annotation for preventing this.

  • dwattttt an hour ago

    Rust is experimenting with "portable SIMD": https://doc.rust-lang.org/std/simd/index.html

    It defines a generic `Simd<T, N>` type, expressing "This is a vector of T elements (such as i8), and is present in chunks of N". Methods that are easily vectorisable are defined on it, so if you can express what you want to do with one, you'll get well defined vectorised operations. Maybe not as perfect as you could hand write if you know what you're doing, but it _does_ guarantee to use vector instructions, so you're not at the behest of the compiler recognising a loop idiom.

0xpgm an hour ago

Reminds me of Learn x the hard way series by Zedshaw

einpoklum 2 hours ago

TL;DR: An introduction to Rust which starts with a Rust-unsafe C program, writing a Rust equivalent, then evolves it towards some of the higher-level abstractions in Rust.

(As opposed to the non-dangerous way which means writing safe code to begin with and mentioning unsafe as the exception)

  • Epholys 2 hours ago

    To complete the TL;DR : the safe Rust code is at 97% the speed of the C code, if keeping manual vectorization.

    • simon_void an hour ago

      To complete the completion of the TL;DR : the 95% safe Rust Code using auto vectorization is even slightly faster than the C code.