We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › extreme noob question: What exactly is API
Page Index Toggle Pages: 1
extreme noob question: What exactly is API? (Read 527 times)
extreme noob question: What exactly is API?
Jun 29th, 2009, 5:37pm
 
I'm having some trouble understanding this. Is the Processing API essentially the same thing as Processing language? Or are only the built-in functions considered the API? Or is it something else entirely? I understand that operating systems also have APIs. How do the Processing API and OS API relate to each other?
Re: extreme noob question: What exactly is API?
Reply #1 - Jun 29th, 2009, 9:50pm
 
An API (application programming interface) is basically a the list of functions or commands that a program responds to. While there is plenty going on "under the hood" of Processing as a program, the API details what is "visible" (or publicly accesible) to the programmer. An external library will also have an API, its own list of new commands that extend the functionality of the programming language.

Processing has an API (all of its methods, variables, etc listed in its reference). Any software that can be manipulated via code has an API. Google released a search engine API, a list of functions that people can put in their code that query Google's search engine. Operating systems have low-level API's at their very basest levels, so that the software running on the operating system can properly communicate with the OS to query or request things like memory, USB ports and other hardware access, networking, etc. But a programming language (usually) takes care of that type of negotiation for you, so when you are writing code, you usually only need the programming language's API.

When you compile the code you've written (in processing, whenever you hit the play button, you are both compiling the code and then executing it), the compiler (which is OS-specific) then converts your written code into machine code, which will likely be informed by the compiler asking for functionality information from the OS (or libraries of the OS). As an example: if I want to draw a 3D cube using openGL, it is just a few lines of code in Processing, and my code will work on any operating system. But once I compile/run it, Processing (which is built upon Java) will use a function of a native (machine-specific) library to find out what exact series of bytes it has to send to my graphics card in order to carry out my command to draw a cube onto the screen.

So there's really no reason for you to worry about OS API's unless you are doing very advanced that cannot be down within the bounds of Processing.

Re: extreme noob question: What exactly is API?
Reply #2 - Jul 1st, 2009, 4:35pm
 
This is a better explanation than anything I was able to find online. Thank you very much!
Page Index Toggle Pages: 1