Handmade Hero»Forums»Code
7 posts
C++ without classes

Are there any books that teach programming without classes and other bloated stuff? Maybe books aren't even needed and practice is all you need?

Mārtiņš Možeiko
2357 posts / 2 projects
C++ without classes

It is called C. You just write C code. And if you really need - compile it with C++ compiler to use some features of C++ you find useful, for example, maybe function overloading.

22 posts
C++ without classes

Are you watching the Handmade Hero series? That is where you can learn what you want. If you are having trouble learning from video, Casey is working on a written version starcodegalaxy.com.

I haven't seen any books that teach C the Casey way:

  • Compression oriented programming.
  • Zero is initialization.
  • Instead of C++ inheritance, use one big struct, and a big switch statement in big functions for the different entity types. If memory usage becomes a problem, compress the entities that aren't being updated or drawn.
  • Make a different platform layer for each operating system your program is used on.
  • Don't use the standard library, make your own.
  • Pre-allocate all memory that will be used at the start of the program. No need to free the memory when the program exits. The OS will do that for you.
  • Put the platform code in the exe part, and the game part in the dll, so you can have live looped coding.
  • Use a simple build system using shell scripts.

The series and this forum are a gold mine. Go to the beginning and start reading.

I can post some external links that helped me, but I would have to go hunting for them, so I'll only get them if you really want them.

Speaking for myself, I like using ANSI C because it compiles faster than C++. However, I assume it is missing some features that Casey needs.