Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Other Programming Languages (http://www.programmingforums.org/forum38.html)
-   -   what is the difference between an API and a library? (http://www.programmingforums.org/showthread.php?t=5597)

linuxpimp20 Aug 27th, 2005 4:46 AM

what is the difference between an API and a library?
 
hi. i didn't know what API stands for so i looked it up. to me a library and an API sound similar to a library but im sure there are some differences that i don't know about. It soundslike a library could be part of an API but i dunno. Is a library moreso to make new programs and an API is to help developers develop an existing program? thanks for any replies in advance

Polyphemus_ Aug 27th, 2005 5:27 AM

just google for 'define:api'. You will find loads of definitions.

One description:
Quote:

API
application program interface; the specific method prescribed by a computer operating system or by another application program by which a programmer writing an application program can make requests of the operating system or another application.

grumpy Aug 27th, 2005 5:28 AM

A library is not part of an API; the reverse is closer to being true. The API (Application Programmers Interface) is the specification of how applications can use the library.

linuxpimp20 Aug 27th, 2005 5:33 AM

Quote:

Originally Posted by Polyphemus_
just google for 'define:api'. You will find loads of definitions.

One description:

i did so prior to posting.

linuxpimp20 Aug 27th, 2005 5:36 AM

Quote:

Originally Posted by grumpy
A library is not part of an API; the reverse is closer to being true. The API (Application Programmers Interface) is the specification of how applications can use the library.

so they aren't really similar but closely tied? An API is rules on how to use a library? Does that mean it is another layer between the library and program so the program is more modular and if it need to be ported to use a new library you just have to alter the API? thanks for your quick replies.

stevengs Aug 27th, 2005 5:55 AM

Quote:

Originally Posted by linuxpimp20
so they aren't really similar but closely tied? An API is rules on how to use a library? Does that mean it is another layer between the library and program so the program is more modular and if it need to be ported to use a new library you just have to alter the API? thanks for your quick replies.

The API is, as the name states, the interface specification. It specifies how the application programmer should use the library and the behaviour of the library in reaction to calls. For a call to a function, pre-call states and post-call states are defined, parameter types, return types, events, error codes, etc. etc. It does not, in accordance with the 'black box' principle, explain what goes on INSIDE the library. This information should not be necessary, and if the library developer were to change the internal design, it could possibly be harmful.

DaWei Aug 27th, 2005 7:25 AM

You don't want to write the all code to operate your system. You don't even want to learn all the code that already exists to operate your system. All you want to do is learn to invoke the code that operates your system. If the invocations are standardized, remain unchanged, and always result in the promised operation, you are in Fat City. If the operations are improved internally without deep-sixing your efforts, no sweat. This little piece of lagniappe given you by the people that actually wrote all that code, is the API. In my opinion, it includes the small layer of software necessary to standardize the invocations, as well as the detailed instructions for using it.


All times are GMT -5. The time now is 5:34 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC