3 ms·
A lot of the criticism is fair but not the part about runtime os detection. It is vastly preferable over conditional compilation since it is much easier to test
by bjourne 5y ago
A lot of the criticism is fair but not the part about runtime os detection. It is vastly preferable over conditional compilation since it is much easier to test. With conditional compilation you introduce code paths that are only traversed on, say, Windows. If most developers use, say, Linux you will introduce difficult-to-debug system-dependent bugs. This goes for similar things like SIMD-extensions too. If possible, use runtime checking over conditional compilation.
- DenseComet 5y agoWhat? Even with runtime os detection, you won't be running linux code paths on windows. However you do it, you can't test linux apis on windows or windows apis on linux natively.
- bjourne 5y agoYes, you can accomplish that using proxies and/or using the Wine libs.
- jen20 5y agoPlatform specific code is typically implemented in Go using build tags, which are a less flexible form of conditional compilation.