Thursday, February 19, 2009

Difference between Framework and API


Software Framework:

It is a re-usable design for a software system (or subsystem). A software framework may include programs, code libraries, a scripting language, other software to help develop and glue together the different components of a software project. Various parts of the framework maybe exposed through an API.
dot_net_framework
Microsoft's .Net framework is a very good example of a software framework. It contains compilers, class libraries, an IDE(Visual Studio), and a runtime. Another example is OpenCog: A Software Framework for Integrative Artificial General Intelligence.

API (Application Programming Interface):

It is a set of routines( AKA methods or functions), data structures, object classes, and/or protocols provided by libraries and/or operating system services in order to support the building of applications.
Good examples of API are Microsoft TAPI(Telephony API), or MySQL connectivity API, or Google MAPS API.










In Microsoft's .Net Framework, only the Base Class Library or BCL are the API. The framework is a bigger thing. API is a part, framework is a whole. Although, API can exist on its own, without a framework as well.
A friend was telling me yesterday "I interviewed someone, he had no idea about difference between Framework and an API". I replied"Owwww that's dumb". In fact, had no idea about the difference either.
Well, I think this much is enough to illustrate the difference between Software Framework and API, or Software Framework vs API.



Another example of software platform is pictured below, Google's Android Mobile Platform, 


android-system-architecture


You see this platform contains many things, a kernel for low level tasks, certain libraries for OS level chores, Delvik Virtual Machine (an enriched clone of Java Virtual Machine), and the "Application Framework" on on the "third story". Any software we write for Android smart phones will reside on 4th floor, which is labelled "Applications" here.
Some might search this topic as API vs framework, this blog entry will be equally helpful for those friends as well.

I'm working as a freelance programmer through ODesk.com, I have a strong profile over there. Feel free to ping me if you need an Android app.

https://www.odesk.com/users/~012d73aa92fad47188

4 comments:

  1. Are frameworks like templates?
    Eg:We want to develop an application in some programming language. The framework for that language provides a ready made generic program in that language and when we write code using the APIs or libraries(I still don't understand the difference b/n APIs and Libraries), we are just customizing that readymade program to suit to our purposes? Just like customising a web template to represent a specific website?

    It so happens that I am working with J2EE for my semester project. The project is built using IBM Wepsphere Application Server Toolkit and tested in Websphere Application Server 6.1. The features of the IDE are so bewildering for someone who wrote and executed C code on Turbo C++ 3.5 Compiler. After reading about frameworks and APIs (J2EE has a lot of APIs!) I am curious to learn whether the IDE I am working in is providing a Framework, which makes coding easier.

    ReplyDelete
  2. Haritha, sorry for very late reply.
    NO FRAMEWORKS ARE NOT LIKE TEMPLATES. Framework is a set of many things. Frameworks are like echo systems.
    API is one function call, for example clrscr() is one API. Library is one or more such function calls bundled together. Just to keep things nice and clean, we usually group these functions in different files or packages.
    And no, you are not "customizing" the ready made programs to solve your problems, you are only "using" them.
    First of all just don't be afraid of J2EE or anything related to programming, if you can code stuff up in Turbo C++ you can pretty much handle anything. Because Java and C#, both languages are created based on C++.
    IDE stands for Integrated Development Environment, and it has nothing to do with a framework. IDE is just a tool which is is helpful in consuming services provided by a framework or API.
    Feel free to ask any more questions. I'll try to spare some time and do a brief post about API vs Library soon. cheers...

    ReplyDelete
  3. Thanks for your reply. It has been very helpful. A lot of my misconceptions have been cleared.

    ReplyDelete
  4. Framework: Collection of libraries with their implementation.
    API contains only the definition the libraries.(like a user manual)
    An API can be implemented differently by 2 different companies.

    ReplyDelete

Feel free to talk back...