[KLUG Members] API

Adam Tauno Williams adam at morrison-ind.com
Thu Feb 10 07:24:11 EST 2005


> I often see references to 'API' (application-program interface), but
> have never really seen a good definition of it. In fact, the term seems
> to me to be used differently in different contexts. (An application IS a
> program, so what exactly is being interfaced?) Could someone explain
> exactly what API means in the following quotation (from CodeWeavers'
> mission statement):

The "A" in API is the 'other-way-around'.  It isn't an interface TO an
application (usually) it is an interface FOR an application to access services
below it.

>      "re-implementing the Win32 API under Linux"

When you create a traditional (non-.NET, non-Macro, non-Java) application for
Windows you are creating a Win32 application, that is - one that is comprised
of a series of calls to routines provided by 32-bit Windows for applications to
use, like: Draw Window, Put A Button Here,  Register Click Of Button To Call My
Function X, Open The File "C:\Windows\Crash".

The 'below' in "access services below it" can be rather amourphous.  For
instance there is an OpenOffice API, so you can build programs that invoke
methods from Open Office to perform some task - in this sense OO is 'below'
that application in the API stack.

In Linux -
Glibc is the core library that provides an API (does it have a name?) to the
POSIX-ish semantic of the Linux OS.  glib sits on top of glibc and adds some
nicities and hides some of the variation between UNIX platforms.  libX11 sits
on top of Glibc (and glib?) and provides primitive functions for 'put this
bitmap at X,Y' and some basic window management functions.  GTK sits on top of
libX11 and glib and provides the routines to 'associate this button with this
function', 'make a scrollable window at X,Y' and paints the widgets you
actually see in GNOME.  libgnome (and brethereb) sits on top of Gtk and
provides the basic GNOME libraries allowing cut-n-paste, routines so an
application can draw to a virtual page (make circle with diameter X at A in and
B in from corner of page) and send it to a printer, etc...  There are LOTS of
APIs in Linux (actually it is a bit of a problem).

Windows is a monolithic thing so you get one API: Win32  (well, not really true
now, you also have .NET).


More information about the Members mailing list