5 ms·
I suppose that a version of SQLite written in a safe(r) language will eventually appear, and hopefully become popular. But it will take a long time to mature.
by nine_k 5y ago
I suppose that a version of SQLite written in a safe(r) language will eventually appear, and hopefully become popular.
But it will take a long time to mature. SQLite the project cannot switch languages, sadly. The only way to migrate is that another project would grow beside in the meantime, mature, and become a viable and compatible alternative.
- tptacek 5y agoI don't like C (correction: I love writing C; I don't like running code written in C), but I'd probably stick with sqlite for several years after the introduction of a competing Rust sqlike. But I also wouldn't expose sqlite directly to untrusted users (for instance, in the hellworld where I'm a designer on a major browser, I wouldn't make sqlite part of the Javascript interface of that browser).
- nine_k 5y agoI see; I share much of the sentiment. But, tangentially, if not SQLite, what would you expose as a DB interface in a browser? SQL, while large and hairy, is both powerful and logical (in the relational part, not syntax). A plain KV store like dbm is no match to it. A Redis-like store is better but still more limited. Kdb's approach is sort of wonderful but geared towards time series and not much general-purpose. Is there an existing interface / language you would reuse to give the browser a rich database interface?
- masklinn 5y ago> SQLite the project cannot switch languages, sadly. I'm sensible to the issues of tradeoffs (e.g. platform support which is a completely fair issue) and manpower requirements and whatnot, but I don't see why it can not switch language. Converting libraries "inside out" has been done. Adding Rust support inside sqlite's build system and migrating modules is technically feasible (again, not opining on whether it would be worth it).
- Jtsummers 5y agoAdding Rust support would reduce (presently) the number of architectures and platforms that SQLite can target. That would greatly reduce its utility for a lot of customers. Once Rust supports the same variety of architectures that C presently supports this will become a non-issue, but that's unlikely to happen in the near term.
- masklinn 5y ago> Adding Rust support would reduce (presently) the number of architectures and platforms that SQLite can target. I mentioned that but i don't think that's the subject as it does not warrant such a drastic assertion that sqlite can not switch language.
- Jtsummers 5y agoOk, yes. SQLite can switch languages if the objective is to cutoff a large number of customers. Until Rust is well-supported on the variety of architectures that C is supported on, then that will be the result.
- justin66 5y ago> Until Rust is well-supported on the variety of architectures that C is supported on There's no particular reason to think that this will ever happen. SQLite runs on a lot of crazy stuff that Rust won't want to bother with.
- ecnahc515 5y agoFor rustc with llvm maybe, but there's projects to build a GCC backend for rustc, as well as projects to build a Rust frontend for GCC, both of which could solve this.
- nine_k 5y agoIt cannot "switch" languages in a way like "we stop development in C and switch to development in XYZ only; C-based code will only get security updates". If can switch the officially endorsed "primary" implementation, but only after an alternative implementation has been around for a long time and was battle-tested, all the while the original C implementation continued to exist and develop.
- dathinab 5y agoI don't think a rust version of sqlite would make sense, rewriting a very mature and well tested library rarely makes sense. Only if either: - there are anyway some major changes comming - or major problems/improvements in maintainability and better external dev commitment/support could rewriting it make sense IMHO. Lets be honest many (most?) of the "recent" (~3years) security bugs sqlite had would most likely not have been prevented by using rust, go or similar. EDIT: I guess the biggest drawback of C is that it keeps contributors away, but I also might keep some of the contributors projects like sqlite might not want to have away. So depending on the maintainer it might be seen as a benefit not a drawback.
- tptacek 5y agoThe problem with the first sentence of this comment is that it also justifies keeping stuff like ImageMagick around.
- woodruffw 5y ago> Lets be honest many (most?) of the "recent" (~3years) security bugs sqlite had would most likely not have been prevented by using rust, go or similar. Using SQLite's CVE list from 2020[1], we see 12 vulnerabilities: * Two NULL pointer dereferences; it's impossible to produce a NULL reference in safe Rust. * Two integer overflows; Rust makes these harder, but not impossible. * Three UAFs; these are impossible in safe Rust. * One uncategorized segfault; there are impossible in safe Rust barring environmental constraints (like a stack overflow from unchecked recursion). * One segmentation fault from incorrect object initialization; this is impossible in safe Rust. * 3 SQL and table-level bugs; Rust is unlikely to have helped with these. By my count, that's 6/12 bugs are would be impossible in plain old safe Rust, and another 3/12 that would likely be prevented by normal best practices in Rust. I still don't think this necessarily means that we should drop everything and rewrite SQLite in Rust, but the raw numbers don't back up the claim that doing so wouldn't eliminate the actual security bugs that SQLite is seeing. [1]: https://www.cvedetails.com/vulnerability-list/vendor_id-9237/year-2020/Sqlite.html https://www.cvedetails.com/vulnerability-list/vendor_id-9237...
- PaulDavisThe1st 5y ago
- CraigJPerry 5y agoI think https://gitlab.com/cznic/sqlite https://gitlab.com/cznic/sqlite has become pretty popular. It’s a pure go implementation
- masklinn 5y agoIt is popular not because it's a good idea but because go: using cgo is a huge imposition, so recoding everything in go so it can be used from go is basically the norm. That is useless to sqlite itself, this exists only because of go's issues and is essentially unusable outside of the go ecosystem.
- pjmlp 5y agoDislike for cgo, is similar to the old JNI displeasure, nowadays plenty of Java libraries don't have any issues making use of JNI. The only issue I see with cgo is that they decided to follow such path instead of a proper FFI declaration support like most languages. Even Java is now having such capability thanks Project Panama.
- CraigJPerry 5y agoI’ve noticed cgo dependencies massively slow down compilation. E.g. the hugo project built with and without extended features. Build without and it’s all go, it compiles in the blink of an eye. The tooling in go, from a devops point of view, is surprisingly good. It’s not just compile speed. Build with all the c deps and well you’re compiling more code so of course it’s going to be slower but it’s disproportionately so.
- nikki93 5y agoFWIW, the overhead of calls across the cgo barrier is quite high, which can have API architecture implications -- https://github.com/dyu/ffi-overhead#results-500m-calls https://github.com/dyu/ffi-overhead#results-500m-calls.
- pjmlp 5y ago