I am trying to understand the difference between an Application Programming Interface and a Library and I stumbled upon this question:
https://stackoverflow.com/questions/3678665/is-there-still-a-difference-between-a-library-and-an-api
And according to one of the answers:
A library contains re-usable chunks of code (a software program).
These re-usable codes of library is linked to your program through APIs (Application Programming Interfaces). That is, this API is an interface to library through which re-usable codes are linked to your application program. In simple term it can be said that an API is an interface between two software programs which facilitates the interaction between them.
For example, in procedural languages like C, the library math.c contains the implementations of mathematical function, such as sqrt, exp, log etc. It contains the definition of all these functions.
These function can be referenced by using the API math.h which describes and prescribes the expected behavior.
That being said, an API is a specification (math.h explains about all the functions it provides, their arguments and data they return etc.) and a library is an implementation (math.c contains all the definitions of these functions).
Stating that the C header file math.h
is an API, while math.c
is a library.
So therefore, when we say "API", we mean "header file"? Is API exactly the same as header file?