What makes code "readable"? (was Re: Python vs. Perl, which is better to learn?)

Christopher Browne cbbrowne at acm.org
Wed May 8 00:30:33 EDT 2002


The world rejoiced as Peter <pcc at ecet.vtc.edu> wrote:
> In article <m3pu0859s1.fsf at chvatal.cbbrowne.com>, cbbrowne at acm.org 
> says...
>
>> And this points back to Leo Brodie's _Thinking Forth_, where the
>> crucial concept is that coming up with good _names_ for functions is
>> the most important thing...
>
> As someone who teaches programming, I've observed that the students who 
> have a good grasp on what they are doing tend to choose appropriate 
> names for things while the students who are clueless tend to use names 
> like "x", "y", "y2", and so forth. The usual conclusion is that the 
> student who chooses poor names does so because he/she doesn't understand 
> what the program is doing and thus can't think of anything better. Yet I 
> would turn that around and say that if the student worked on coming up 
> with good names it would help clarify the program for him/her. I tell my 
> students this, of course, but it doesn't always help.

I'll often use quite horridly short names, initially; it's easy enough
to do a search and replace to fix that.  That mandates having the
_discipline_ to do so...

> In any case, I'd love to teach a class using Python. I like Python's 
> elegant regularity. I really like the way it forces the programmer to 
> indent properly (I can't tell you how many rants I've given my students 
> about indentation). Alas, right now we give our students Perl because 
> Perl is seen as a language they are more likely to encounter. Python is 
> currently considered "exotic" in my department... something only a 
> quirky person like me could get into.
>
> I will say that the students love Perl... but that's probably because 
> their prior programming experience is all C and C++. :-)

Ruby's also worth a look, although it's more "obscure" than Python.
I've fiddled with it a bit lately and it's not bad.  My comparison
would be that Ruby's a version of Smalltalk that:
 a) Stores code in files, and
 b) Uses syntax resembling either Perl, without most of the fruitsalad
    of punctuation, or one of the modern Pascal variants like Ada or
    maybe Eiffel.

It's really "in your face" in its "objectness," rather like Smalltalk.
_EVERYTHING_ is an object; that's where it all starts and ends...
-- 
(concatenate 'string "cbbrowne" "@acm.org")
http://www3.sympatico.ca/cbbrowne/sap.html
"My dog appears to require more PM than my car, although he also seems to be
cheaper to service." -- GSB



More information about the Python-list mailing list