← Back to context

Comment by rhelz

1 year ago

Its kind of cool that you can abstract the operating system with only a 200-line long header file.

This is the interface description. It's not the .c file that implements the abstraction. There is lots of code behind this, redundantly implementing the calls using either Win32 or POSIX.

  • But you do not need to know about them if abstraction works, I assume it is sufficient for SQLite use case.

    • The filesystem APIs for Windows and POSIX have extremely similar semantics when you bridge their superficial differences. I don't think this is as huge an achievement as suggested. Many multiplatform projects have similar wrapper layers. Indeed the FILE* abstraction in the C standard does some of it. (But not sufficient for the functionality that sqlite needs, hence the need for another wrapper.)

      That's not a knock on sqlite, I consider it well implemented and one of my favorite libraries I've ever seen, used and studied.

      2 replies →

  • // This is the interface description //

    Yeah, but that is the abstraction. The associated .c files are not the abstraction, because they could be implemented any number of different ways, and it would still be the same abstraction.

    It's incredible that even the header file is around 200 LOC. For state-of-the-art, very performant database, I would have thought that all manner of Os-specific IO api's would have to be used.

    • I don't find it that remarkable. They are function signatures for open, close, read, write, a few locking operations... The signatures for the same operations on both Win32 and POSIX look extremely similar to this. These are fairly "obvious", most multiplatform code written in C has something pretty close to this.

The dividends of damn near everyone who still matters copying Unix and developing similar ideas about subdirectories and filenames and so on.

There's still differences between Windows and Everything Else, but it's easier to ignore them now that, for example, all of the old flat file systems with no directories (like on the original MacOS, CP/M, MS-DOS 1) are all comprehensively obsolete and ignored.

  • > all of the old flat file systems with no directories (like on the original MacOS, CP/M, MS-DOS 1) are all comprehensively obsolete and ignored.

    not quite true. The classic flat OS/360 filesystem is still heavily used on IBM mainframes. Of course, probably your app will never run on a mainframe, and if it does, it will probably run either under z/Linux or the z/OS UNIX filesystem (zFS). But there is still a lot of actively supported in-production software which does, since born-on-the-mainframe apps mostly use the classic filesystem and the POSIX file API is mainly used by apps ported from elsewhere