PDA

View Full Version : what does API mean?




Darkroom
Mar 8, 2008, 10:24 AM
i understand it's an acrynom that means "Application Programming Interface", but what does that mean? in laymen's terms please... i'm not the sharpest cookie in the breadbox :rolleyes:



antibact1
Mar 8, 2008, 10:28 AM
... i'm not the sharpest cookie in the breadbox :rolleyes:

I figured that out from your post. Try Google next time. Second result for API is wikipedia. Very informative. It also links to a Computer World article that could help you. Don't be so lazy.

Darkroom
Mar 8, 2008, 10:30 AM
I figured that out from your post. Try Google next time. Second result for API is wikipedia. Very informative.

oh snap... yeah i read the wikipedia entry, still don't get it.

antibact1
Mar 8, 2008, 10:32 AM
oh snap... yeah i read the wikipedia entry, still don't get it.

Try Googling "what is an api". Provides some more useful information. If you can't find something on Google about this that will help you, you certainly won't understand what an API is.

gnasher729
Mar 8, 2008, 10:41 AM
i understand it's an acrynom that means "Application Programming Interface", but what does that mean? in laymen's terms please... i'm not the sharpest cookie in the breadbox :rolleyes:

I'll give you an example. Let's say you write a program for the iPhone. And if the user presses a certain button, then the iPhone is supposed to call _you_. Your phone number is 1234-5678-9123. So if your program is written in C, C++, Objective-C, or Java, you would have written some code that looks like

if (PhoneHomeButtonPressed ()) {
... something must go here...
}

That's were the API comes in. The API describes what function or functions you must call to do what you want to do. It doesn't say how these functions work, that can actually change. The code in the iPhone operating system that dials a phone number could be different in iPhone 1.1 and iPhone 2.0. But that doesn't matter. The API (Application Programming _Interface_) tells you what the interface looks like, for example

if (PhoneHomeButtonPressed ()) {
iPhoneHardware.DialNumber ("1234-5678-9123");
}

(I just made the code up completely, but it would be half reasonable that the actual call might look like this). So an API describes what application programmers need to know to use the features of an iPhone. It doesn't say how the feature works, that is often of no interest to you.

The API would also tell you what you would have to do to say call a phone number in France, or call a phone number in France if the phone itself is in Britain and not in Germany or the USA (you might have to do things differently), and it would tell you how to find your location.

So a programmer needs to know two things: They need to know the general rules of programming. How to put things together logically. These are things that work the same on every computer. And then they need to know the rules for the features of the computer they are programming for, and that is the API.

Darkroom
Mar 8, 2008, 10:56 AM
I'll give you an example. Let's say you write a program for the iPhone. And if the user presses a certain button, then the iPhone is supposed to call _you_. Your phone number is 1234-5678-9123. So if your program is written in C, C++, Objective-C, or Java, you would have written some code that looks like

if (PhoneHomeButtonPressed ()) {
... something must go here...
}

That's were the API comes in. The API describes what function or functions you must call to do what you want to do. It doesn't say how these functions work, that can actually change. The code in the iPhone operating system that dials a phone number could be different in iPhone 1.1 and iPhone 2.0. But that doesn't matter. The API (Application Programming _Interface_) tells you what the interface looks like, for example

if (PhoneHomeButtonPressed ()) {
iPhoneHardware.DialNumber ("1234-5678-9123");
}

(I just made the code up completely, but it would be half reasonable that the actual call might look like this). So an API describes what application programmers need to know to use the features of an iPhone. It doesn't say how the feature works, that is often of no interest to you.

The API would also tell you what you would have to do to say call a phone number in France, or call a phone number in France if the phone itself is in Britain and not in Germany or the USA (you might have to do things differently), and it would tell you how to find your location.

So a programmer needs to know two things: They need to know the general rules of programming. How to put things together logically. These are things that work the same on every computer. And then they need to know the rules for the features of the computer they are programming for, and that is the API.

thanks for the response gnasher...

just to clarify Interface Builder works in it own way that's different from another GUI builder say on a windows machine, so since programmers have to follow the rules of this unique application to build apps for mac os x, is Interface Builder also considered an API?

or is it just stuff like the carbon frameworks that are the APIs?

and finally, what's the difference between a high-level API and low-level API?

admanimal
Mar 8, 2008, 10:56 AM
Another answer is that an API is a set of programming libraries (i.e. ready-made code) provided by a third party that allows you to access features of their system/software/device in your own programs. Examples:

The iPhone SDK provided by Aapple gives you an API for accessing iPhone features like the accelerometer and the touch screen gestures.

The Windows SDK provided by Microsoft allows programmers to access Windows features like creating actual windows, printing, etc.

(In case you haven't noticed SDKs pretty much always include API libraries).

admanimal
Mar 8, 2008, 10:59 AM
Interface Builder also considered an API?



Interface Builder itself is just an application that helps you build resource files (aka NIB files) which can be used in conjunction with the Mac OS APIs.

Strictly speaking, an API only includes code libraries/frameworks that allow people to program for a particular system. Other tools like XCode, Interface Builder, etc. are not part of the API but are part of the SDK.

Darkroom
Mar 8, 2008, 11:07 AM
Another answer is that an API is a set of programming libraries (i.e. ready-made code) provided by a third party that allows you to access features of their system/software/device in your own programs. Examples:

The iPhone SDK provided by Aapple gives you an API for accessing iPhone features like the accelerometer and the touch screen gestures.

The Windows SDK provided by Microsoft allows programmers to access Windows features like creating actual windows, printing, etc.

(In case you haven't noticed SDKs pretty much always include API libraries).

Interface Builder itself is just an application that helps you build resource files (aka NIB files) which can be used in conjunction with the Mac OS APIs.

Strictly speaking, an API only includes code libraries/frameworks that allow people to program for a particular system. Other tools like XCode, Interface Builder, etc. are not part of the API but are part of the SDK.

thanks admanimal... i think i get it now...

solid...

psingh01
Mar 10, 2008, 04:10 PM
All programs are made of code written in some language. An API is simply a collection of code that has been already written for you to use. That way the developer doesn't waste time re-writing the same things over and over and everyone has a consistent way of doing things. For example creating a windows on the screen. All windows should look and behave the same (generally speaking). There is no point in having each program custom write code to do that. So Apple wrote it and other developers just use it to create windows. API's are not for just windows or GUI stuff of course. It could be anything. Reading/Writing to files. Creating connections over a network. Sorting data. Down to just low level system stuff. The API's are there to let you worry about your own program and less about how to do things that the Operating System should handle.

This may not make much sense, but this is the documentation for the Java API to give you an idea:

http://java.sun.com/j2se/1.5.0/docs/api/

Michael CM1
Mar 12, 2008, 04:09 AM
All programs are made of code written in some language. An API is simply a collection of code that has been already written for you to use. That way the developer doesn't waste time re-writing the same things over and over and everyone has a consistent way of doing things. For example creating a windows on the screen. All windows should look and behave the same (generally speaking). There is no point in having each program custom write code to do that. So Apple wrote it and other developers just use it to create windows. API's are not for just windows or GUI stuff of course. It could be anything. Reading/Writing to files. Creating connections over a network. Sorting data. Down to just low level system stuff. The API's are there to let you worry about your own program and less about how to do things that the Operating System should handle.

This may not make much sense, but this is the documentation for the Java API to give you an idea:

http://java.sun.com/j2se/1.5.0/docs/api/

After being thoroughly confused through most of the iPhone event, that is probably the best explanation I've heard. It would be extremely wasteful for everybody to have to do the same thing over and over and over again. I think if someone had ever said "API = Quark template," that would've helped me a lot. It also explains the whole point of the SDK a lot better.