• she/her

(Help, idk how to use this site and I'm too scared to ask)


ysaie
@ysaie

is that if you're writing anything (not just games or game engines) in c++ (or c), here is my "it's dangerous to go alone, take this" list:

  • integrate address sanitizer, or at least some kind of memory checking tool, into your process really early. i would add undefined behavior sanitizer too if your platform supports it (msvc doesn't yet)
  • set up a stack unwinder library, or write your own if you're that sort of person (points at self)
  • any time you do something that could crash or break or corrupt memory or cause a data race etc. (dereferencing a pointer, indexing into an array without a bounds check, doing arithmetic that might overflow or underflow), assert that shit!! and set them up to hard crash if one fails, definitely in debug mode, and in release mode too if you can handle the performance hit
  • use some kind of auto-free memory buffer, whether it's std::vector or something custom. manual allocation sounds sexy until you're leaking 10 bytes every 5 minutes and can't figure out where it's coming from for a month
  • friends don't let friends serialize application state to binary files
  • figure out your text encoding early (probably just UTF-8, but have it defined, not just whatever the default is)
  • personal opinion: inheritance is a trap and so are pointers. use if necessary, but in general you'll have less bugs if you stick to templates and references
  • don't open the multithreading grimoire unless you have no other choice
  • set up a way to easily print out your application state from anywhere in a human readable format

source: maintained a commercial database engine written in c++ for what felt like an eternity and still have brain pain from the experience and this is what kept me functional