# Float or double?

In scientific computation we use floating point numbers a lot. This article is a guide to picking the right floating point representation for you. In most programming languages there are two built-in precisions to pick from: 32-bit (single-precision) and 64-bit (double-precision). In the C family of languages these are known as float and double, and those are the names I will use in this article. There are other precisions: half, quad etc. I won't cover these here, but a lot of the discussion makes sense for half vs float or double vs quad too. So to be clear: I will only talk about 32-bit and 64-bit IEEE 754 here.

The article is split into two separate (but related) discussions: what to use for storing you data, and what to use during calculations on your data. Sometimes you want to store your data with float but do calculations using double.

# Stick to UTF-8 and these three character sets

Handling text is an important part of every programmers life, and there are many subtleties to it. Lately I have started to realize that all text I handle in my everyday work falls into three categories:

• Free text: this includes names of people and places, contents of chat messages, books, etc.
• Code: this includes C++, JSON, HTML, etc – anything that is both human and machine readable and writable.
• Identifiers: these are unique names, e.g. instance keys in JSON, file names, database keys and resource names.

I think we as programmers can make our lives much simpler if we decide to stick to these three categories, and to all agree on their character sets and encodings.

# Designing a fast Hash Table

This article describes the many design decisions that go into creating a fast, general-purpose hash table. It culminates with a benchmark between my own emilib::HashSet and C++11's std::unordered_set. If you are interested in hash tables and designing one yourself (no matter which language you are programming in), this article might be for you.

# Simple coroutines for games in C++

In games it is very common to have scripted sequences - for instance, a piece of dialogue or a cutscene. I don’t mean these sequences are written in a scripting language (though they might), but that they follow a script like a play or a movie does. Of course, contrary to a movie script in a game the script may have some conditional branches (an NPC only saying something if the player choses to ask a certain question, for instance).

Expressing such a sequence in code should be straight-forward  – after all, computer code is very much like a script. However, these scripts are often span minutes and happen while a bunch of other things are also happening. The now obvious solution to this is to put these in a separate thread - but now you open yourself up to race conditions and other nasty thread-related bugs. So what to do?

# Error Context - a stack trace for data

Often a crash is the result of unexpected data. For instance, a crash could be caused by an extra space at the end of a string, or an integer being negative when your code didn't expect it to be. Or maybe the crash happened during the processing of a bunch of files and you want to know the name of the file that caused the crash. What you really want is the ability to inspect the values of arguments and locals at different parts of the stack. But how can we write that data to a log file on a crash without writing it when there is no crash?

# Introducing Configuru - the user friendly config library for C++!

In the previous blog post I talked about the need for better config libraries. In this blog post I introduce such a library for C++!

# You deserve great error messages!

You deserve great error messages, and so far you config library has been letting you down. It is time for that to stop!

# The fastest code is the code that never runs

It was early 2014, and I was working at Arrowhead Game Studios on our reboot of the classic arcade game Gauntlet. It was the week before we where going to present our game to the world for the very first time. We where going to let the public play a select level from the game, and over the last weeks the team had been busy fixing bugs, refining gameplay and tuning the visuals. It was looking good, but during the last week something happened: the frame rate dropped from the desired 60 FPS to a crawling 20-25 FPS. Panic! What had gone wrong? And did we have time to fix it?

# Introducing Loguru - the user friendly logging library for C++!

Loguru is a flexible, single header, public domain logging library for C++ that creates readable output.

# Fitting a plane to many points in 3D

Let say you have a set of n points in 3D and want to fit a plane to them. In this article I will derive a simple, numerically stable method and give you the source code for it. Sounds like fun? Let's go!

# Lessons after a year with Lua

When I started working at Arrowhead Game Studios a little over a year ago, I came from over a decade of using statically typed languages, the main one being C++. At Arrowhead we wrote most of our game code in Lua, which is a small but sweet scripting language. In this article I will summarize the main lessons I've learned, and how scripting languages in general, and Lua in particular, related to statically typed, compiled languages such as C++.

# Responsiveness

What is the difference between a good button and a bad button? Let me tell you about the one simple thing that can make or break a user experience.