Some Presentation Slides

Published

Tags: , , , , and

Here are the slide decks to a couple of talks I’ve given recently.

Being Self-Employed in Australia (at JAIT)

Because this talk is based on my own experiences, it’s particularly relevant to service businesses in Australia. But if you’re interested in being your own boss, anywhere or anyhow, you could find it useful. As I said in the talk, there’s a lot of stuff that feels obvious to me now, but I ended up learning the hard way.

Introduction to Infrastructure as Code (at RORO Sydney)

Here’s a common story: Devs write an app, and do all the right things like using source control and writing automated test suites. Then it comes to deploy the code, and they have to figure out all these things like DNS and server infrastructure. They hack something together using web UIs, but six months later no one can remember the deployment process any more.

This presentation was a really quick introduction to the tools you can use to get more app dependencies into source control.

Why Sorting is O(N log N)

Published

Tags: , and

Any decent algorithms textbook will explain how fast sorting algorithms like quicksort and heapsort are, but it doesn’t take crazy maths to prove that they’re as asymptotically fast as you can possibly get.

D in the Browser with Emscripten, LDC and bindbc-sdl (translation)

Published

Tags: , and

Here’s a tutorial about using Emscripten to run D code in a normal web browser. It’s uses a different approach from the Dscripten game demo and the dscripten-tools toolchain that’s based on it.

LDC has recently gained support for compiling directly to WebAssembly, but (unlike the Emscripten approach) that doesn’t automatically get you libraries.

You can find the complete working code on Github. ./run.sh starts a shell in a Docker image that contains the development environment. dub build --build=release generates the HTML and JavaScript assets and puts them into the dist/ directory.

This tutorial is translated from a Japanese post by outlandkarasu, who deserves all the credit for figuring this stuff out.

Unfortunately, Garbage Collection isn't Enough

Translations:русский

Here’s a little story of some mysterious server failures I had to debug a year ago. The servers would run okay for a while, then eventually start crashing. After that, trying to run practically anything on the machines failed with “No space left on device” errors, but the filesystem only reported a few gigabytes of files on the ~20GB disks.

Understanding a *nix Shell by Writing One

Published

Tags: , , , and

A typical *nix shell has a lot of programming-like features, but works quite differently from languages like Python or C++. This can make a lot of shell features — like process management, argument quoting and the export keyword — seem like mysterious voodoo.

But a shell is just a program, so a good way to learn how a shell works is to write one. I’ve written a simple shell that fits in a few hundred lines of commented D source. Here’s a post that walks through how it works and how you could write one yourself.

Why it's Easier to Get a Payrise by Switching Jobs

Published

Tags: and

It seems to be easier to get a payrise if you’re negotiating a new job than if you’re negotiating within your current job. Just looking back over my own career, every time I’ve worked somewhere longer term (over a year), payrises have been a hard struggle. But eventually I’d leave for a new position, and my new pay made all payrises at the previous job irrelevant. These days I make job switching upfront and official: I run my own business and most of my money comes from short contracts. Getting rewarded for new skills or extra work is nowhere near as difficult as before.

I know I’m not the only one to notice this effect, but I’ve never heard anyone explain why things might be this way.

Using D Features to Reimplement Inheritance and Polymorphism

Published

Tags: , and

Some months ago I showed how inheritance and polymorphism work in compiled languages by reimplementing them with basic structs and function pointers. I wrote that code in D, but it could be translated directly to plain old C. In this post I’ll show how to take advantage of D’s features to make DIY inheritance a bit more ergonomic to use.

Although I have used these tricks in real code, I’m honestly just writing this because I think it’s neat what D can do, and because it helps explain how high-level features of D can be implemented — using the language itself.

Hacking extern(C++) Classes to Work in betterC

Published

Tags: and

First up, here’s a big disclaimer if the title didn’t warn you enough: this is a hack. It’s just a proof-of-concept for getting extern(C++) classes working with betterC D. Also, DMD keeps getting better quickly, so if you’re reading this post when something more recent than version 2.080 is out, this hack is probably obsolete. Hopefully you’ll find this post interesting anyway if you’re either

If you haven’t read my earlier post about how polymorphism and inheritance work yet, I recommend doing that first.

Xanthe Doesn't Need Linker Hacking Now

Published

Tags: and

I finally got around to dusting off the code for Xanthe to test if it can work without linker hacking, now, too. Short answer: yes. I had to add an implementation of memcmp for the freestanding build, but other than that, all I had to do was throw away the linker hacking steps in the Makefile. Apart from the linker scripts for building the disk images, Xanthe now just compiles normally with -betterC.

Also, the old build was about twice as big as it needed to be because the media files were being packed into the binary twice for no good reason. That doesn’t seem to be a problem any more with the latest dmd.

How Inheritance and Polymorphism Work

Published

Tags: , , and

I’ve promised to write a blog post about the DIY polymorphic classes implementation in Xanthe, the experimental game I once wrote for bare-metal X86. But first, I decided to write a precursor post that explains how polymorphism and inheritance work in the first place.