I'm trying to wrap my head around the differences between a library, a framework, and a game engine. One article I read defines a library as a collection of reusable code tailored to specific tasks like audio or physics. Meanwhile, a framework is described as a cohesive set of libraries and tools. However, I've seen some sources that focus on the concept of inversion of control as the main differentiator instead of just scope. For instance, according to the first definition, SDL would be a framework, but the latter would classify it as a library. I'd love to hear some thoughts on which perspective might be more accurate!
4 Answers
The main thing to look at is inversion of control. With libraries, you call their code, while frameworks call your code. Think of it like this: when you use a framework, it’s in control, and you give it instructions at specific points. Typical examples of frameworks would be stuff like Spring Boot or Angular. I can't really speak on game engines, though!
Didn’t you just ask this same question a few days ago? You might want to check out the responses from there for more insights!
What? I didn't realize that!
In general terms:
- **Library**: You call its code. It gives you tools, types, and behaviors to use as you please. Your code leads the way.
- **Framework**: This is where inversion of control comes into play. The framework calls your code at specific points, which allows you to add your features while it manages the common tasks for you. Basically, it drives and you’re just along for the ride.
- **Game Engine**: Think of this as a specialized framework designed for games. It manages the complex parts, letting you plug your code into specific interfaces to customize how your game behaves. All the hard stuff like physics and rendering is handled for you.
Regarding SDL, it’s more of a library because you’re responsible for the game loop and interaction—it allows you to manage input and render things, making it a solid base for building a game engine.
So it sounds like the big difference really comes down to inversion of control rather than just the scope of what it covers? That makes a lot of sense!
To make sense of inversion of control (IoC), think of it like a breadboard in an electronics project. The framework gives you all the setup, so your job is simply to add your code at various points, like plugging in devices to make the circuit work. In contrast, a library is akin to a toolbox, where you pick specific tools for particular tasks—like jQuery in JavaScript. SDL is a library that helps with hardware manipulation through an abstraction layer.
Overall, working with frameworks or engines can be tough unless you’re being paid to do it, as there's a lot to learn about their underlying structures. However, libraries tend to be more straightforward and easier to grasp.
Yeah, that’s the vibe I'm getting too. Thanks for clarifying!