So what is the real difference between a framework , a library and an API ? There is an opinion that all these are close concepts, everywhere there are classes and methods that can be embedded in the client code. And yet, it seems there are significant differences?

  • Metaphorically - the library is part of the application. The framework is the skeleton, the API is the external parts of the specified application. The framework, among other things, in contrast to the API uses the inversion of control. - Andrew Kachalin
  • In addition. softwareengineering.stackexchange.com/questions/54451/… The responses of the three participants (@Makarenko_I_V, @Alex Krass, @VladD) were quite good. The best answer is IMDO VladD - because the answer used the language of metaphors, understandable for beginners. - Andrew Kachalin

7 answers 7

Let's start with the API . This is the simplest option: the ability for an application to access code outside this application. This is a set of functionality in order to force an external entity to do its work.

An example from real life: you have a plumbing in the apartment, and the API is a plumbing telephone that this plumbing can repair if necessary.

Now, a library is a ready-to-use set of code that runs in the context of an application, and does its job in the same way. That is, the library becomes part of the application when connected. The difference between a library and an API can be quite subtle: for example, WinAPI provides functionality that, in general, sometimes happens within a process. However, this is considered an appeal to an external application platform.

An example from real life: you yourself do not put together a cupboard, but buy a ready home, put it in your apartment and use it. Cabinet is your plug-in library.

Well, the framework - its functions, unlike the library, are not called by you, but on the contrary, your code is called from it. The framework can be imagined as a semi-finished application to which you add the necessary functionality yourself.

An example from real life: you buy an almost finished apartment, and you add furniture, wallpaper and cabinets yourself. The apartment is your framework, it is almost ready. You cannot simply alter the number of rooms or turn it into a ship, instead you just add internal functionality: parquet floor, bathrobe in the bathroom and a cat.

    If you use each understand the difference.

    API:

    Most often involves the interaction interface. Used to work with independent services. Suppose you want to upload videos on YouTube, then you will use their functionality through the API.

    Library:

    Most often a set of ready-made classes, methods, solutions of typical problems. Ground for something definite. Suppose you want to recognize faces in photos (personally, without using third-party services), then install some kind of OpenCV and use it to not reinvent the wheel.

    Framework:

    Most often include libraries for convenience. And provide you with a ready-made application pattern / s , implementing design patterns (MVC, MVVC or others). The framework usually consists of ready-made modules that are rigidly interconnected (they use each other’s interfaces), while developing their own module, it is necessary to implement interfaces for the simple integration of their modules.

    • How interesting. I use everything, but it comes slowly. - Andrew Kachalin
    • And somehow more metaphorically, can you explain? Can you sanctify the moment, which is not in the framework, which is necessarily present in the API (or vice versa)? Can a software product be a framework and an API? For example, the framework is not very clear with the template, is it like? It means that the framework, by definition, has already written the simplest program (like Hello World)? And as I understand it, in your last sentence, patterns = patterns, right? IMHO, the question is important, another hundred people will look at your answer after. More pliz. - Andrew Kachalin
    • one
      @AndrewKachalin, at least the term API is well described in the wiki (well, with the framework there is also a good idea). In 2 words, the API is the agreement that the library implements, and the framework is a set of software (including libraries) and the rules for its use, which dictates as a. An application has been built (i.e., a certain framework into which you build your parts). / Well, and the library? Generally speaking, just a bunch of subroutines (usually agreed upon) that you can call. - avp
    • one
      @AndrewKachalin, no, not right. IDE is a development tool . Specific? -Th? IDE can "know" about some frameworks and guide you on the correct way to use the selected framework. - avp
    • one
      @AndrewKachalin, I think you should understand that your program can be just "Hellow World" (hereinafter referred to as HW ), it can be the same HW written in the framework , it can have an API on which anyone else can get the message HW , and use libraries to display the message. First there is a program; everything else is independent / optional . - Makarenko_I_V Nov.

    The API is an interface for interacting with the program from the outside. You have some finished product by itself and it seems to be a black box and you want other programs to use it. You define the methods of interaction with it and describe them, and third-party programs use it. In itself, the concept is very broad and more often it is still used in relation to remote services and requests outside the main application. Roughly speaking, the API is a description of the interaction with the black box, what would it do to you this or that action.

    A library is an assembly of various functions and subroutines that can be transferred and used later in various applications. The basic idea is that they are portable between applications and can be reused without changes.

    The framework is a framework for the future application, which contains all the basic necessary details: libraries, structure, initial code, etc. It can be said, this is a minimal preset, on the basis of which you will add functionality and build on the application. Your application will work due to the fact that there is already and carefully prepared for you.

    • About frame disagree. This definition is already on the starter kit pulls, and not on the framework. - Qwertiy
    • @Qwertiy and the framework is not the same Starter Kit for a certain type of application? Initial details are given and on their basis you assemble your train with finishing touches using a motor and wheels. - Alex Krass
    • Nope Given the ideology of architecture and something that ensures its work. At the same time, the framework can easily be connected with a single file, just like the library. - Qwertiy 1:59

    The library is usually small, created for something specific, usually one purpose. For example, library calendar for js, graph for winforms.

    An API is a paraded system interface: methods, classes, etc., that other people can use.

    Framework - a large system, covers many questions on any topic. For example, .NET Framework. This is a bunch of libraries for various needs. You can write as a web application, and winforms, wpf, wcf and others.

    • thank. Your feedback is very important to us. - Andrew Kachalin

    API is a pattern .

    Libraries and frameworks provide API.

    API can be created on the basis of the framework.

    The framework consists of libraries or is a pattern of their connection.

    The library can be built by the framework framework.

      If on the fingers, then so:

      • A library is some kind of external logic that your code can freely access to pull some functionality.

      • A framework is some kind of ready-made framework, into the framework of which you must enter your code.

      • An API is a control panel that some system exposes so that other systems can access it.

        Api (appliation interface) - access to the application functionality. Library (assembly) - a separate module containing a set of classes or methods. Well, the framework is not just a set of functions like api, sdk or a library - it is a complete development environment, in addition to a set of classes and methods that can be used in your application, the framework gives you the right compiler, interpreter, package manager, decompiler, and much more. For example. Net, nodejs, java are frameworks.