My name is Barry Watson and I'm a software development consultant based in Stockholm.

I've been programming since I learned Atari BASIC and 6502 assembly language for fun in the mid 1980s, and since 1996 I've been paid to build real-time operating systems and compilers. Even after all this time, I can honestly say that programming can still get me excited.

My main interest is logic and how it makes the development of reliable software easier. Back in 1929 the logician S. K. Langer wrote that "every universe of discourse has its logical structure". These words have become part of my personal credo. Whenever I'm facing a problem that seems overwhelming I just remember that there's a logical structure to be found, and if I can just find it, then I'll be on my way towards a solution.


The vast majority of my programming is done with languages I've designed and implemented myself. The reason for designing new languages is best summed up by the researchers Bowles and Wilk who wrote:

A programming methodology often used in AI, as well as in other fields, is stratified or layered design. When faced with a problem, rather than implementing a solution directly in some base language, a new, more appropriate, higher level language is designed in which to express a solution, and this is implemented in the base language. This methodology can have several iterations yielding as a final solution a hierarchy of different languages each more appropriate to expressing the solution than the language below.

This layering of languages probably isn't going to work for most time critical applications, but in other areas it's surprisingly useful. A good example of growing a language to suit a problem can be found in this paper. Here the application area is telephony and the language is Erlang.


The paper just mentioned leads on nicely to my implementation of the language they first used to implement Erlang — Prolog.

Here you will find the beta version of my Prolog compiler and run-time system that I use daily. The dialect supported is a superset of the ISO Standard with library routines for statistics, parsing, and the usual data structures. You should be able to run code from any Prolog book with this system and the original Erlang implementations work too.

In total the system is built from roughly 30,000 lines of Prolog, 20,000 lines of C, and 500 lines of assembly language. It runs on 32-bit and 64-bit Intel/AMD PCs running Linux and it is free for non-commercial use.


Trying to put what you've learned into words is a great way to expose just how little you really understand! Every so often I write down what I've done to try and make things stick a bit better.

The Everyman Kernel

Back in 2009 I designed and built a hard real-time kernel and wrote a little book to describe the design and implementation. This is intended as the simplest possible kernel to act as a tutorial for hard real-time scheduling algorithms, non-blocking resource access protocols, and non-blocking inter-process communication mechanisms. Hopefully the system is so simple anybody could pick it up, port it, and improve it — hence the name.

The source code for the system can be compiled to boot and execute on 32-bit Intel/AMD PCs. Either you'll need an external hard disk to install it on and boot from, or you can run it as a process in UNIX. Running it as a process is fine for demonstration purposes but that isn't really going to give you the deterministic behaviour a hard real-time system needs. I compile the system on Linux but any system with a C compiler, MAKE, LEX, and YACC will do. You can download the book and the source code to go along with it below.


If you want to know more about what I'm working with, then send me a message.