3 ms·
This type of standardization is what I like to call Lowest Common Denominatorism. And it's a leaky solution to a hard problem. The underlying problem isn't that
by saosebastiao 10y ago
This type of standardization is what I like to call Lowest Common Denominatorism. And it's a leaky solution to a hard problem. The underlying problem isn't that different platforms have different APIs, it is that different platforms have different capabilities. Even if you unify the APIs that are semantically equivalent across platforms, there will always be some superset of that unified standard that you end up having to use because you are programming for a platform. At best, the unification makes programming for a different platform slightly easier and a little more tenable to share some code across platforms. But your code is still littered with `#if`s everywhere, and that wreaks havoc on your compiler's (and subsequently your IDE's) usefulness for catching bad bugs due to platform incompatibilities.
I believe the future of cross platform programming is by integrating Tomas Petricek's idea of Co-Effects[0] into type systems. While an effect system tracks what your program does to the world in its type system, a co-effect system tracks what your code requires from the world, aka the executable's environment and platform. There are a lot of benefits to this, but the primary benefit of a co-effect system is that you could safely write cross-platform cross-compiled code within a single compilation unit project by having different `main`s that specify and encodify different platform capabilities. If your `getSDCardFileSystem` function only works on Android because iOS doesn't have SD card capabilities, then it can't be used in a main function bound by the iOS context. And if different platforms have similar but slightly different capabilities, an interface can be defined that shares their commonalities and is usable across the differing platform executables, while still making platform-specific code accessible within it's platform specific executable.
There are other benefits too, but I'll leave that to the reader of [0] if they want to know more.
[0] http://tomasp.net/blog/2014/why-coeffects-matter/ http://tomasp.net/blog/2014/why-coeffects-matter/