Difference between an API and Library
Moderator: Coders of Rage
- Pennywise
- Chaos Rift Cool Newbie
- Posts: 55
- Joined: Tue Sep 22, 2009 1:36 pm
- Favorite Gaming Platforms: Megadrive(Genesis), Dreamcast, SNES, Nintendo 64
- Programming Language of Choice: C, C++ and Java
- Location: England
Difference between an API and Library
Hi everyone.
I was just wondering what the difference between an API and a library was.
I hear that OpenGL is a Library and an API and I was wondering what the difference was.
Thanks
I was just wondering what the difference between an API and a library was.
I hear that OpenGL is a Library and an API and I was wondering what the difference was.
Thanks
Re: Difference between an API and Library
It is more like a library has a API (application programming interface). The API is your access point to the library.
- Pennywise
- Chaos Rift Cool Newbie
- Posts: 55
- Joined: Tue Sep 22, 2009 1:36 pm
- Favorite Gaming Platforms: Megadrive(Genesis), Dreamcast, SNES, Nintendo 64
- Programming Language of Choice: C, C++ and Java
- Location: England
Re: Difference between an API and Library
So a library has an API.
Is it like how C++ has a compiler(GUI - Graphical User Interface) or different?
Is it like how C++ has a compiler(GUI - Graphical User Interface) or different?
Re: Difference between an API and Library
A GUI is not part of a compiler. You are talking about an IDE, however, it's not comparable.
Why don't you just do a websearch? http://en.wikipedia.org/wiki/Applicatio ... _interface
Why don't you just do a websearch? http://en.wikipedia.org/wiki/Applicatio ... _interface
- Pennywise
- Chaos Rift Cool Newbie
- Posts: 55
- Joined: Tue Sep 22, 2009 1:36 pm
- Favorite Gaming Platforms: Megadrive(Genesis), Dreamcast, SNES, Nintendo 64
- Programming Language of Choice: C, C++ and Java
- Location: England
Re: Difference between an API and Library
Yep, I did a few times but did not quite understand it. ^^
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Difference between an API and Library
Think of it this way.
You have a car. The car is the library.
The car has a door, steering wheel and gas pedal. This is the API.
At least, that's what I get from what K-Bal said. I'm not quite sure myself =)
You have a car. The car is the library.
The car has a door, steering wheel and gas pedal. This is the API.
At least, that's what I get from what K-Bal said. I'm not quite sure myself =)
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Difference between an API and Library
An API offers a level of abstraction between you and something. A library can or cannot have/be an API, but pretty much always an API will be a (or in a) library.
Think about something like OpenGL. It offers a level of abstraction between you (the programmer) and the video hardware, by giving you things like hardware accelerated rendering. OpenGL is an API. It is also a library.
Look at SDL. It is a library, but it is also a collection of APIs. It has a video API that gives you 2D blitting, an audio API that allows you to play sound and music, then timer, networking, and input--these all offer levels of abstraction between hardware and the programmer.
The Lua library has an API that allows the programmer to interact with Lua (states) at a higher level.
A library is simply a group of functions (and/or classes) compiled as a .lib (or .dll) that your program can statically (or dynamically) link to. When you use cout and printf, they're available because you're linking to the C and C++ standard libraries. These functions aren't considered APIs, because they aren't offering a layer of abstraction between you and something.
Think about something like OpenGL. It offers a level of abstraction between you (the programmer) and the video hardware, by giving you things like hardware accelerated rendering. OpenGL is an API. It is also a library.
Look at SDL. It is a library, but it is also a collection of APIs. It has a video API that gives you 2D blitting, an audio API that allows you to play sound and music, then timer, networking, and input--these all offer levels of abstraction between hardware and the programmer.
The Lua library has an API that allows the programmer to interact with Lua (states) at a higher level.
A library is simply a group of functions (and/or classes) compiled as a .lib (or .dll) that your program can statically (or dynamically) link to. When you use cout and printf, they're available because you're linking to the C and C++ standard libraries. These functions aren't considered APIs, because they aren't offering a layer of abstraction between you and something.
Re: Difference between an API and Library
Although it would be harder to write a text pixel per pixel in the framebufferGyroVorbis wrote:These functions aren't considered APIs, because they aren't offering a layer of abstraction between you and something.
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Difference between an API and Library
Trust me, it is.K-Bal wrote:Although it would be harder to write a text pixel per pixel in the framebufferGyroVorbis wrote:These functions aren't considered APIs, because they aren't offering a layer of abstraction between you and something.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- Pennywise
- Chaos Rift Cool Newbie
- Posts: 55
- Joined: Tue Sep 22, 2009 1:36 pm
- Favorite Gaming Platforms: Megadrive(Genesis), Dreamcast, SNES, Nintendo 64
- Programming Language of Choice: C, C++ and Java
- Location: England
Re: Difference between an API and Library
I been looking it up better and found this out:
API (Application Programming Interface)
Refers to how you interact with the library. A good API makes it very easy to code with the library. Usually when people say they prefer Direct 3D or OpenGL they are talking about the API.
Library
Other code that someone has written so you don't have to. Your code uses the library to perform tasks that might be impossible otherwise (Windowing, Networking, fast 3D graphics) or might just take a lot of code that you don't want to write (compression, image loading, XML parsing)
I found this on gpwiki.org.
I get it now. Thanks for your help ^^
API (Application Programming Interface)
Refers to how you interact with the library. A good API makes it very easy to code with the library. Usually when people say they prefer Direct 3D or OpenGL they are talking about the API.
Library
Other code that someone has written so you don't have to. Your code uses the library to perform tasks that might be impossible otherwise (Windowing, Networking, fast 3D graphics) or might just take a lot of code that you don't want to write (compression, image loading, XML parsing)
I found this on gpwiki.org.
I get it now. Thanks for your help ^^
- Pennywise
- Chaos Rift Cool Newbie
- Posts: 55
- Joined: Tue Sep 22, 2009 1:36 pm
- Favorite Gaming Platforms: Megadrive(Genesis), Dreamcast, SNES, Nintendo 64
- Programming Language of Choice: C, C++ and Java
- Location: England
Re: Difference between an API and Library
One more question:
Can someone recommend me what scripting language I should learn please
Thanks
Can someone recommend me what scripting language I should learn please
Thanks
Re: Difference between an API and Library
Don't bother implementing scripting functionality in your program until you are really firm in your primary language and complete some projects.Pennywise wrote:One more question:
Can someone recommend me what scripting language I should learn please
Thanks
- Pennywise
- Chaos Rift Cool Newbie
- Posts: 55
- Joined: Tue Sep 22, 2009 1:36 pm
- Favorite Gaming Platforms: Megadrive(Genesis), Dreamcast, SNES, Nintendo 64
- Programming Language of Choice: C, C++ and Java
- Location: England
Re: Difference between an API and Library
Oh God No
I was just asking for future reference
I was just asking for future reference