News for hackers. Stuff that matters.
Re:Portable software is more complex than you think by api on Tuesday December 07, 2021 @05:03PM (#29478785)
A good pattern is to separate the core logic from the code that interacts with the platform. If these are tangled up porting becomes a nightmare.

Our approach to portability in ZeroTier is to make the core, our "network hypervisor," a completely OS-neutral chunk of code that interacts only via an API. It contains literally no system calls, I/O, etc. Then there's a service harness for desktops, servers, phones, etc.

Re:Portable software is more complex than you think by ansgri on Wednesday December 08, 2021 @10:12AM (#29485662)
The problem is, for this to work the API itself must be cross-platform, which means it's either an incomplete abstraction (exposes many options, only some of which are implemented on a given platform), overly restricting (lowest common denominator leading to suboptimal performance and restricted development agility on advanced platforms), or not really cross-platform (supports one platform well but others are inefficient -- might as well use a virtual appliance).

In reality the API is part of the core logic except for purely computational services and therefore all core logic can rarely be fully encapsulated.

Re:Portable software is more complex than you think by weq on Thursday December 09, 2021 @02:12AM (#29494710)
You need to design your system with appropriote trade-offs. If you want to be everything to everyone you will end up in mess you describe. Cross-platform game, coreutils or LOB are all different beasts. Unity shows how API surface level will get polluted as you strive for speed in your cross-platform game, but on the flip side you run on all platforms without overhead.

I tend to use DDD and the egg-shell pattern, building a domain / service model in portable code, and leaving the platform specific code to the outer shell behind a refined abstraction. I dont have any APIs with overloads, but sometimes the backing API is a no-op.