I haven’t posted in a while because I have been busy with a few random studies and projects.
Low level programming has always, to a high-level programmer like myself, felt like a mysterious playground where all the real hackers write graphics engines, password crackers, and operating systems. I have always had a fascination with people who can write something hardcore like an emulator. Sure, I can open a window, draw some graphics, and update the UI to reflect state changes. However, an application that does all that and some low-level wizardry is in an entirely different league of complexity.
Many prominent programmers recommend learning something like C because it is a good way of learning how computers really work. Apart from the occasional toe-dip into C, I have almost exclusively coded in higher level languages.
I want to get better at programming. I’m getting bored of the high-level: there’s only so many ways classes, functions, currying, type systems, can be repackaged before you’ve seen it all. I like the idea of mastering the low level. However, deciding on where to start was challenging.
Last weekend, however, I decided to set myself what I thought would be a simple exercise:
Write a websocket server that capitalizes and echoes any text it recieves. You cannot use a websocket library.
I eventually hacked something together that works (github). I took a shortcut and used the nodejs http-parser and a base64 encoder written by Brad Conte. However, the websocket implementation was derived directly from RFC6455.
Even though it’s pathetically basic, is blocking (I don’t
fork or do
any fancy event queueing on the connections), and uses compile-time
allocated buffers for most of the messages (so it can’t stream big
websocket frames), this was still a very eye-opening first step into
some low-level programming. I somewhat regret writing the process
text adventurer in
clojure (with the help of
websocketd) after seeing
how straightforward a lower-level implementation would be.