[ale] perl, python, C, C++ old code readability

Danny Cox danscox at mindspring.com
Fri Feb 15 08:26:57 EST 2002


James,

On Thu, 2002-02-14 at 21:49, James P. Kinney III wrote:
> What I have gleaned over the years with having to start with someone
> else's code base and extend or modify to suit my needs is the
> readability depends not on the language, but the author. 

	I *am* a programmer, and I say: Hear! Hear!

> Many people who bang code have the project in their head. So they don't
> bother with usable annotation or logical structure. It doesn't matter
> what language it's in. The next poor schmoe who has to fix or add
> something has a hard task.

	However, if you bit the bullet, and realize that *you* must maintain
this code, you begin to write code more obviously, and add comments, at
least where you're doing something that may not be obvious.  One main
point I've learned over the years is that NO software is "write and
forget".  I can't count the number of times I've written a small proggy
"just for testing", and by the next week, it's in production, for
whatever reason.  If you're the only programmer, you learn to make it
easier on yourself down the road, by writing easy code.  From "The
Elements of Programming Style" by Kernighan and Plauger: Rule #1: Write
clearly - don't be too clever.

> It is often taught that C is a small language. True. But to be really
> useful, one must know the libraries and their syntax. Now the language
> has grown tremendously in size. C++ and it's classes can get enormous.
> Fortran, well, what can I say?! Ditto for BASIC. They are the way they
> are. As part of the graduate program in physics, I had to demonstrate
> proficiency in either German, Russian, Fortran or BASIC for the language
> requirement. Not to mention some C variants used by National Instruments
> Lab View and a Pascal/C mutation in Origin.

	Around Dec 2000, I began the transition to Kernel Hacker.  I know C
pretty well, and the C library to the point where I only have to look up
a reference or two (quick: in qsort, what is the order of the 2nd and
3rd args?  Is it size and number, or number and size? ;-)

	The kernel doesn't (can't) use the C library, and indeed has a whole
different "library".  It's currently around 17 Meg of source code, and
thankfully most of that I don't (yet) need to know.  I still feel like a
fish out of water, floundering around, and only a *few* of the familiar
friends near, like sprintf and strncpy.

> It still boiled down to the skill of the previous writer.

	There is also evolution involved.  I've most recently been in the ide
driver.  This has had three main developers, and Linus Knows how many
others with their fingers in this code.  It's not quite spaghetti, but
the pot is boiling away.  My best description is this: you know what a
state machine is, right?  Well, imagine a state machine spread over 54
source files.  Okay, I'm really only concerned with 6, but 6 files
taking some part in a state machine?  Sheesh!

	This all goes for most any language.  While I like Perl, I've not
actually used it for a large project.  According to writings by Eric
Raymond, who HAS attempted to use it for large projects, it quickly
becomes unwieldy.  It just seems to arrive there faster than others.

	What little I've seen of Python, I like.  If you're interested, I've a
Python script that filters kernel make messages to the point where you
may actually see any error messages produced by gcc!  Write me if you'd
like it.  It's called blueberry.py, by Rob Landley.  If you do many
kernel compiles, it really helps!

-- 
kernel, n.: A part of an operating system that preserves the
medieval traditions of sorcery and black art.

Danny


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list