Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 20th, 2005, 10:52 PM   #1
BrinyCode
Newbie
 
Join Date: Nov 2005
Posts: 11
Rep Power: 0 BrinyCode is on a distinguished road
Unhappy Why API terminology?

Okay personally I do not understand what is an "API" and why it is called "application development interface?" Is there something that contrasts it? I already tried google and wiki and can't find an interpretation that is clear...


I figure we already have C++ and compilers, so why do we need this term "API." How do you differentiate this ?
BrinyCode is offline   Reply With Quote
Old Nov 20th, 2005, 11:05 PM   #2
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
An API ("Application Programming Interface") is a type of code that let's you interact with an application, thus the Win32 API, which lets you interact with Windows...
__________________

tempest is offline   Reply With Quote
Old Nov 20th, 2005, 11:23 PM   #3
BrinyCode
Newbie
 
Join Date: Nov 2005
Posts: 11
Rep Power: 0 BrinyCode is on a distinguished road
So is C++ an API and is there others?
BrinyCode is offline   Reply With Quote
Old Nov 21st, 2005, 12:15 AM   #4
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 294
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
C++ is a programming language. API are a set of functions you can call upon to leverage a framework, application, or set of libraries. Windows API, DirectX API, etc...
andro is offline   Reply With Quote
Old Nov 21st, 2005, 2:03 AM   #5
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 4 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
So you can use a language such as C++, then if you wanted to code in 3D you would get the OpenGL API. It is sort of like an extension of functions that allow the programmer to do a specific task.
__________________
Join us at #programmingforums @ irc.freenode.net!

My software never has bugs. It just develops random features.
coldDeath is offline   Reply With Quote
Old Nov 21st, 2005, 2:14 PM   #6
BrinyCode
Newbie
 
Join Date: Nov 2005
Posts: 11
Rep Power: 0 BrinyCode is on a distinguished road
Okay, so OpenGL and Direct X are the APIs, right (any more)? That's kind of odd because I thought C++ can code in 3D by itself. Why do we need an outsider like API ? Isn't C++ powerful enough?
BrinyCode is offline   Reply With Quote
Old Nov 21st, 2005, 2:22 PM   #7
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 4 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
C++ is very powerful, but it isn't designed to have every API included in it, otherwise it would be bloated and fall out of date quickly. APIs are written to "extend" a languge so taht it can perform a special task.

For instance, what happens if it comes with the Win32 API built in, and then Windows is update d to a new version that C++ didn't support? All that needs to happen with APIs is that microsoft change the API and the new version can be included.
__________________
Join us at #programmingforums @ irc.freenode.net!

My software never has bugs. It just develops random features.
coldDeath is offline   Reply With Quote
Old Nov 21st, 2005, 3:52 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Consider, further, that you have written some very complex code that you would like to be able to market to people using different operating systems. If you make a standard interface that looks the same on the surface, to the programming user, then that user may move from one operating system (say, Windows) to another (say, Linux) without learning a new way to use the same tool.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 21st, 2005, 4:11 PM   #9
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Basically, C++ is the language. C++ itself doesn't actually have any functions at all - it just has some commands you can use to start building a program. Even things like cout and cin - the output and input objects - are in an API - the Standard Template Library.

An Application Programming Interface contains code written by other people to make your life a bit easier, and to make sure there's only a few ways to do the same thing. If everyone used different code, imagine how annoying trying to take over someone else's project would be. By using, say, the OpenGL API for 3D graphics rendering, anyone with knowledge of the API can give you a hand, or even take over if the need arises.

Some languages have their standard APIs built in. Pascal is a good example - the writeln function, which writes a line of text to the screen, is part of the language. Because Pascal is primarily a teaching tool, that's fine - it's designed to be used with a screen and a keyboard. However, C++ imposes no such restrictions. If you were writing software for a scanner, where would it write to? The cout function isn't necessary for the scanner - it'd just add in extra bloat. It's also different on every single architecture type - your phone will have different machine commands to your computer to draw a number onto the screen. Because everything's in an API or written by you, C++ is infinitely more flexible than it would be otherwise.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 21st, 2005, 5:11 PM   #10
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,009
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by BrinyCode
Okay personally I do not understand what is an "API" and why it is called "application development interface?" Is there something that contrasts it? I already tried google and wiki and can't find an interpretation that is clear...


I figure we already have C++ and compilers, so why do we need this term "API." How do you differentiate this ?
Others have done a pretty good job, but here's my explanation.

An API is an interface. It's a collection of functions (or procedures, or methods, or whatever you'd like to call them) that behave in a predictable way to accomplish tasks. The underlying code might differ from system to system, but the API remains constant.

For example, all MS Windows operating systems have a CreateWindow() function. It's part of the API. An application calls this function to (you guessed it) create a window. The parameters it takes are likewise described in the API documentation. However, the function itself will be vastly different 'under the hood' between different flavors of Windows, such as Win98 vs Win2000, or WinXP vs WinCE (for mobile devices).

It's kind of like a steering wheel in a vehicle. You don't have to learn how to operate each individual steering wheel; it's a standard interface. You turn it left, and the car/truck/boat/whatever turns left.

Some APIs are rather simple, with only a few functions, whereas others may have hundreds or thousands of functions. The C and C++ APIs are quite rich in terms of functionality, with a plethora of functions to do a wide range of tasks. Individual environments provide additional APIs for system-specific features. That's why you will likely use multiple APIs in any given real-world program. For example, you might use the C++ API for stuff like memory allocation, file I/O, and creating linked lists, and the Win32 API for developing your application's GUI front-end. You might use a sockets API for network communication, and another API to access a database.

By making these part of an API, rather than part of a language, you get two benefits. First is that programmers are not forced to use a particular language. As long as the language and compiler they use can call the functions properly (ie, supports appropriate argument types and calling conventions, among other things), it can be used to develop applications using that API. Second, the language itself is not bloated if code specific to certain tasks or platforms is put into an appropriate API. There is no need for a GUI API as part of C++, since C++ can (and often is) used to develop code on platforms that have no concept of a GUI.

I hope this clarifies it.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:55 AM.

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