Rust is a great language but the packages right now are of mixed quality. I'm doing a hobby OS and had huge problems with "invalid opcode&quo

Why use Rust on the backend? : programming

submited by
Style Pass
2023-03-22 11:00:06

Rust is a great language but the packages right now are of mixed quality. I'm doing a hobby OS and had huge problems with "invalid opcode" exceptions repeatedly. I'd assumed I was doing something wrong, I mean it is OS dev and I'm using stuff everyone else is using productively right?

After a few weeks of back and forth crashes with this I went bonkers with gdb stepping through everything. I eventually found that it was intermittent because it was unaligned atomic operations that were at issue. As I wrote more code the variables aligned and stuff worked, then add more and they unalign again. I hadn't used any atomic operations. I removed one library that is very commonly used and I haven't had a single issue since. No idea if I was doing something wrong but "removal = success" tells a story of its own.

Cargo is a great thing but right now Rust has the same kind of package process as JS, necessarily because there isn't enough resource to make large official projects, and it shows. As a consequence Rust is a great language if you are prepared to own all/most of the code yourself, which makes it a good replacement for C/C++ but not fit for competing with something like C#.

Leave a Comment