Today I’ll be interrupting the usual programming to write a little something about phobias, specifically targeted at people that don’t have any. It’s probably going to come across a little killjoy and lecture-y but stick with me, it’s an important topic worth understanding.

Read on →

It’s quite easy to get scared by large systems of things that seem like magic. The Internet is pretty remarkable. It’s probably among the largest and most complicated systems ever designed by human beings. All those hundreds of web pages we view each month arrive at our computers unscathed a large percentage of the time. Some of them will have crossed the Pacific! That small percentage of the time we have a page “hang” while loading is often resolved by simply hitting the refresh button. Ace, right?

But how do those pages actually get to us? In this post (and maybe more, I might split them out, we’ll see how it goes) I want to show how these things work with practical examples and real commands that you can run to inspect what’s going on.

Prerequisite knowledge: Basic Ruby should do it. If you’ve built a simple web application with Sinatra or Rails or something similar, you should be able to follow along without much issue.

NOTE: I’m a Mac user. Some of the examples may be Mac specific. I will try, where possible, to give equivalent commands you can run on a Linux machine but I may miss something out. If you spot something that doesn’t work on your platform, get in touch. Windows users: I’m sorry.

Read on →

Over the last few weeks I’ve been grappling with a bug that just wouldn’t leave me alone. In the end, it took almost a week of pouring over TCP dumps and RFCs to figure out what was going on and, if I’m honest, the solution is a best-guess because I can’t figure out how to prove the theory.

It was a fun one, though, so I felt like writing it up :)

Read on →

A while ago, I found a pair of really useful GDB functions for debugging live Ruby processes on ThoughtBot’s blog:

ThoughtBot .gdbinit
define redirect_stdout
  call rb_eval_string("$_old_stdout, $stdout = $stdout,'/tmp/ruby-debug.' +, 'a'); $stdout.sync = true")

define ruby_eval

These proved really handy but they have a couple of problems relating to garbage collection and Macs, so I made a few modifications.

NOTE: If you don’t care about the explanation, scroll to the bottom of the post for the modified script.

Read on →

Many times I’ve been asked: “Why are you working on that? Is it for work?” referring to my tinkerings with kernel internals. “No, it’s not for work,” I reply, “I’m just interested in it.”

Other times this goes a bit further: “That looks horrible. Why would anyone want to work in C and assembler? No-one needs to understand that any more.” I’ll reply that I think it’s important to understand that which you rely on.

Then I’ll be told: “You don’t need to understand the internal combustion engine to drive a car.” They’re right, of course, but there is still value in understanding how an internal combustion engine works.

Then maybe someone will be telling me about the wonderful abstraction provided by the Node.js event loop, or the concurrency benefits of using a functional language. These things scare me, because I know that they eventually have to play ball with the real and terrifying world of the kernel and the processor, and only a fraction of a percentage of programmers have any interest in how either of those things run their code.

Read on →

Ever run into this one?

duplicate symbol _name in:
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1

It’s a bitch. Lemme explain what’s up.

Read on →

I’ve been wanting to start exploring the MRI Ruby source code for quite some time now, but didn’t quite know where to start. I wanted to devise a way of figuring out what parts of the Ruby source code were important, so if I were to run a “Hello, world!” program I could see exactly what the Ruby VM had to do to execute that.

Prerequisite Knowledge: It would help if you’ve used GDB before, but it should be self explanatory if you haven’t. If you’ve never used Ruby this post might give you tips on how to explore language code bases, but other than that it’ll probably be uninteresting. It’ll also help you if you have a vague idea of what a “symbol table” is in a binary file.

This is going to be quite meandering. I’m basically just going to be picking interesting things in the differences between certain running programs and looking at the C source to figure out what’s happening. If that sounds like your cup of tea, let’s do it! :)

Read on →

I’m really interested in the education of young people. A wise man once said to me if you’re in a privileged position and you have the capacity to help others get into the same position, it’s your duty to do so however you can.

With that in mind, a few months back I set out to help a friend get his university computing and innovation society some exposure to the programming industry (among other things!).

Read on →