Because we already have operating systems. Java is not designed to work on bare metal, but it is not as strong as it might seem at first glance. Because C compilers provide built-in functions that are compiled for specific instructions, the Java compiler (or JIT, this distinction makes no sense in this context) can do the same. It would also be difficult to handle the interaction of the GC and the memory manager. But it can be done. The result is a kernel with 95% Java and ready-to-run jars. What's next?
Now it's time to write an operating system. Device drivers, file system, network stack, all other components that allow you to do something with the computer. The Java standard library usually relies on system calls to make a heavy lift, both because of this and because starting a computer is a pain in the ass. Writing a file, for example, includes the following layers (at least I'm not a guy from the OS, so I probably skipped the material):
- The file system, which should find a place for the file, updates its directory structure, processes logging, and finally decides which disk blocks should be written and in which order.
- The block level that must plan for simultaneous writing and reading in order to maximize throughput and maximize fairness.
- A device driver that should keep the device happy and push it in the right place for everything to happen. And, of course, each device is broken in its own way, requiring its own driver.
And all this should work fine and remain executed with a dozen threads, accessing the disk, because the disk is essentially a huge bunch of shared mutable state.
In the end, you have Linux, except that it does not work, because it does not have almost as much effort as is invested in functionality and performance, and only Java works in it. Perhaps you get performance from one address space and without differentiating the kernel / user, but the gain is not worth the effort.
There is one place where language-specific OS makes sense: VM. Let the underlying OS handle the hard parts of the computer, and the tenant operating system process the virtual machine in runtime. BareMetal and MirageOS follow this model. Why would you do this instead of using Docker? That's a good question.
source share