Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

confusions regarding application framework and api


  • Please log in to reply
11 replies to this topic

#1 gupta.vijay

gupta.vijay

  • Members
  • 28 posts
  • OFFLINE
  •  
  • Local time:11:19 PM

Posted 24 December 2010 - 10:22 PM

i was just reading something about
the api and application framework on
wikipedia and on different pages after
searching. .got some queries regarding
both :
1 ) there are three things: library,
framework and api. ... in this ,
framework consists of many libraries
and every library consists of an api
through which that library can be
accessed .. .please correct me if i am
wrong in the last statement .
2 ) i understood the purpose of google
maps api .. .can someone please let me
know the purpose of using general
api 's such as java or direct x
api ... .instead of using api , the user
can install the framework for java and
solve the purpose ... .then why using
these general purpose api?
3 ) can anyone also let me know some
examples of websites or applications
that are using api ?
4 ) As per my understanding , api is
simply an interface through which an
application / website can access the
code and database of another
application / website... .now, the
confusion in this is whether i am
correct in saying code and database
or only code can be accessed using
api because code will anyways have
access to database so api cannot
access database directly ?
Thanks in advance.. ..

BC AdBot (Login to Remove)

 


#2 gupta.vijay

gupta.vijay
  • Topic Starter

  • Members
  • 28 posts
  • OFFLINE
  •  
  • Local time:11:19 PM

Posted 31 December 2010 - 03:19 AM

Is there no one to answer this query?

Note: I searched and read on Net before posting this here. I am only asking my confusions here.

#3 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:11:49 AM

Posted 31 December 2010 - 11:21 AM

An API is simply a set of instructions that allows an application to communicate with other applications. You don't install an API, you use a library or framework and interface with that library or framework using an API.


now, the confusion in this is whether i am correct in saying code and database or only code can be accessed using api because code [..]

You are making it way more complicated than it is. A database is just another application, and databases have their own APIs.

#4 gupta.vijay

gupta.vijay
  • Topic Starter

  • Members
  • 28 posts
  • OFFLINE
  •  
  • Local time:11:19 PM

Posted 01 January 2011 - 07:42 AM

As per my understanding , api is simply an interface through which an application / website can access the code and database of another application / website... .now, the confusion in this is whether i am correct in saying code and database or only code can be accessed using api because code will anyways have access to database so api cannot access database directly ?

Thanks groovicus for the reply. So, you mean to say that for an application to access the code and database of another application, two api's will be needed. One for code and another for database. Please correct me if I am wrong here.

Also, can you please provide answer for other queries also.


#5 matthew180

matthew180

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Marshall, Michigan
  • Local time:12:49 PM

Posted 06 January 2011 - 01:37 AM

An API is not anything, it is just an idea; a way to talk about something that does not exist. Think "abstract". Look at it like this, say you have a project where you need to read and write data in a file. Then in another project sometime later, you need to do the same thing. Instead of rewriting the code, you go and rip out that part of the code from your previous project and modify it for your current project.

Now you think, "I could use this again, if I only make a few of the functions more generic..." So you take those functions, bundle them up, remove the project specific parts, and create a "library" for reading and writing data to a file in a certain way.

At this point, look what you have created:

1. A library of code for doing a certain "thing", in this example reading and writing data to a file in a certain way.

2. A file-based database.

3. An "API" for using that library, which is simply the functions you wrote and the details about the input parameters and return values.

4. A certain way to "access" those functions (your library), either statically at compile time via a static lib, or dynamically at run time via a .so (shared object (unix)) or .dll (windows).

There is really nothing to stop you from writing code that accesses those data files directly, but why would you do that? It defeats the purpose of using a "library" to begin with.

In the case of something like the Google Maps "API", you have no choice but to use Google's libraries to access their data. However, their "interface" (the 'I' in "API") may not be a library, but rather a specially formatted HTTP request to a certain URL. Some of the parameters you might have to pass in, I suspect, would be authentication tokens that you had to get via a registration process or something. But either way, Google is going to publish the "functions" or "HTTP calls" you can use, and the parameters each one takes; and that *is* the API.

Once you call one of Google's functions, that code will access the data internally however they have it set up, whether via more internal layers or maybe directly to some disk files or something. At that point you don't really care.

Frameworks are usually some sort of glue that brings together collections of libraries to assist in some related task. CMS "frameworks" are a good example since there seems to be a new one popping up every day. If you were trying to make a "modern" database-driven website, you would have to deal with sessions, security, a database, content, presentation (HTML, CSS, JS, etc.), users, widgets, etc.

A "framework" tends to provide all of those features and some sort of cohesive "way" of doing such a website, so you can get on with making your site instead of wondering if your security model will stand up to SQL injection. Other frameworks do the same thing for other purposes, like the old MFC (Microsoft Foundation Class), which Microsoft created to "help" programmers get their apps done faster instead of messing around with the messy details of displaying a window, widgets, icons, etc. The MFC has now been replaced with the .NET "framework", which goes even further and makes the language you choose to write in even less important.

Edited by matthew180, 06 January 2011 - 01:42 AM.


#6 gupta.vijay

gupta.vijay
  • Topic Starter

  • Members
  • 28 posts
  • OFFLINE
  •  
  • Local time:11:19 PM

Posted 09 January 2011 - 07:33 AM

Thanks Matthew for the reply. You offered a very good explanation of the things. Please answer my specific queries:

As far I understood, there are three things - library, framework and API. I will summarise my understanding in points.

1) Library is a file consisting of code which can be reused. Please let me know if I am correct here.

2) Framework is a software that provides the collection of libraries along with the compiler, environment etc to build the application/website. Please let me know if I am correct here.

3) API is a way for an application (Suppose: Application A) to access other application's (Suppose: Application B) data using other application's (Suppose: Application code by making HTTP request in a specified B) format to that other application (Suppose: Application B). Here Application B is providing API and Application A is accessing Application B's data using Application B's API. Please let me know I am correct here.

4) I understood the purpose of google maps api .. .can someone please let me know the purpose of using general api 's such as java or direct x api ... .instead of using api , the user who intends to code in java can install
the framework for java and solve the purpose ... .then why using these general purpose api?

5) Can anyone also let me know some examples of websites or applications that are using api ?

Edited by gupta.vijay, 09 January 2011 - 07:37 AM.


#7 Yoshistr

Yoshistr

  • Members
  • 75 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:12:49 PM

Posted 09 January 2011 - 01:56 PM

1) A library is a set of code used within a specific programming language,
and can be utilized by software written in that language when it is referenced
properly within the code.

2) Framework consists of the complete environment used to code the software
for the platform it is being built for.

3) API is a communication interface, two separately coded software applications
can use it to communicate within a set of instructions.

4) Frameworks are on a more general level, they are not changeable and serve as the foundation,
however APIs are adaptable and can be changed to a certain extent.
Yoshistr Support Team

#8 gupta.vijay

gupta.vijay
  • Topic Starter

  • Members
  • 28 posts
  • OFFLINE
  •  
  • Local time:11:19 PM

Posted 09 January 2011 - 10:08 PM

hi yoshistr,

your explanation of the terms is very clear, however, can you please respond to my specific queries?

#9 matthew180

matthew180

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Marshall, Michigan
  • Local time:12:49 PM

Posted 09 January 2011 - 10:17 PM

1) Library is a file consisting of code which can be reused. Please let me know if I am correct here.


More or less. That is a pretty big generalization, but a library does fit in there.

2) Framework is a software that provides the collection of libraries along with the compiler, environment etc to build the application/website. Please let me know if I am correct here.


A framework does not *usually* contain a compiler, interpreter or anything else you need to use the framework. If you want examples of frameworks, go take a look at things like MFC, .NET, wxWidgets, Zend framework, CakePHP, Rails, etc.

3) API is a way for an application (Suppose: Application A) to access other application's (Suppose: Application B) data using other application's (Suppose: Application code by making HTTP request in a specified B) format to that other application (Suppose: Application B). Here Application B is providing API and Application A is accessing Application B's data using Application B's API. Please let me know I am correct here.


I guess what you have described could be classified as an API. But an API is not necessarily used to access just data. Like I said before, an API is just the specification of how to use a library or, these days, a web service, etc.

4) I understood the purpose of google maps api .. .can someone please let me know the purpose of using general api 's such as java or direct x api ... .instead of using api , the user who intends to code in java can install
the framework for java and solve the purpose ... .then why using these general purpose api?


I have no idea what you are talking about when you say "general purpose API". Also, Java is considered a language, not an API. Direct-X is a library for accessing the graphics cards on a Windows OS, and you use the published Direct-X API to use the Direct-X functions. You need to forget the notion that an API is a *thing*. It is an abstract concept.

5) Can anyone also let me know some examples of websites or applications that are using api ?


All web sites in the world use an API of some sort, if only at the level of the web server accessing services provided by the OS (disk, network, etc.)

I think you need to go start programming in some language on some platform. It does not matter what language or platform, but based on your questions it seems you have never actually tried to write any code, otherwise this would not be so confusing to you. No one has time to just provide you a list of examples; you should use Google for that kind of thing.

Edited by matthew180, 09 January 2011 - 10:18 PM.


#10 gupta.vijay

gupta.vijay
  • Topic Starter

  • Members
  • 28 posts
  • OFFLINE
  •  
  • Local time:11:19 PM

Posted 10 January 2011 - 02:17 AM

Thanks matthew for the clarification. Regarding general purpose api, i got that idea from the following excerpt on wikipedia:

An API can be :
general, the full set of an API that is
bundled in the libraries of a
programming language , e .g .
Standard Template Library in C ++
or Java API .
specific , meant to address a
specific problem , e. g. Google Maps
API or Java API for XML Web
Services.

here i got confused by java api.

Also, i did programming only in c and c++ where there was an ide where programs were written, compiled and run.

#11 matthew180

matthew180

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Marshall, Michigan
  • Local time:12:49 PM

Posted 10 January 2011 - 10:19 AM

Well, what the Wikipedia page says is accurate. Like in C/C++, a statement like:

printf("Hello World\n");

That is *NOT* part of the C/C++ language. In this case, the printf() function is part of libc (http://www.gnu.org/software/libc/), i.e. the support library you have to write if you are trying to build your own, complete, C/C++ compiler to run on a given platform. The use of printf() will be defined in a man page and the whole set of man pages for libc make up the "API". C, C++, Java, etc. don't actually have any built-in functions (maybe Java does, I'm not sure), so any time you "call" a function in one of those language you are using a library, or a function you wrote yourself. The libc library is pretty much always referenced by default by the compiler, so you never see it, same with C++, and Java probably has a set of base libs that are used by default.

Here is an example of using the libc library in the context of a "general API":

#include <stdio.h>

int main(void)
{
    printf("General API in action.\n");
    return 0;
}

At the command line on a typical unix box, you would compile and run like this:

$ gcc -Wall -o example example.c
$ ./example

Note that I did not have to specify the libc library, the compiler will assume that automatically. But without libc, printf() would not resolve and I would get an error.

#12 gupta.vijay

gupta.vijay
  • Topic Starter

  • Members
  • 28 posts
  • OFFLINE
  •  
  • Local time:11:19 PM

Posted 29 January 2011 - 12:05 AM

Thanks matthew for the reply. The air is clear now. One last query: here you have mentioned that printf function is defined in libc but as far as i know, it is defined in stdio.h library that you have included in the code snippet

can you please explain?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users