4 ms·
I’m not sure if I would call SQLite’s needs incommon — in a perfect world, every app should have SQLite’s properties like preserving user data on power loss, et
by pcr910303 6y ago
I’m not sure if I would call SQLite’s needs incommon — in a perfect world, every app should have SQLite’s properties like preserving user data on power loss, etc… It’s just that other apps just don’t care enough about these issues as much as SQLite.
For example, I’m pretty sure I would like every app to automatically handle cases where the underlying file gets renamed or removed. (AFAIK apps that use the Cocoa API automatically does these.) However there really isn’t any POSIX API that allows handling these kind of situations — and to do these now you need to do all of these nitty-gritty things that SQLite does.
In fact, I think that the reason why SQLite needs all of these nitty-gritty details that does everything is because of an insufficient abstraction. If the file APIs were better and didn’t require everyone to consider whether you have to call fsync or not, SQLite wouldn’t have needed any of these. But well POSIX have flied and here we are.
- dahart 6y agoThe API doesn’t need to expose whether data is preserved on power loss. Normally these days, it is, and it’s implemented underneath the API. I don’t think the POSIX API is perfect by any stretch, but there is a real downside to going lower level, in terms of productivity, in terms of mis-use and accidents, in terms of security, and in terms of ability to support old hardware, heterogeneous storage devices, networked storage devices, etc. If there was a huge and unanimous demand for the low level features SQLite uses, the API would already expose those features. APIs sometimes are too high level, and sometimes are too low level. Getting it wrong in either direction has negative consequences. And getting it exactly right is hard. In any case, I’m unconvinced that the Linux filesystem API is abstracted at the wrong level or represents a good example of an API that is too high level.