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?

  • Kissaki
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    1 day ago

    Package managers may distribute and manage libraries as dependencies, but may also manage tangential files like documentation, debug symbols, or source code for those libraries. They may also package build files to integrate into the build system, executable programs, or executable instructions. So it is a superset. Distributing libraries is the main, but only one aspect of them.

    A packaged library is distributable through the package manager.

    APIs, application programmable interfaces, are a standardization of callability - of names, parameters, returns, and behavior. Libraries may practically offer a non-standardized interface, or they may explicitly define an interface that they promise to follow (a more stable interface that you can depend on), or a library may implement an interface that is defined independently of a library.

    With a standardized interface, multiple libraries can implement the interface, and they become inter-operable and inter-changeable.

    OpenGL is an API that is defined as standards. The various graphics driver developers implement the interface. (Their driver makes the implementation available as libraries.) And there’s even software-implementations that implement a translation layer rather than “directly” talking to hardware. This for example allows you to play Windows games on Linux where the Windows APIs get translated to Linux equivalent API calls or implementations.

    Frameworks typically offer a broad[er] architecture and functionality of things. You do not interface with them, you integrate with them. For example, in C++ you may use the Qt framework for UI. Rather than using a UI library that you interface with and call, you implement UI the Qt way, and call Qt to render that. This does not only work for UI of course.