nexos wrote:IMO, "true" cross platform development would be binary compatibility. This would require a common executable format, and then a runtime which would decide with OS was being ran on at runtime, and then it would wrap over its API to provide a common API. Such an undertaking would be long, hard, and wouldn't gain a huge amount either. That's why we have JIT languages.
Yeah, totally agree. That's why for native compiled languages we typically just have portable source that uses a given stable portable API (e.g. libstdc++, boost, Qt, etc.). When the source is compiled, it is linked with right libraries pre-compiled for each platform. That's simple, efficient and reasonably convenient to do. Different binaries, but behave the same by doing at runtime different stuff under the hood.
What the OP intended is, clearly, something different, as you said. A single binary that will run everywhere and that's pretty hard to achieve without some sort of
runtime translation from one API to another. For example, originally Microsoft implemented WSL1 directly in their kernel so we could
natively run Linux apps on it. But, the were two problems with that:
1. The substantial overhead inside the kernel to make the Linux syscalls work. Windows has a very different architecture from Linux and it's inevitable to incur in some overhead while trying to behave as Linux. Even if the "emulation" was (still is) inside the NT kernel, some things like I/O couldn't be made as fast on the Linux subsystem as on the Win32 one. The whole idea of supporting multiple subsystems is very cool, but it has too much overhead in practice.
2. The Linux interface evolves continuously and keeping up with that is pretty expensive for the company.
Probably mostly because of the problem 2., Microsoft introduced WSL2, which is substantially a specially managed Linux VM. At the end of the day, virtualizing the whole Linux kernel turned out to be simpler and faster than "emulating" its interface directly.
Still, that's a little sad. The WSL1 idea was so cool. Unfortunately, it's already kind of deprecated and it will dropped at some point.