Friday, May 25, 2018

Code to Joy

I remember the moment when code began to interest me. It was the tail end of 2013 and a cult was forming around a mysterious “crypto-currency” called bitcoin in the excitable tech quarters of London, New York and San Francisco. None of the editors I spoke to had heard of it – very few people had back then – but eventually one of them commissioned me to write the first British magazine piece on the subject. The story is now well known. The system’s pseudonymous creator, Satoshi Nakamoto, had appeared out of nowhere, dropped his ingenious system of near-anonymous, decentralised money into the world, then vanished, leaving only a handful of writings and 100,000 lines of code as clues to his identity. Not much to go on. Yet while reporting the piece, I was astonished to find other programmers approaching Satoshi’s code like literary critics, drawing conclusions about his likely age, background, personality and motivation from his style and approach. Even his choice of programming language – C++ – generated intrigue. Though difficult to use, it is lean, fast and predictable. Programmers choose languages the way civilians choose where to live and some experts suspected Satoshi of not being “native” to C++. By the end of my investigation I felt that I knew this shadowy character and tingled with curiosity about the coder’s art. For the very first time I began to suspect that coding really was an art, and would reward examination. (...)

Like most people, I have spent my life entirely ignorant of how the code that increasingly corrals me actually works. I know that microprocessors use tiny electrical switches to create and manipulate great waves of 0s and 1s. But how do these digits mesh with the world? Programmers speak to machines in impenetrable “languages” and coding, as the pop-cultural cliché suggests, appeared to be the impregnable domain of spectrumy maths geniuses. Though code makes our lives easier and more efficient, it is becoming increasingly apparent how easily it can be turned to malign purposes. It’s used by terrorists to spread viruses, car manufacturers to cheat emissions tests and hostile powers to hack elections. As the line between technology and politics blurs, I wondered whether my ignorance of its workings compromised my capacity to understand what it should and should not do. Being unable to speak to these mavens in their own terms, as they encoded the parameters of my world, brought a sense of helplessness for which only I, as a citizen, could take responsibility. And two questions that embraced all the others began to form. Should I learn to code? Could I learn to code? With a trepidation I later came to recognise as deeply inadequate, I decided there was only one way to find out.

There are now more than 1,700 computer languages that enable human desires to be translated into the only language a computer understands: numbers and logic. Most have been written by unpaid, clever individuals out of some opaque mix of glory and the hell of it. If you want to program a computer, you have to learn one of them. A daunting task, you might think. But even before that, you must engage in the hair-pulling frustration of picking your language.

To make my choice I trawl the web and consult every programmer I know. Each person either hedges or contradicts the last one. At first the litany of names sound like cleaning products or varieties of roses – Perl, Python, C, Ruby, Java, PHP, Cobol, Lisp, Pascal, Fortran. All have different specialisations and affinities that I feel unprepared to assess. Nevertheless, aided by websites that rank languages in terms of popularity on a monthly basis (the pace of coding fashion makes haute couture look agricultural), three scroll into view as not-stupid options: Python, JavaScript and C++. All are widely employed and on the rise, and have lots of fans and learning resources. Which to go for?

On a trip to New York I beg help from someone I trust. Paul Ford is co-founder of Postlight, a digital-production studio based on 5th Avenue. He is also the author of a superb and improbably entertaining novella-sized essay entitled “What is Code?” If anyone can help me choose a language, it’s him. The son of an experimental poet, Ford came to programming late, after a career in journalism. Unlike most single-track peers, he can empathise with my discombobulation.

Computer scientists use the metaphor of a stack to describe how directly a language communicates with the computer hardware. Lowest in the stack is machine code. It consists of orders issued directly to a silicon chip, where tiny electrical switches called logic gates create and process binary and hexadecimal numbers. At the very top are beginner’s languages such as the child-friendly Scratch, where most of the mach­ine’s weirdness is hidden behind user-friendly shortcuts and guardrails designed to prevent mistakes. But ease of use comes at the expense of fine control and speed of processing. In an inversion of civilian usage, coders employ the soubriquet “low-level” to describe the difficult languages that engage computer processors most directly; and “high-level” to denote the more accessible ones further up the stack. When I meet Ford, I’m still reeling from my terror-breeding assumption that “low-level” was the best entry point for a beginner.

“That stuff is not comfortable, is it?” Ford says with a grimace when I ask if even a seasoned coder can translate seamlessly between different levels. “A mature programmer can go from very high in the stack to very low in the stack and explain how the pieces work. But that’s maturity: there are really good [software] developers who, once you get below the level of what the web browser is doing, have no idea.”

He points me in the direction of a Playboy interview Steve Jobs gave to coincide with the launch of the Apple Macintosh home computer in 1985. Jobs compares computation to showing the way to the toilet to someone with no sense of direction or instinctual control of their own body: “I would have to describe it…in very specific and precise instructions. I might say, ‘Scoot sideways two metres off the bench. Stand erect. Lift left foot. Bend left knee until it is horizontal. Extend left foot and shift weight 300 centimetres forward…’ and on and on.” Computers operate on the same principle, just a million times quicker. “They don’t know how to do anything except add numbers very fast,” Ford concludes.

Ford steers me away from C++, which he likens to a shotgun: fast, efficient and ready to blow your foot off. If a misplaced semi-colon indicates a wish to erase the British archive of a major Hollywood movie studio – a friend of a friend claims this happened to him – C++ will follow through with unquestioning obedience. Not for me, I think.

JavaScript, by contrast, has the advantage of ubiquity: it is high level and serves as the primary language of interactive web pages. But it’s also hard to think your way into, which is the price it pays for having evolved chaotically – like the web – with no central authority. Devotees claim that JavaScript is improving rapidly, which sounds great until you consider that your hard-won skills might be obsolete in six months’ time. This fear haunts all coders and explains why they defend their own languages so fiercely, in what techies only half-jokingly refer to as “Religious Wars”. Like a lot of professional coders, Ford uses JavaScript and Python. He admires the latter, he says, for its svelte, modern syntax, its relative logic and versatility and the proactive disciples who generate lots of useful support. It has been used for everything from website development to algorithmic trading on the stockmarket.

In the course of our discussion, Ford offers nothing to allay the monumental nature of my choice. Languages are not expressive, he explains, but they do form cultures with attendant ways of seeing and being. My choice isn’t simply a practical matter. Much like the musical decisions I made as a teenager, I have to ask myself who I want to hang with. Python was named after “Monty Python’s Flying Circus” and within the community is considered hip. All of which I find discreditably appealing – until, out of the blue, Ford asks a question I hadn’t considered.

“What do you want to do?”

Do? What? Of course. Programming is about making things happen. My mind goes blank, until slowly an answer emerges. A few years ago someone built a website for me but it doesn’t work and I would love a flashy replacement. And if I want to work on the web, most roads lead to JavaScript.

by Andrew Smith, The Economist/1843 |  Read more:
Image: via