I have some familiarity with C++, and concepts like compiling and linking static and dynamic libraries, which is what I understand as collections of code that simplify doing certain things.

But then I get confused in certain cases, for example, why is OpenGL considered an API? Why is it necessary to use other libraries like GLAD, freeGLUT or GLFW to interface with OpenGL?

And then other languages have this thing called package managers, like pip, node, cargo, and vcpkg for c/c++, where you install these packages that get used like libraries? What’s the difference?

Finally the ones I understand the least of are frameworks. I keep hearing the concept of frameworks like Angular for js and a lot of stuff that’s too alien for me because I’m still unfamiliar with web development.

So for example, I’m using the raylib library for a small game project I have. I link the .lib or .dll file to my executable file so I know I’m unambiguously using a library. How come there’s also Cocos2dx which is a framework? What’s the distinction?

  • schnurrito
    link
    fedilink
    arrow-up
    2
    ·
    1 day ago

    My understanding:

    • API = a communication interface between different pieces of software, can be running on the same machine (e.g. a library API) or on another (e.g. a HTTP API)
    • library = code that provides some reusable functionality that someone else wrote and that you, as the application developer, are calling and using the return values of
    • package = can mean different things depending on context and programming language, the metaphor is that it is code that somehow belongs together, but there’s no general way to define this
    • framework = code that provides the general structure of code and that is extended by the application developer to implement actual functionality

    The way it’s been explained to me is that the difference between a library and a framework is that a library is something that you call from your code, a framework is something that calls your code.