Building a Blockchain

There has been a lot of discussion around blockchain in recent times. It’s been touted as a solution for everything from the financial system to aviation maintenance records, but the details of how it works has always been hidden …

How Compilers Work - The Problem of Parsing

Parsing is the second stage of compilation, it comes right after lexical analysis. While lexical analysis focuses on breaking down the input text into a set of tokens, parsing focuses on ensuring that the relationships between those tokens …

C# Value Types are Objects

Value types in C# are Objects, but they don’t behave exactly like Objects do. A part of the reason for this is that all value types are implicitly derived from System.ValueType. public abstract class ValueType { protected ValueType(); …

A Short History of Sorting in C#

Recently, while reading Jon Skeet’s excellent book“C# in Depth” I came across the long and varied history of sorting in the C# language. It provides a tantalising view of how the language has evolved over the years. Apart from being a great …

C# Abstract Properties, Virtual Properties and Access Modifiers

Properties in C# are first class citizens, this means that they can be declared as abstract, virtual, private and protected. This is not the general use case though, most of the time properties are used to encapsulate fields. class Customer …

A Concise Guide to Hiring Good Programmers

The best way to hire a good programmer is to be invested in his or her results. It’s like getting married. You want to be careful to choose the right kind of girl, the kind of girl that you’d want to spend the rest of your life …

How Compilers Work - Lexical Analysis

Compilers are wonderful, if somewhat under appreciated programs. Like the foundations of great buildings, they form the latticework on which modern computing is built. Unfortunately, they have been a bit neglected of late. Writing code …

Emacs - Debugging Code under Linux with GDB

Visual Studio provides a very nice developer experience when debugging code. Emacs, on the other hand, doesn’t really shine in this area. It relies heavily the on strong debugging tools that ship with Linux, particularly GDB. While …

Emulating Classical Inheritance in Javascript

Javascript isn’t a classical language. It’s prototypal, which is a bit like every object being a class in waiting. You can create graphs of objects where one object inherits from another, but the idea of classes doesn’t really exist. This …

C++ Constructors and Move Semantics

In order to do almost anything with a class in C++, you need to define a few constructors. If you don’t, depending on usage, the compiler will generate those constructors for you. For example, consider the following code: class Person …

CMake Platform Specific Actions

Sometimes you need to link one library on Windows and another on Linux (or vice versa). CMake has a number of variables that allow you to do this easily: UNIX TRUE on all UNIX-like OS’s including Apple OS X and CygWin WIN32 TRUE on …

Pessimistic vs Optimistic Concurrency

Concurrency is when multiple jobs see incremental progress within the same time period. It may be that the concurrency is parallel where both jobs progress together at the same time or time sliced wherein parts of both jobs are done one …

CMake find_package

In the last scroll on CMake we discussed adding libraries that you write to your own code. This time, we look at using third party libraries out of the box. This turns out to be fairly easy with CMake - though there are exceptions …

Redis vs Azure

Redis and Azure table storage have a lot in common. Both have no schema’s enforced on the objects that they store. Both have limited complex query capabilities and both are touted as being “post SQL” storage. However there is one major …

High Performance Code - Make No Assumptions

Concurrent bear – parallel fish Often when writing high performance code one can fall into the trap of making assumptions about the nature of the problem. Donald Knuth said “Premature optimisation is the root of all evil”. If that is the …

Emacs - Frames, Windows and Buffers

First for some terminology. What Emacs called “frames” is what everyone else now calls windows. This is because Emacs started out as a full screen terminal tool and GUI’s came along later and because of that what Emacs calls windows is now …

CMake add_library

In the last post we built an executable from a source file and a header only library. However, sometimes we need to build shared library binaries that can be linked into an executable. This is fairly simple with CMake. Instead of using …

CMake Include Directories

To do almost anything today with C++ requires the use of a number of different third party libraries. Some of these come in the form of header only libraries containing only include files (.h and .hpp). The references to these libraries are …

CMake The Beautiful Beast

CMake is a mix of things. It’s a cross platform makefile generator that makes porting your C/C++ code from one OS to another or from one compiler to another inside the same OS really simple. However it complicates things a bit as well …

World War and Economic Unions

It’s interesting that when the European project kicked off it was against the backdrop of the end of the second World War. Europe had seen two world wars within a generation with much resultant suffering and destruction. There must have …

CMake Trickery - Platform Specific Linking

Quite often when your working on cross platform code you need to build applications that use one set of libraries when compiled under Microsoft Windows and another set when compiled under Unix/Linux. Fortunately CMake is a cunning tool to …

Unicode on Linux

At first the place of Unicode in Linux looks simple. It is deceptively so. Linux C/C++ has support for both char and wchar_t. Let’s take a look at the char version: #include <cstring> #include <iostream> int main(int argc, char* …

The Configuration of Emacs

Emacs can only be configured naked by moonlight. I kid, I kid – the moonlight is optional. Emacs has a number of “modes”. Much has been said about them on the interwebs so I’ll take the easy way out and link to a such an article. There are …

Emacs Key Bindings

Emacs is like your average dragon, very cranky before breakfast and set in its ways. Take for instance the key bindings. For you to do anything – and I mean anything at all you need to type in an arcane set of shortcut keys, like for …

The Bumpy Road to Emacs

The Road goes ever on and on Down from the door where it began. Now far ahead the Road has gone, And I must follow, if I can, -Bilbo Baggins, The Fellowship of the Ring Sometimes the completely respectable Visual Studio programmer is called …

Big Data and Intelligent Machines

Big data has been getting a lot of attention lately as a field in computing that could significantly increase the value of the vast amounts of data that are captured by digital networks and devices. Phrases like “Data is the new oil.” has …

The pImpl Idiom – Hiding Private Implementation Details

One key principle behind the design of classes is that of the encapsulation of the implementation from the clients using the code. Here a client is any bit of source code that uses the classes that you write. C++ provides an imperfect …

Sociable Programming

Programmers are not known to be social creatures. It’s an unfortunate reputation really, considering that programmers spend most of their lives writing their thoughts to each other - they should be right up there in the social …

Step on that Code

In Sociable Code I mentioned that an often overlooked consideration when writing code is the strain that it puts on the programmers who end up reading it. Difficult to read code tends to mash the wetware and end up causing more bugs and …

Unicode and Windows

Unicode string support in Windows is a strange beast. When Microsoft hired Dave Cutler and others to write a new OS for them they were thinking about writing a new version of OS/2. In fact the new Microsoft OS was a combined effort by …

Unicode

For many years programmers and strings existed in a state of balance, as much balance as could have been possible under the constant threat of undefined behaviour that sociopathic string functions threatened in any case. It was not to be …

The Private Lives of Strings

Ah, Strings. Surprisingly simple for most C# and Java programmers yet so complex for those of us left behind in the world of C and C++, Strings are perhaps one of the strangest beasts in the programming landscape. Yet they began so simple, …