I’m used to C++ and C# and want to learn Jai. How should I think about organizing code without classes, especially for a game engine? Are there useful resources or languages to study first?
How do you structure code without classes?
Answers
Try learning some C first. It gives you a straightforward way to practice separating data structures from the functions that operate on them.
For example, a node can be a struct, while a separate function takes a node and returns the next one. You still have types and behavior, they just don’t have to live inside a class.
Reply to this answer
Start with the work the program needs to do. What data goes in, what changes, and what comes out? That can be a more useful starting point than trying to make a class for every engine concept.
Group the related types and function signatures into a coherent interface. The functions contain the implementation, and callers don’t need a class wrapped around them to use that interface.
Reply to this answer
No classes doesn’t mean no encapsulation. If the language supports modules and separate compilation, you can expose the types and operations callers need while keeping implementation details in the module. Namespaces can also help keep related names organized.
Reply to this answer
Add your answer
Answers are reviewed before publication.
7e!circuitladle_430:
That also makes the data flow easier to follow when you’re deciding how different parts of the engine interact.