Try visiting a different layer of abstraction

Photo credit: Vadim Sherbakov on Unsplash

I had a brush with assembly language over the Christmas break.

I’ve always counted myself fortunate that I started programming in the microcomputer era, when BASIC was the most common entry point for hobbyists, and that I got my first programming job when assembler programming was becoming rare, and languages such as COBOL were the norm.

BASIC and COBOL are regarded as old-fashioned now, but their core programming paradigm - a simplified, English-like syntax used to construct logic and manipulate variables - endures. However, I’ve always been aware of the assembly programming paradigm that involves loading, incrementing and comparing registers, and that it’s a lot closer to what is actually happening at a hardware level. I’ve also been aware that many large enterprises still depend on code written in assembly language, and have been grateful that I’ve never had to attempt to learn, read or debug it.

But over Christmas I was given a copy of the book The Elements of Computing Systems, by Noam Nisan and Shimon Schoken - also the foundation of the online course nand2tetris. As implied in the name, the course teaches how computers work by leading the reader through a series of exercises which start with one of the most fundamental logic gates, NAND - a hardware component which takes two inputs and only provides an output if at least one input is not on, thus implementing the logic NOT (a AND b) - and shows how, from this atomic beginning, we can build all other logic gates, a CPU, memory, and so on up to software that runs Tetris.

It’s a wonderful book and, even though I’m only halfway through, I would strongly recommend it. (Be aware, though, that this is a book which deliberately does not hold your hand all the way: part of its teaching approach is to let the student get to grips with tough and fundamental problems. But also be assured that all of the hardware exercises are emulated in software: you are not expected to build circuit boards or fabricate chips.)

One of the projects in the early chapters is to write some code in assembly language, before going on to construct a computer and write an assembler capable of converting the assembly language into machine code. I found it easy to learn the syntax of the assembly language - there aren’t that many commands - but very hard to master the concepts, particularly the idea that I had to manually shuttle data in and out of registers. It struck me that, while programming in high level languages can often feel like shifting a mountain of sand using a toy spade, writing in assembly language feels like shifting the same mountain using tweezers.

You might wonder what the point of this exercise was, given that I had come this far in my technology career without writing assembly language, and could probably have gotten away without writing it for the rest of my life. I think that, apart from learning more about the fundamental components of computing, and achieving a greater appreciation of the line where software and hardware meet, it has made me reflect on two key aspects of computing - and has given me increased gratitude for both.

First, it has reminded me how fundamental the concept of abstraction is to computing. Whether we are using an app on our phones in our personal lives, or a large scale transaction processing system running on the cloud in the organisation we work for, we are operating at several layers of abstraction from the physical hardware properties that implement the logic. But, even though it is ever more difficult to see them, those physical hardware properties are there, and, if we want to understand how they underpin our world, it is good to go through something like the nand2tetris journey.

Second, it has made it clear that none of those layers of abstraction have come about by accident. They have all been built by people, designing chips, building operating systems, writing systems software and utilities, creating compilers, interpreters and frameworks, and, ultimately, writing, releasing and maintaining application software. Now that we have compilers, interpreters and frameworks, I’m not sure whether any of these people still write assembly language (except those people who have the unenviable task of maintaining some of the most legacy of legacy systems), but the experience of attempting to write in that language made it clear to me what it means to work at a different layer of abstraction to that I am used to.

Which brings me to my final point. I often advocate that people who do not have a technical background should learn to code. Those people often ask me when they will ever use that coding experience in their everyday working lives. The chances are that (unless they fall in love with programming and choose to switch careers) they won’t. But I hope that they can also see the experience as a visit to another layer of abstraction, giving them a new appreciation of the way things work - and of the work that people do.

I hope that I never have to write assembly language again - high level languages are much more fun. But I am glad that I spent some time this Christmas visiting a different layer of abstraction.

Previous
Previous

Technology estimates: unpredictable since 1823

Next
Next

What’s hiding in your technology sock drawer?