Monday, 2 July 2012

SNAKES ALIVE

Dick Pountain/13 April 2002/12:22/Idealog 93

I've had a terrific response to my column in issue 91 that called - in an only slightly tongue-in-cheek way - for a return to DOS. Many folk mailed to recommend DOS-based tools more powerful than the the Win 2000 shell, and clearly there are still plenty who are not afraid of a command line. Of all these mails, one that hit home was from Simon Foster at Smiths Aerospace who felt duty-bound to convince me that the data-mangling tool I've been looking for is the Python language. I was aware of Python and had even glanced cursorily at it back in Byte days, but I'd wrongly concluded it was only intended for Web scripting (in which I have little interest), plus I'd just taken the monumental decision not to learn Java and so decided not to learn Python at the same time. However something about Simon's tone persuaded me to reconsider, and after downloading the free Python 2.1 (last-but-one version, no heroics) I was instantly smitten. It is indeed very close to my ideal programming language (thanks Simon) and I've found myself programming for pleasure for the first time in ages: a sort of programmer's Viagra.

I won't delve into Python in any great detail here, as anyone who's interested can find out more from www.python.org. I will just say that what attracts me is its unrivalled interactivity, elegant syntax (simple indentation to indicate block structure) and superb handling of ultra-high-level data types including tuples, lists and dictionaries. Like Smalltalk, Python is typeless and object-oriented but it has proper modules with importing of names, like Modula, to support large programs. And far from being confined to Web scripting (though it's probably superior to Perl for that) I can write general purpose file and text mangling utilities with unprecedented ease. Python is available for just about every known platform and OS, and under Windows, Unix and MacOS there's even a rather effective IDE for it called idle - written using Sun's Tkinter GUI libraries - which comes complete with a syntax-colouring editor and a source-level debugger. 

However enough of this Python Porn: that's just an ploy to get me around to musing, in the airy-fairy way which is the remit of this column, about the nature of man's (or at least this man's) attraction to programming. There's no question that programming can become addictive, like game playing or smoking crack but with a rather steeper initial learning curve. I used to pretend this had something to do with a sublimated urge to power - the inside of the computer as a micro-universe over which you have complete and dictatorial control, unlike the rotten old real world out here. However as the years roll by I'm unable to sustain this belief, being forced more and more to the conclusion that programming is actually an art. Certainly I'm not the first to believe this. Donald Knuth didn't name his great work 'The Art of Computer Programming' as mere metaphor, but meant it quite literally, and of course some mathematicians have long since claimed the status of artist - a view that's been promulgated by the recent success of the movie 'A Beautiful Mind'.  And what is programming but maths in motion.

This leads straight into the further question of 'what is art?', which you may have noticed is a ferociously contested one, complete with contending schools, vitriolic factionalism and several hundred shelf-miles of academic treatises. A popular view, promoted by that movie and the media in general, is that art is somehow about the pursuit, production or recognition of beauty. However the feuding about what can be beautiful (a face, a flower, a brick, a soiled bed?) is just as intense. Certainly the aesthetic sense is involved in programming - the satisfaction after writing an elegant program that does its job, er, beautifully, is very similar to what one feels after drawing a good picture or playing a pleasing tune. Certain algorithms and data structures are recognisably beautiful in that same sense mathematicians use about proofs, and personally I'd extend this to language syntax too: some languages I just hate on sight, and could never write good programs in one I felt that way about (what, precious, moi?)

Much of this misses the point for me though, because for me art isn't primarily about beauty but rather about truth
(in a sense accepting Keats' assertion that these are one and the same). I'm not talking only about moral notions of truth. Science is a pursuit of truth in the very strongest sense: it applies theories to facts about the world, so producing new 'truths' that may or may not be confirmed by more facts. Art functions in a closely similar way but its subject matter is human perceptions, relationships and consciousness rather than atoms, particles and forces. Mediocre art feeds or reinforces existing habits and prejudices, while good art always changes your perception of its subject.

Programming too has a close relationship to truth - any program that does what was intended is in a sense true. Of course programs can also manipulate a greatly restricted representation of truth in the shape of Boolean variables. My only real criticism so far of Python is that, being typeless, it lacks a proper Boolean data type, employing instead the old Fortran/Basic convention that 0 represents falsity and any other value truth: useful but ugly, so my first two definitions in Python (as in many previous languages) were:

FALSE = 0
TRUE = not FALSE

No comments:

Post a Comment

CHINA SYNDROME

Dick Pountain /Idealog 357/ 08 Apr 2024 01:09 Unless you live permanently as an avatar in Second Life [does that even still exist?] then it ...