geek
sublime
the beauty of code,
the code of beauty
vikram chandra
GRAYWOLF PRESS
Copyright 2014 by Vikram Chandra
are an extension of the copyright page.
This publication is made possible, in part, by the voters of Minnesota through a Minnesota State Arts Board Operating Support grant, thanks to a legislative appropriation from the arts and cultural heritage fund, and through a grant from the Wells Fargo Foundation Minnesota. Significant support has also been provided by Target, the McKnight Foundation, Amazon.com, and other generous contributions from foundations, corporations, and individuals. To these organizations and individuals we offer our heartfelt thanks.
Published by Graywolf Press
250 Third Avenue North, Suite 600
Minneapolis, Minnesota 55401
All rights reserved.
www.graywolfpress.org
Published in the United States of America
ISBN 978-1-55597-685-9
Ebook ISBN 978-1-55597-326-1
2 4 6 8 9 7 5 3 1
First Graywolf Printing, 2014
Library of Congress Control Number: 2014935698
Cover design: Kapo Ng
Cover art: Svetlana Lukienko, Shutterstock
For Melanie,
Sri Sri Sri
LIST OF FIGURES
ACKNOWLEDGMENTS
This project has been supported by the University of California, Berkeley.
Thanks to Martin Howard for the images of the LEGO logic gates (http://www.randomwraith.com/logic.html); and to Alex Papadimoulis of TheDailyWTF.com for the dependency diagram.
For inspiration, aid, and insight, Im grateful to Jennie Durant; Janet Miller; Maura Finklestein; Wendy James, for the loan of that PCjr; Margo True; David Harvey, with fond memories of the rapture of the freeways and AH&AJ Computing; Balaji Venkateswaran; Jeff Kowalski; Sumeet Shetty; S. Sadagopan; Eric Simonoff; Julian Loose; Ethan Nosowsky; Alok Aggarwal; Telle Whitney; Maria Klawe; Roli Varma; Dominik Wujastyk; Arati Gerdes; Ida Mayer; Avnish Bhatnagar; Balajee Vamanan; Dipankar Bajpai; Raka Ray; and Kapil Kapoor, for his help and his invaluable books about the Indian literary tradition.
Luther Obrock translated all the poems from the Dhvanyaloka , and was unstintingly generous with his knowledge and ideas. He provided essential guidance through the subtleties of the dhvanikaras.
The translation of I will tell you a funny story from the Bhaver Gita was a collaborative effort: thanks to Dilip Misra, Rakesh Mishra, and Monidipa Mondal for their help.
Thanks to Chiki Sarkar for helping me discover the shape of this book; and to Tanvi Kapoor and her team at Penguin India for their heroic efforts at bringing the project to fruition.
As always, I couldnt have started or finished the book without support from my parents, Navin and Kamna; my sisters, Tanuja and Anupama; Vidhu Vinod Chopra; Anuradha Tandon; S. Hussain Zaidi.
Im especially grateful to the two irrepressible shakti s, Leela and Darshana, for their timely interruptions and revivifying hugs.
NOTE ON TRANSLITERATION
Sanskrit words in this book have been rendered phonetically, without the use of diacritical marks: Shakti, not akti. Diacritics have been retained in direct quotations and the titles of cited works.
1 HELLO, WORLD!
class Program
{
public static void Main()
{
System.Console.WriteLine(Hello, world!);
}
}
Even if youre the kind of person who tells new acquaintances at dinner parties that you hate e-mail and e-books, you probably recognize the words above as being some kind of computer code. You may even be able to work out, more or less, what this little Program does: it writes to the console of some system the line Hello, world!
A geek hunched over a laptop tapping frantically at the keyboard, neon-bright lines of green code sliding up the screenthe programmer at work is now a familiar staple of popular entertainment. The clipped shorthand and digits of programming languages are familiar even to civilians, if only as runic incantations charged with world-changing power. Computing has transformed all our lives, but the processes and cultures that produce software remain largely opaque, alien, unknown. This is certainly true within my own professional community of fiction writerswhenever I tell one of my fellow authors that I supported myself through the writing of my first novel by working as a programmer and a computer consultant, I evoke a response that mixes bemusement, bafflement, and a touch of awe, as if Id just said that I could levitate. Most of the artists I knowpainters, filmmakers, actors, poetsseem to regard programming as an esoteric scientific discipline; they are keenly aware of its cultural mystique, envious of its potential profitability, and eager to extract metaphors, imagery, and dramatic possibility from its history, but coding may as well be nuclear physics as far as relevance to their own daily practice is concerned.
Many programmers, on the other hand, regard themselves as artists. Since programmers create complex objects, and care not just about function but also about beauty, they are just like painters or sculptors. The best-known assertion of this notion is the essay Hackers and Painters by programmer and venture capitalist Paul Graham. Of all the different types of people Ive known, hackers and painters are among the most alike, writes Graham. What hackers and painters have in common is that theyre both makers. Along with composers, architects, and writers, what hackers and painters are trying to do is make good things.
According to Graham, the iterative processes of programmingwrite, debug (discover and remove bugs, which are coding errors, mistakes), rewrite, experiment, debug, rewriteexactly duplicate the methods of artists: The way to create something beautiful is often to make subtle tweaks to something that already exists, or to combine existing ideas in a slightly new way You should figure out programs as youre writing them, just as writers and painters and architects do. Attention to detail further marks good hackers with artist-like passion:
All those unseen details [in a Leonardo da Vinci painting] combine to produce something thats just stunning, like a thousand barely audible voices all singing in tune.
Great software, likewise, requires a fanatical devotion to beauty. If you look inside good software, you find that parts no one is ever supposed to see are beautiful too.
This desire to equate art and programming has a lengthy pedigree. In 1972, the famed computer scientist Butler Lampson published an editorial titled Programmers as Authors that began:
Creative endeavour varies greatly in the amount of overhead (i.e. money, manpower and organization) associated with a project which calls for a given amount of creative work. At one extreme is the activity of an aircraft designer, at the other that of a poet. The art of programming currently falls much closer to the former than the latter. I believe, however, that this situation is likely to change considerably in the next decade.
Lampsons argument was that hardware would become so cheap that almost everyone who uses a pencil will use a computer, and that these users would be able to use reliable software components to put together complex programs. As a result, millions of people will write non-trivial programs, and hundreds of thousands will try to sell them.