News for hackers. Stuff that matters.
Re:Why Is SQLite Coded in C and not Rust by oconnor663 on Tuesday October 14, 2025 @08:13PM (#45586529)
Yes. You have to write `unsafe { ... }` around it, so there's an ergonomic penalty plus a more nebulous "sense that you're doing something dangerous that might get some skeptical looks in code review" penalty, but the resulting assembly will be the same as indexing in C.
Re:Why Is SQLite Coded in C and not Rust by hypeatei on Tuesday October 14, 2025 @08:28PM (#45586650)
I figured, but I guess I don't understand this argument then. SQLite as a project already spends a lot of time on quality so doing some `unsafe` blocks with a `// SAFETY:` comment doesn't seem unreasonable if they want to avoid the compiler inserting a panic branch for bounds checks.
Re:Why Is SQLite Coded in C and not Rust by Ferret7446 on Tuesday October 14, 2025 @10:27PM (#45587449)
If you put unsafe around almost all of your code (array indexing) aren't you better off just writing C?
Re:Why Is SQLite Coded in C and not Rust by aw1621107 on Wednesday October 15, 2025 @03:27AM (#45589144)
Perhaps if the only thing you're doing is array indexing? Though I'm not sure that would apply in this particular case anyways.
Re:Why Is SQLite Coded in C and not Rust by tomjakubowski on Wednesday October 15, 2025 @12:34AM (#45588120)
In many cases LLVM can prove the bounds check is redundant or otherwise is unnecessary and will optimize it away.