Semi-literate Programming

I recently finished “Coders at Work“, a series of interviews with famous programmers.

On one hand, reading a book like this is a downer: it’s very clear to me that I occupy a place that is very close to the median of the bell curve, and the skill level of programmers is a very steep non-linear curve in itself. I’ll never be as good as JWZ or Brad Fitzpatrick. But I knew that before, and I am ok with it. On the other hand, this book inspired me to read more code.

The programmers in the book disagree on many points, but they mostly agree on the importance of writing readable code and educating yourself by reading other people’s code. I make my living writing in scripting languages, and I haven’t written a line of C or C++ since college. But there’s nothing preventing me from downloading and taking a look at the source of Apache, PHP, MySQL.

It’s important for me to understand “how the sausage is made” in the PHP stack, and as it turns out, what happens between Apache PHP and MySQL in term of requests and timeouts is not as simple as one might think. I asked at StackOverflow about this, but all the diagrams that people pointed me at were of the very rudimentary type: “look, here’s a happy cow, it goes to Bovine University, look – it’s all shrink wrapped on the supermarket shelf” instead of “sausage farm/slaughterhouse/truck/factory tour, starting with cow insemenation”.

When I downloaded the source code of mod_rewrite, arguably the most useful Apache module in the world, I was amazed to find out that it’s only 5000 lines of C with comments.

The book ends with the interview of Donald Knuth, and another two major questions that the interviewer is asking everyone is – “have you read Knuth’s books and have you tried literate programming”. It was interesting to find out that most of the famous programmers use Knuth’s the same way that I do. The books sit on my bookshelf, I look at them, I sometimes try to read them, I skip most of the math. They serve as a constant reminder to me that I suck at computer science even more than I suck at programming, and luckily there are people out there who know all of this stuff who are not idiots like me.

Here’s a photo of my cubicle at TV Guide circa 2002, Knuth’s books are holding a place of honor next to the mini fridge. By the way, taking pictures of the places where you work and live is something that you should not forget to do: years from now nobody will care about those pictures of flowers, shadows, and sunsets, but

I’ve read the book about Literate Programming at the time, and was rather inspired by it. Ok, maybe I didn’t read it and more like skimmed it. I don’t think I understood what real literate programming is.

The way I understand it, Literate Programming is a way to write programs as a narrative that is readable to computers and humans. My father, in his former career a site supervisor (a type of a contractor) is very fond of giving very detailed instructions to me, the same way he used to give instructions to construction workers. His instructions usually are exaustive algorithms, with error handling. I think that his instructions, expressed as a flow of conciousness, would work not only on me and construction workers, but on computers as well, and are similar to what Donald Knuth has in mind. All you really have to do is to build a layer of abstraction between these instructions and a computer language. Also, since computers don’t forget things, he would only need to repeat his instructions once.

These days my dad is a COBOL programmer. Everybody dumps on COBOL, but in my mind it’s a language worth of a lot of respect. It has a syntax that is very English-like, something that makes reading COBOL code easy. Well, maybe it’s like reading some old-timer’s newsgroup post written in all caps, but it’s still much closer to English than most other computer languages.

At the time I was reading “Literate Programming” I was using ASP 3.0, IIS, and SQL Server 97. My task was to write a system that would account for booked and pending business. This is something that had to be done since the age of Mad Men. You see, the dealings of clients, account executives (like Pete Cambell), their bosses, account coordinators, creative department, etc are rather convoluted. But in the end, to get paid, you have to have a system that will track who brought in what business, who handled what, and how the commissions need to be split.

This is normally the realm of something called EAS (Enterprise Application Software). Back at the turn of the century, this area was still dominated by a company called SAP, but there were a few smaller players, like Salesforce.com that tried to package these applications. Any sane IT manager looks to see if an EAS solution can be purchased first. It turned out that TV Guide’s buseness logic was impossible to shoehorn into any existing solution. SAP folks said – yeah, no problem, we’ll build you what you want, but our prices start at $1M, and then there are consultant fees. ERM world is a crazy place, you can read about some true craziness in “Cube Farm”, an account of one hapless developer’s adventures at Lawson Software. It’s a truly riveting book, and I fell that every developer out there should read it. It’s literally Lovecraftian in nature, that book.

In any case, it fell to me to develop the application from scratch. Inspired by Knuth, I decided to write some semi-literate code. Me and a project manager, Brad, went to the clients and interviewed them at length, documenting their existing process (aka the most complicated set of spreadsheets you’ve ever seen). In the past, before cheap computers, all you needed was a Joan Holloway, but I believe they stopped making them.

Brad went on to go back and forth with a very terse document about 5 pages in length that described how the new system would work. He would sit down with the clients and go through the narrative, step by step, confirming that this is what they wanted. Meanwhile I created an object oriented library that made dealing with the database, creating forms and navigation elements much easier. This is similar to to what you might find in a CMS like Drupal, only a little cruder.

When the document shaped up, I created the database schema, and then I took a big chunk of the document and pasted it into one huge comment block. I proceeded to break off chunks of that block and writing the code around it. Interestingly enough, as time went on, the project manager started helping me to write the code: enough of scary database abstration was hidden by simple classes and method, and there were tons of self-evident examples all around to copy and paste. I switched to writing reports that involved cubes, rollups and other fancy stuff. Stored procedures that did the reports also received comments from the document that described the reports.

This wasn’t a monolythic system – I was writing it for 2 years or so, releasing a chunk after chunk. In the end it was handed off to another developer, the whole transfer took only a couple of hours. There weren’t any major bugs, maintanence issues (I believe I received only one phone call about it after several years of continuous use). All in all I was pretty pleased with this approach and can absolutely recommend it.

I believe this is the reason why so many English majors become excellent programmers: if you can write for people, you can write for computers. Sometimes there are reasons why you can’t do both at the same time, but there’s no reason not to find some middle ground.

Ada Lovelace Day: Temple Grandin and the True Nature of Nerds

People walking by my cubicle often pause and look at a picture hanging on my wall. It’s of an old lady in what looks like a meter maid’s uniform. Who is she? Why is this picture so important to you? – they ask.

The picture, of course is of one of the two patron saints of software developers, Rear Admiral Murray Grace Hopper. Admiral Hopper is an old school hacker, mother of Cobol, popularizer of the term “bug”. There is a missile destroyer named after her, her personal motto is very close to my heart, and she looks a little bit like my grandmother (who happened to be a mechanical engineer).

The second prominent woman in software is Augusta Ada King, Countess of Lovelace, and a celebration of her life is the reason I am writing this post. Countess Lovelace is famous for grokking what computer programming was all about back in Victorian era, and therefore is often reffered to as the first programmer. If I’ll ever make it out of a cube into an office, I’ll comission an oil portrait of Ada Lovelace and hang it there.

There aren’t many accomplished women in technology as these two, so someone came up with an idea of celebrating Ada Lovelace’s birthday by getting people to write blog posts that will draw attention to women excelling in technology. I chose to write about Temple Grandin. I would have written about my grandmother, but unfortunately I don’t know much about her life’s work.

I learned about Temple Grandin from an article in Wired magazine called “The Geek Syndrome“. It was an article about an explosion of cases of autism and Asperger’s syndrome in hotbeds of technology such as Silicone Valley. This article and Temple Grandin’s books, “Thinking in Pictures” and Emergence: Labeled Autistic made me see myself and other techies in a completely different light. I am convinced that some level of autism is what makes people get involved in technology. Being a geek is a bit like having homosexual sex: anybody can do it, very few try it, and only a minority enjoy it and are good at it.

According to wikipedia “the word geek is a slang term, noting individuals as “a peculiar or otherwise odd person, especially one who is perceived to be overly obsessed with one or more things including those of intellectuality, electronics, etc.”[1] Formerly, the term referred to a carnival performer often billed as a wild man whose act usually includes biting the head off a live chicken, bat, snake or bugs.” Indeed, geeks are strange people. They obsess about things, they have unusual interests, they are incredibly detail-oriented. All of these traits are considered by psychologists to be symptomes of Autistic Spectrum Personality disorder or ASD. “Impaired social interaction and communication” – another geeky/autistic trait.

“The prevalence of ASD is about 6 per 1,000 people, with about four times as many boys as girls” – also, according to Wikipedia. Eerily, this seems to be more or less in line with overall percentage of people involved in technology and the male/female ratio.

A human mind is a self-aware and self-adjusting multi-level software/hardware combination, and that makes it very hard to talk about the nature of brain disorders. Autism is particularly tricky: it is a spectrum. People with autism range from those severely afflicted and non-verbal through hundreds of different gradations to a geek with strange hobbies and social interaction problems. Yet it is the same basic thing: some kind of overdevelopment of some areas of the brain and underdevelopment in others, as well as a difference in processing sensory input.

Temple Grandin started out a severely afflicted autistic child, pretty close to the upper end of the scale. She recoiled from being hugged, started speaking very late, had all kinds of behavioral problems. Even with her high IQ nobody expected her to become a very succesful professional. She was lucky in having parents who sent her to a specialized school, and some teachers who channeled her obsessions into productive direction. She describes herself as a “recovering autistic.”

Her professional success is tremendous. She became a foremost expert in livestock handling equipment. Before her the livestock industry did not pay a lot of attention to the way animals were handled and transported. Existing structures used to shuffle livestock from a place to a place had design flaws that would cause animals to balk and refuse to move. This caused unnecessery use of force, stressing the animals and their handlers, costing farmers and processors a lot of time and money. Temple Grandin’s attention to detail allowed her to figure out very subtle causes of animal’s discomfort (autistic people are frequently bothered by minute changes in their environment) and figure out better ways to handle them. It’s very likely that all of us at some point drank milk or ate a steak from a cow that went through a facility designed by Dr. Grandin.

Autism seems to be a hardware-based disorder, something to do with neuron distribution and signal sensitivity. The curious part about problems like that is that they sometimes can be fixed with a software patch and changing some external factors. For instance, if you have a defective computer processor that starts generating errors from overheating, you can fix it by writing error-checking software and cooling it down with a fan.

After seeing a squeeze chute used to calm down cattle, Temple Grandin ivented a so-called hug machine, a device that applies a deep body pressure and through it makes autistic people feel better.

In his book Jpod, Douglas Coupland describes how one cubicle dwelling game developers builds a hug machine. After some ridicule and a few tryouts the machine attracts a long line of software developers wanting to use it. I wonder if any of the Google offices have one. I, personally, find that taking a long bath or wrapping very tigtly in a blanket always calms me down. Even better is diving: I get an unusual sense of calm from it.

Dr. Grandin’s books opened my eyes to the traits of “engineer’s affliction” and allowed me to better understand myself and my fellow geeks. Here’s a short list of the autistic traits that you might find in most software developers:

* Liking to create lists
* Lack of eye contact
* Stimming: repetitive behaviors like rocking in a chair
* Strange patterns of speech
* Ranting, long speeches about obscure topics
* Excruciating attention to detail
* Love of routine, dislike of change
* Love of symbols
* Obsessions with obscure things
* Superior pattern recognition
* Visual thinking
* Liking things more than people
* Bouts of anxiety, especially in social situations

Wired has a test designed by Simon Baron-Cohen (Borat’s brother) – you can see how many typical autistic traits you have. My score is 31.

The good part is that autistic obsessions can be “cashed in” for professional success in technological fields. Think about the level of obsession or concentration necessary to design a computer processor like this one? On the other hand, Dr. Grandin’s books showed me that it is possible to work on problematic traits, like eye contact and social awkwardness. Human minds are strange loops, capable of understanding, rewriting and fixing themselves.

Here’s a list of books that I recommend for better understanding of techies, male and female:

* Thinking in Pictures: And Other Reports from My Life with Autism and Emergence: Labeled Autistic by Temple Grandin

* Jpod and Microserfs by Douglas Coupland

* A Spot of Bother and The Curious Incident of the Dog in the Night-Time by Mark Haddon.