Do you know these Aha-moments when you discover something really simple yet insightful in programming? I think everyone does. Here are some random ones of mine that I collected over the last couple of weeks:

  • Signed two’s complement integer division can overflow, meaning that the result might require more bits than the inputs. I believe there is only one case though: INT_MIN / -1. The result is INT_MAX + 1 which cannot be represented by the same amount of bits due to asymmetry of two’s complement range. Discovered in js-webassembly-interpreter.

  • I will just quote this one: “More correctly, there’s no such a thing as a compiled or interpreted language – it is a property of the implementation, not of the language”. Discovered in

  • Vim tip: You can jump to next occurrence of character in line by typing f followed by the character. Similarly F will take you to the previous one. These can be combined with d or y to delete or copy the current line up to some character. To copy the current line up to the next dot, I type yf. for example.

  • In Git, you can use stash in diffs to see what they contain, i.e. git diff stash to compare stashed state to current working state. I find this very helpful because you do not have to remember what is in the stash.