![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Nov 2005
Posts: 11
Rep Power: 0
![]() |
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 ? ![]() |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
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...
__________________
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Nov 2005
Posts: 11
Rep Power: 0
![]() |
So is C++ an API and is there others?
|
|
|
|
|
|
#4 |
|
Professional Programmer
|
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...
|
|
|
|
|
|
#5 |
|
Expert Programmer
|
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.
|
|
|
|
|
|
#6 |
|
Newbie
Join Date: Nov 2005
Posts: 11
Rep Power: 0
![]() |
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?
|
|
|
|
|
|
#7 |
|
Expert Programmer
|
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.
|
|
|
|
|
|
#8 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#9 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
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. |
|
|
|
|
|
#10 | |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,009
Rep Power: 5
![]() |
Quote:
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 |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|