4 ms·
I don't really get what the author is driving at. Sure, each system has quirks so designing a portable FFI is difficult to say the least. But what's the alterna
by prerok 4y ago
I don't really get what the author is driving at. Sure, each system has quirks so designing a portable FFI is difficult to say the least. But what's the alternative?
In my experience I have seen plenty of standards violated and downright disregarded because the platform has special functionalities or quirks. My view is that even if there was an ironclad ABI spec platforms would still violate it with their special implementation of the system interface.
I think we would end up with exactly the same problems only the rant would not be targetting C but something else.
- anfilt 4y agoThat's my thought as well. It probably would be even worse. For instance it possible to write a leaf function in assembly for AMD64 that runs both on linux and windows if all you do is return a value. This is because they both use RAX as the return register. There subtle difference between the two but that is mainly what registers are used. The biggest difference comes in the stack layout. Now when it comes to pretty much any other OS for instance on x64 they pretty much use the System V calling convention. The thing is if C was not the glue, I could imagine the ABI would be wildly different on each OS heck maybe even each version of the OS. If we look at windows you can't safely call any system calls directly since a major update could change the system call number. However, windows provides wrappers around these system calls. Linux is an outlier in OSes that considers changing system calls like this as breaking user-space. Now if we did not have C what would operating systems be using to wrap all these system calls? I suspect something tailored to that OS specifically and it would be quite the mess so I bet it would even be worse to handle. Since at least C keeps things similar. Whereas without it you would get OS specific schemes that could vary by a lot more! Making the code base to support multiple platforms even larger.
- haberman 4y agoThat was exactly my reaction when this article was last on HN: https://news.ycombinator.com/item?id=30706326 https://news.ycombinator.com/item?id=30706326
- prerok 4y agoThanks for the link. You put it much better than I did :)