• Readability: Narrow try/catch blocks

    Try/catch blocks (or try/except, or whatever they happen to be named in your favorite language) are the mechanism by which you capture exceptions raised by a chunk of code in a controlled manner. Within that chunk of code, it does not matter which line throws the exception: any exception specified in the catch statement will be captured, and it is "impossible" to know at that point where it originated. [Continue reading]

  • 'Hello GitHub!' say shtk, sysbuild and sysupgrade

    Over a year ago, I developed two command line utilities for NetBSD (sysbuild and sysupgrade) and a supporting library for the two tools (shtk). These were all introduced in their corresponding blog posts —Introducing sysbuild for NetBSD, Introducing sysupgrade for NetBSD and Introducing shtk— and since then I have heard good comments about them. [Continue reading]

  • Readability: Don't modify variables

    Single assignment says that a variable should only be assigned a value once; i.e. a variable should only be initialized and never modified later. This could be said to be a property of functional programming —never mind that it's used in compiler optimization a damn lot— so it may sound a bit out of scope in a readability post. Not really. [Continue reading]

  • Readability: Conditionals as functions

    Conceptually, there are two kinds of conditional statements: ones that compute —or affect the computation of— a value and others that guard the execution of optional code (e.g. functionality enabled by a command-line flag). In this article we will focus on the former kind. [Continue reading]

  • Readability: Explicitly state complementary conditions

    In the most basic form, a conditional has two branches and the conditional expression inspects a single variable on entry. For example: [Continue reading]

  • Putting a PowerMac G5 to good use

    A few months ago I bought an old PowerMac G5 off of Craigslist and since then I have been experimenting with various operating systems and configurations. Before I tell you more about these, let me briefly explain why I got such a machine. [Continue reading]

  • Installing FreeBSD with a ZFS root on a PowerMac G5

    Suppose you have a nice PowerMac G5 big beast around and want to install a modern operating system on it. Suppose that you want FreeBSD to run on it. Suppose that you would like to use ZFS as much as possible, say to use the machine as a NAS. [Continue reading]

  • Readability: Do not abuse classes as global state

    You know that passing state around different functions by using global variables is bad: it results in spaghetti code, it introduces side-effects to your functions and, well, is just bad practice. Then: don't make the same mistake when using classes. [Continue reading]

  • Readability: Dictionaries are not data types

    Yes: a dictionary is a data type. No: a dictionary is not a way to implement abstract data types; doing so is lazy programming and is asking for trouble later on. [Continue reading]

  • Readability: Abuse assertions

    Assertions are statements to ensure that a particular condition or state holds true at a certain point in the execution of a program. These checks are usually only performed in debug builds, which means that you must ensure that the expressions in the assertions are side-effect free. [Continue reading]