Stream: Casual code and magic

I think that I was not sold on the BitStream stuff, the added complexity (bit shifting, encoding, decoding) looks overkill when most of the time (if not all) err has enough space to print plain values of the state. Having plain values also helps to “read” the state, it’s sometimes helpful to understand a bug (in a simu for instance).

Otherwise the content was excellent, even if I never used C++ it was quite easy to understand and follow you (maybe because I was already using the same kind of concepts in Java, BitStream excluded :slight_smile: ).

To be fair, I never expected this BitStream thing to become such a huge focus, having known beforehand maybe I would have done things differently.

You raise good points, but I still think bit coding is superior for a few reasons:

  • Some games are very input intensive, so having all this clutter present while trying to debug other stuff is distracting. Keeping it to one short line helps tidying it up, and makes the IDE lag less.
  • You are rarely interested about the whole state, and when you are you can always print out just the stuff you’re interested, or debug it locally.
  • Copy/pasting a single string line to your code is much easier, so is keeping multiple reference versions.

And most importantly:

  • You deal with the complexity just once. Afterwards it’s reusable and entirely transparent. Improvising it on stream made it look much worse than it is in practice.

But at the end it’s mostly about taste. There are many ways to do the same things, I just present my version. :slight_smile:

3 Likes