There is a program that utilizes APIs written in Java, C++, and C. Do you need to describe an ABI for these to function effectively?
From what I understand, an ABI acts as an API at a lower level for an API. (ABI is used to define how different components of binary code can interface for a given operating system on a given architecture)
I am not too sure about this. Correct me if I am wrong and please provide details on whether an ABI is required for an API to function.
There is a program that utilizes APIs written in Java, C++, and C. Do you need to describe an ABI for these to function effectively?
An ABI only covers the low level mechanics - things like how parameters are passed (in CPU registers, on the stack) and a few other details (stack alignment requirements, which registers are "callee saved" and which are trashed by callee, etc). The ABI doesn't care about things like what functions do.
An API is the opposite - it only cares about things like what functions do (how programmers use the API from high level languages), and doesn't care about the low level mechanics (how parameters are passed, etc).
Examples are any of the portable open source libraries (zlibc, SDL, OpenSSL, GMP) or any of the standardized APIs (OpenGL, MPI, the standard library/libraries that are part of the language you're using); where the API is the same regardless of which ABI the compiler happens to be using.
A counter-example is firmware interfaces (e.g. UEFI) where the same specification describes both the API and the ABI (primarily because you can't just recompile and reinstall firmware when you feel like installing a different OS with a different "preferred" ABI).
Note: Because Java primarily uses JIT, it doesn't have a concept of "ABI" (or, the "ABI" is an internal implementation detail that nothing outside the JVM knows about) and code written in Java can't be called by code written in other languages. There are special allowances (the Java Native Interface) to allow Java software to call native code via. whatever ABI the native code uses.
Correct me if I am wrong and please provide details on whether an ABI is required for an API to function.
Technically, some sort of ABI would be needed for the API to function it's just that normally you don't care which ABI it is (in a similar way, some sort of machine code would be needed for high level language source code to be executed, but you rarely have a reason to care which CPU's machine code it is).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With