Python factoids... after 3 three years.

Stephen Horne $$$$$$$$$$$$$$$$$ at $$$$$$$$$$$$$$$$$$$$.co.uk
Fri Oct 10 09:13:29 EDT 2003


On 7 Oct 2003 07:18:02 -0700, randall_young at hotmail.com (Randy Young)
wrote:

>3  By far and I mean by a ton, the best language to use, put down, and
>then pick UP AGAIN. Shortest learning curve to get back up to speed on
>the toolset, and the code you wrote to do the initial task.

You've just got me curious about this. I certainly have no complaints
about Python in this regard, but in general I think code readability
depends on the programmer more than anything.

Being a packrat, I still have pretty much all the code I've ever
written (excluding that written in defence companies) since I retired
my old Commodore 64. Actually, I even have some old C64 source code
that I managed to recover from the tapes into an emulator! This seemed
a bit extreme, though.

In the end, I decided to go for some 68000 assembler code I wrote for
an old college project in 1992 (one component in a distributed
'environment control system' using what the college called 'flight
boards'). I can assure you I haven't read this code for a long time -
it's only a couple of years later that I retired my Atari ST and
stopped using 68000 assembler, and I haven't used any assembler at all
since about 1996.

So that's about 27K of assembler code, 11 years old, and I haven't use
any form of assembler for about 7 years (though I've looked at .NET IL
assembler a couple of times recently ;-) ).

I remember being so proud of it at the time - now it seems such a
trivial piece of code. Certainly I can read it fine. The only problem
is that some stuff that tweaks hardware registers uses bitmasks
without explaining the register layout. Mostly, the code is clear
enough that I can figure that out, but these days I'd put that extra
comment in just to save the next reader the job of working it out or
looking it up in the manual (if they have the manual, that is - I
certainly don't).

Also looked at some 8086 assembler from 1993 - another college
project, this time a simple serial-port LAN. Most of the apps code
(IIRC we had file transfer and remote printing) was in modula 2, but I
wrote the TSR packet queueing, sending and recieving - about 1000
lines.

I was surprised by the difference in style - sometimes commenting
every line, and rarely with more than a few lines between comments. I
certainly never found 8086 assembler as intuitive as 68000, but even
so the commenting seems a bit over the top. With the
typical-of-assembler formatting into columns, the comments don't get
in the way however. Once again, it is perfectly readable - at least to
me.

Basically, I think that fits my usual experience. I don't remember the
last time I had a problem reading my own code, whatever language it
was written in and however long since I last looked at it.

Reading other peoples code, of course, is a very different thing - but
once again it has more to do with the programmer(s) than the language
IMO. Python certainly makes it easy to write easy-to-read code, where
some languages make it much harder, but some programmers just love to
write cryptic code. Some C programmers even seem to treat the winners
of the obfuscated C contest as some kind of style guide :-(


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk




More information about the Python-list mailing list