3 ms·
> Dependency Dog: If you want to see a good example of a leaky abstraction, consider AppKit. Not only is AppKit thread-unsafe to the point where many functions
by gwbas1c 2y ago
> Dependency Dog: If you want to see a good example of a leaky abstraction, consider AppKit. Not only is AppKit thread-unsafe to the point where many functions can only safely be called on the main() thread, it forces you into Apple’s terrifying Objective-C model. Basically any program that wants to have working GUI on macOS now needs to interface in Apple’s way, with basically no alternatives.
Uhm, every OS that I've developed a GUI for has a similar limitation. The "only call this thing from this thread" is a well-known thread safety pattern. It might not be the pattern that this author prefers, but it is an industry standard pattern for UI.
- koito17 2y agoI agree with your comment. Every UI framework I have used (AppKit, Swing, JavaFX, etc.) is not thread-safe. It requires all UI code in the main thread or, in the case of JavaFX, a dedicated UI thread (not necessarily the main thread, but it must be a single thread where all UI operations occur).
- etcd 2y agoWPF was the same IIRC
- solarkraft 2y agoyup!
- gwbas1c 2y agoThat's how winforms did it; and I suspect that's how the underlying Windows OS needs it done too.
- mike_hearn 2y agoTechnically in JavaFX you can work with UI objects off the main thread, for instance to load or build up UI in parallel. The single thread requirement only kicks in when UI is attached to a live window (stage).
- hinkley 2y agoIBM made a similar decision before the larger Java community thought it was anything like a good idea.
- vacuity 2y agoEven outside of UI, use-from-one-thread-only is perfectly valid and acceptable. The issue at that point is with the tools (e.g. C), not the API. If the API provides thread-safe entry points, that's because it is taking on the responsibility of synchronizing. Maybe that's fine for a particular API, but it shouldn't be expected for everything. It's an added layer of complexity, hidden from the programmer, so expect it to be absent in more optimized cases.