Balance Programming

  • Area of a triangle

    This is a bit specific but that is the way with some algorithms, or formulas in this case. Let’s say you want to calculate the area of a triangle. I’m not sure why. It could be something in a graphics shader for a fancy effect. Winging it It’s been a long time since high school…

  • Diversion ahead

    I’m not going to be able to spend as much time on the blog for a bit. Rather than struggle to keep up with the schedule I’m going to drop the schedule for now. I hope to still post occasionally but it won’t be every Tuesday and will be less often. It could mean that…

  • Defer again

    I written about defer before. This is a keyword that delays execution of a statement until the end of the block. It’s designed to allow you to perform setup and immediately specify the associated clean up. I thought it made control flow a bit more confusing but could be a useful tool. Simple implementation C++…

  • Reorganising data

    I’ve talked about data-oriented design before. It looks at structuring things to remove unnecessary data, keep cache refreshes down and thereby get faster code. Compilers are pretty good nowadays at optimising code. That is they can re-order code, inline functions and unroll loops but they’re not going to restructure your data for you. Packing booleans…

  • Missing operator

    A couple of weeks ago I was talking about error handling and one option using. short-circuit logic. It had lines that looked like this: But why couldn’t they look like this: While you might understand what that means C++ doesn’t, very few languages do. Short-circuit logic The normal logic operators we deal with are and,…

  • The Law of Demeter

    I’ve been doing some more reading and came across the Law of Demeter and train wrecks again. The last time while while reading Clean Code. I’ve one book that tells me this is bad practice: And that I should do this instead: My feeling was to prefer the first as more compact here and it…

  • Error handling

    I’ve used a few different error handling techniques since university. Over the last few years a couple of other options have appeared. Lets take a simple problem and see how it works with all of them. A simple problem Let’s say we want to read a text file containing a list of dates and return…

  • Choosing Wren?

    One of my friends was thinking about Wren earlier in the year to run scripts in a game engine. It was created by Bob Nystrom who wrote Game Programming Patterns which I reviewed earlier. I thought Wren looked interesting so it went on my list of topics to explore. The language It describes itself: Think…

  • Calling functions

    I was recently talking about clang-tidy. One of the performance checks it can run is unnecessary-value-param. This makes sense, accidentally passing a big array by value rather than by reference can invisibly ruin the code performance. The rule was pretty easy though, pass simple types by value and everything else by reference. Then along came…

  • The Checklist Manifesto

    The Checklist Manifesto is a book from 2010 by author Atual Gawande, an American surgeon and public health researcher. I read it a while ago and it reinforces my belief that we all make mistakes. Unsurprisingly the book is all about checklists. It may not sound like much it can be a great help in…