Is there still a difference between a library and an API?

后端 未结 8 1667
清歌不尽
清歌不尽 2021-01-29 20:07

Whenever I ask people about the difference between an API and a library, I get different opinions. Some give this kind of definition, saying that an API is a spec and a library

8条回答
  •  猫巷女王i
    2021-01-29 20:28

    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, API is interface to library through which re-usable codes are linked to an 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.

    enter image description here

    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.

提交回复
热议问题