4 ms·
C APIs like ioctl, setsockopt, etc. are perhaps also an example of narrow waists which aren't mentioned in the article. I've been looking for a term for these k
by hlandau 5y ago
C APIs like ioctl, setsockopt, etc. are perhaps also an example of narrow waists which aren't mentioned in the article. I've been looking for a term for these kinds of functions, which seem to be quite successful long-term in terms of API design.
- kevin_thibedeau 5y agoYou can take it to an extreme like with XView which has a half dozen variadic functions for an entire GUI API.
- chubot 5y agoYes, file descriptors and whole file systems are other narrow waists that Unix has, not just files themselves! I want to make diagrams for those too. The terminology I'd use: File descriptors are just a way to do polymorphism in the type system of C. Basically you fall back to an "untyped" integer (similar to void*). Go's interfaces solve this problem pretty directly, much better than C++, which can't really express it in the type system. That is, with the "-er" interface pattern like Reader and Writer. (I think type classes do better too, but I haven't used them much. I'd like to see an article that unpacks this better in the context of file descriptor APIs) This style relates to "versionless evolution". The key issue is that Go doesn't require you to declare that a type supports an interface. It's implicit and the compiler figures it out. That was controversial, but it is the key to enabling evolution. Most programmers are viewing things through the lense of "strictness" and "catching mistakes", rather than evolution. ioctl() is messy as heck but has allowed a lot of evolution. It's highly related to this discussion, which I've linked on the blog before: https://lobste.rs/s/izpz2n/on_missed_opportunities_static_types https://lobste.rs/s/izpz2n/on_missed_opportunities_static_ty... again linked from the main page: https://github.com/oilshell/oil/wiki/Perlis-Thompson-Principle https://github.com/oilshell/oil/wiki/Perlis-Thompson-Princip...