Sunday, May 13, 2012

So what is an API, anyway? And why is Google so evil for copying one?

(Woops, I missed a day.  I was travelling over the weekend to see Mom and I guess I lost track.

I'll die before it happens again.)

In the news lately, Oracle has been suing Google for copying "its" Java API's in Android.  For 99.9% of people, this raises the question, "what the hell is an API?"  That's a good question, and I'm going to show you, because you can't really think about something if you don't know what it is.

API stands for Application Programming Interface.  Here is the first paragraph from that Wikipedia page, which won't mean anything to you:

An application programming interface (API) is a specification intended to be used as an interface by software components to communicate with each other. An API may include specifications for routines, data structures, object classes, and variables. An API specification can take many forms, including an International Standard such as POSIX or vendor documentation such as the Microsoft Windows API, or the libraries of a programming language, e.g. Standard Template Library in C++ or Java API.

Now, I'm going to show you what that really means, and hopefully that will give you some vague idea of what the above is all about.

Have you heard of "RSS" or "Atom feeds"?  It stands for Really Simple Syndication, and it is a kind of API.  This blog (along with all Blogger blogs) has an "RSS feed", which is simply another version of this website delivered API.

If you want to look at it for this blog, just go to:

You may note the "rss" as the end of the URL.  This is Google's way of saying "give me the RSS version of this blog (Google owns Blogger, the service I use to host this blog).

If you go to that page, it will be rendered in various different ways, depending on your browser.  Unless you are using Chrome, it will look like a greatly simplified version of this blog.

View the source of the page.  If you did it yesterday, you will see something that looks like this:

<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='' xmlns:openSearch='' xmlns:georss='' xmlns:gd='' xmlns:thr='' version='2.0'><channel><atom:id>,1999:blog-4061227211666562229</atom:id><lastBuildDate>Fri, 11 May 2012 03:13:37 +0000</lastBuildDate><title>Expand Fair Use</title><description>The only decent solution to the current copyright mess on the internet is the dramatic expansion of fair use rights to include all non-commercial use.</description>

etc. etc. etc.  Here, let me format this in a friendly way for you, and get rid of some of the cruft:

<title>Expand Fair Use</title>

<description>The only decent solution to the current copyright mess on the internet is the dramatic expansion of fair use rights to include all non-commercial use.</description>


<managingEditor> (Lee Latham)</managingEditor>


<title>Pirate the Avengers</title>

<description>Torrentfreak has an interesting analysis of the effect of movie piracy on the new Avengers movie. Their conclusion, unsurprisingly, is...

Can you dig it?  Trust me, if you view the source on this page, you'll find some dramatically more complicated stuff.  This is a simplified version done to an existing standard called RSS.  What you see there is a kind of API.  It is a very simple, well defined way of delivering information, so that programmers can easily "read" or "parse" the information in meaningful way.

Everything is carefully tagged--for example the <managingEditor> tag is followed by some information (my name and email (kinda..that's not a real address, obviously)) followed by the closing tag with the "/" in it: </managingEditor>.

These are XML tags, which are a superset of HTML tags, if you are familiar with those.

So, for example, if I want to write a program that reads blogs and prints them out, I could have code like:

print "This blog was generated by $platform";

where I just have to look at what is between the <generator> tags before hand and $platform will be populated with that information.

If that blows your mind, please think about it for a while and you will suddenly understand the essence of programming.

So the standard says, "If you want to know what program generated the blog, just look in the <generator> tag.  If you want to know the title, check the <title> tags.  You will find the description in the <description> tag.  A document describing the API might look like this:

<title>title of the blog here</title>

<description>generalized description</description>

<link>direct URL to the blog</link>

<managingEditor>email address and name of the blog editor</managingEditor>

<generator>software that generated the blog</generator>

<title>title of the particular article here</title>

<description>generalized description of the post...

Complicated?  Not really.

The whole entire 100% point of an API is to be easy to use!  The programmer (or standards group) should go out of its way to use meaningful tag names, and do other logical things in the design to make it as easy as possible to use.

You see, programming is hard, so it's important to make everything as simple as possible.  It really is the Thing To Do.

So you don't ever make an API rule that says, "If you want to know who wrote the blog, check the <zSSDTE232SSSS--332k322> tag."

You don' that.


If you think about it, you'll realize that ultimately, an API is a vastly simpler thing that a human usable user interface.

Much, much simpler.

What I've shown you, of course, is a fairly simple API.  Really, "complex" in an API usually just means "large", and one fairly large API is the Java API, which is a bit more complex than an RSS feed--but the same principles apply.

Java was a product made open source by Sun Microsystems an amazingly long time ago, now.  Oracle bought Sun, and now they've started suing people.  To Ellison's credit, he didn't go after the small fry who can't afford lawyers, like most of the punk ass bitches out there like Apple and Microsoft and the MPAA and RIAA.

You know, now that I think about it, in the end, I think my biggest problem in general is with punk ass bitches.

Anyway.  As I sit here and write about it for the first time, I wonder if the Larry's Ellison and Page didn't just decide to do a test case and get the damn thing settled once and for all.

Just so you understand the significance, a version of Java is one of the key components of the Android phone operating system for smartphones.

Take you're time, I'm in no hurry.

Anyway, even though Java was an open source project, Oracle is claiming both its copyrights and patents were infringed.  The copyright claim has proven spurious at best, but the patent side of life is still to come.

However, if Microsoft (and Borland, first) can clone Lotus-1-2-3's user interface legally, I can't imaging why Google can't clone Java's API's, especially when it was open sourced in the first place.

No comments:

Post a Comment