Like A Girl

Pushing the conversation on gender equality.

Code Like A Girl

How do programming languages work?

And why am I telling you with only a few weeks’ experience

“Don’t assume that, because you are a beginner, you have nothing to contribute. Your perspective as a beginner is immensely valuable, especially to other beginners.”
Flatiron School, 2018

There’s a school of thought that the best people for beginners in a discipline to learn from are not, in fact, the virtuoso or the competent — or at least, not solely. Though I certainly wouldn’t argue against the importance of experience, there is something that a long-qualified, globally knowledgeable teacher ironically may not have: how it feels to be a beginner, and what impact that has on your learning. In that case, someone uniquely appropriate to have input on your education might be a beginner ahead of you by a few weeks or a few months.

In a podcast I can frustratingly no longer find, the speakers (all themselves senior web developers or software engineers) discussed how their juniors all raved about a book written by someone who was essentially their peer, and had complied his notes while learning a particular programming language into said ‘book’. While it’s true that people have different learning styles, learning with and through other learners not only engenders an encouraging community but also promotes reciprocity and sharing both of knowledge and learning how to learn. If I wanted to be the best ever fancy house builder, would I go ask the person who’s built the most fancy house? Well, sure, but I think I’d do well to go ask the people who make bricks as well, because I need to know that right now, and I don’t think the first builder has done that, from scratch, as a beginner, for a very long time.

So! That explains why I’ve been reading a lot of blogs, and not worrying too much if something gets explained on StackOverflow and some of the complexity goes over my head. I’ll get there. It also explains why I’m writing a post as a beginner programmer (though to be fair, I think if you’re pursuing a growth mindset, you’re going to be a beginner, or at least a learner, at everything every day for ever) — perhaps this will help someone. It’s certainly helped me.

This post is designed to be informative and mildly educational for people new to coding who are interested in an overview of what a programming language is made of, and how it works, based on my research and understanding. It is therefore neither a wiki usurper nor a steadfast & detailed fount of knowledge (though I welcome input). Don’t say I didn’t warn you!

Modern computer programming, or coding, has a really interesting genesis. That’s a topic for a whooooole other blog post. Suffice to say, computers function essentially on an Cartesian duality between hardware(machine) and software (program): without one, the other is a bit pointless.

If we’re using computer programming languages to program computers, let’s have a look at the back end of back end languages (er, and front end languages).

My biggest question as a new user of computer programming languages has been: what language do you use to write this language? How the heck does this work?

A program is a set of instructions that the computer follows to perform a given task. A programming language is a formal language for instructing a computer to perform this given task.
– Daniel Odia, 2017

There are lots of different computer languages, each with their own grammar and syntax rules, and which are used for different purposes. These rules cannot be broken, otherwise the computer simply doesn’t understand what you’re ‘trying to say’. There is no such thing as “common sense” or “getting the gist” in programming, though it’s true that in languages like Ruby there is more than one way of getting things done.

tests not passing, dear?

Computers use something called Assembly Language & binary code (referred to as “low level” languages) to get stuff done. Humans don’t use this because it’s complex and, once on a large scale, immensely confusing, which easily leads to errors. Instead, humans program in “high level” languages which are closer to human languages. But computers don’t speak high level, they only understand binary code — whether something is 1 or 0, on or off — so it has to get translated from high to low level. It does so like this:

source code > assembly language > machine code > binary code

Depending on the language, it will either do so line-by-line, using an interpreter, or as a whole, using a compiler.

“Software has enabled us to make the most intricate machines that have ever existed”, and yet every piece of software, everything on the internet, every bit of tech, is some crazily Machiavellian constellation of 1s and 0s.

If you really want to go down the rabbithole, consider this: the Go language has been largely written in Go.

….it turns out this is actually a totally legit process called bootstrapping, which can mean a few things but in this case means something building itself using an earlier version. Literally “pulling itself up by its own bootstraps”, if this source is to be believed. (Also, the first few compilers for Go were written in C. I feel slightly Jonathan Creek-ed, but at least I’ve learnt something).

I was reminded recently that you don’t need to know how electricity, phospholuminescence, or 3-way switches work in order to turn on a light; we can abstract away a lot of the detail. While that’s true, and abstraction plays a big part in why programming is difficult to learn, there’s no harm in having a closer look at what is making things tick. In fact, argues Bret Victor, the problem with programming is that it violates the principle that creators should have an immediate connection with what they’re creating. It’s a very simple and tenuously-linked example, but there is so much value to a beginner to unpacking and un-abstracting some of the apparent black magic of programming. I might not be able to start immediately whipping up some sassy assembly language realness, but I’ve now set my sights on C (consider this a formal warning, C) because my interest in how things works has been piqued. It starts to deconstruct what Gerard Berry calls the “fundamentally invisible” aspect of computing and the problems this can create for programmers.

We know that human spoken (and its descendent, written) language is arbitrary sounds and symbols — phonemes and morphemes — which have been combined and assigned meaning. In modern English, you can take your 26 ‘letters’ and do all kinds of dastardly things with them. Programming languages are a linguist’s dream; to borrow a phrase, “countless worlds, made from nothing by use of symbols”. Ruby has fewer than 50 ‘reserved’ words (ones you can’t use as variable names, and have specific purposes). That’s like saying the entire language syntax is shorter than the Lord’s Prayer. And yet things like AirBnB, Twitter, and Kickstarter are built using Ruby on Rails (a framework for implementing web applications using Ruby). Wild. So while there are benefits to abstraction, and it’s a key skill for a beginner programmer to develop, pursuing its antonym can also be its own field of learning.