Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!aurora!labrea!decwrl!sun!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: code formatting (even more random musings) Summary: continuing "Let's Buy an Argument"... Keywords: Individualism versus communication. Message-ID: <637@cresswell.quintus.UUCP> Date: 10 Feb 88 04:10:26 GMT References: <6890@agate.BERKELEY.EDU> <630@cresswell.quintus.UUCP> <6923@agate.BERKELEY.EDU> Organization: Quintus Computer Systems, Mountain View, CA Lines: 143 In article <6923@agate.BERKELEY.EDU>, ed298-ak@violet.berkeley.edu (Edouard Lagache;;;6310183;GY24) writes: > > With all due respect to Dr. O'Keefe, does he ever have anything > positive to say? I must admit that I find his concerns about > code readiability and "standard style" to be rather amusing. ^ I worry about spelling, too... When did I ever say "standard style"? Funny, I thought that in urging people to try to make their programs readable and save their creativity for solving real problems I *was* being positive. I suggested that it would be worthwhile to perform experiments to resolve some of these questions, and offered to help. Is that not being positive? Will nothing less than capitulation to the Humpty-Dumpty school strike Lagache as positive? Let me quote Henry Spencer: It's quite true that such a set of decisions is, to some degree, a matter of personal style. However, to my dying day I will fight the idiot notion that "there is no such thing as bad style, only different style". All of the above examples are thoroughly bad style, not just different but inferior: they are dangerous, error-prone, hard-to-follow constructs that should be avoided like the plague. Even when the situation is not this extreme, though, there are solid objective arguments for using a standard style in anything that somebody else might have to maintain one day. The phrase "anyone should be able to understand that" is the mark of the amateur, more concerned about his own preferences than his successors' problems. Note: Spencer says "a standard style". I don't. I do think that anyone who hasn't sought out objective readability principles and redesigned his coding style around them is being a fool to himself and a burden to others. What is "amusing" about my "concerns about code readability"? Is undreadability a virtue? > As the head TA in a programming course I grade programs in > 4 languages, and I assure you that even with fairly strict > style conventions, every new grading task is usually an enjoyable > experience in discovering the depth of human creativity. I've done this sort of thing too. But what >size< of program do you grade, sir? You can get away with a lot in a one page program. It's interesting that Lagache says "the DEPTH of human creativity". One only says "the DEPTH of X" when one dislikes/disapproves of X... It's also interesting that he says "WITH STRICT STYLE CONVENTIONS". > Inspite Should this be "In spite"? There is no word "inspite". ^^^^^^^ > of this abundance of different coding styles, rarely do I have > to send students back due to "unreadable code". Eh? A sentence ago he said that they had "fairly strict style conventions". Now he says that there is an "abundance of different coding styles". Which should I believe? I don't know how to evaluate this. Which are the four languages? Do any of the compilers pretty-print the listings? (I've been associated with ALGOL and COBOL courses where the compilers did that, and what a boon it was.) What is the range of stylistic variation? What size of programs are these students writing? Are the programs individual efforts, or is the "Software Hut" approach being used? Are code formatters (note that 'indent' is widely available for C) available to the students? Do the students who give Lagache such pleasure with the inventiveness of their layout produce better/worse **algorithms** than those who stick to the layout they saw in their textbooks? > Come now, should we for the sake of communication standardize > on only one form of greeting, or article format, or even commenting > style? (1) If I went up to Lagache and said "Teenaa koe!", I don't think he'd understand me. Most people back home would. If I greeted him "Are you at yourself?", I don't think he'd understand me. Let's face it, within any one group, greetings *are* pretty much standardised. There was a time in my life when I tried inventive greetings & replies to greetings, and I got some very funny looks. That is, "inventive" greetings fail *as greetings*. (2) In most journals, there IS a single article format, and a great help it is. Come now, would you like every article in TOPLAS to be laid out differently? Would that really help? (3) I don't recall suggesting that everyone should follow a single commenting style. I did suggest some fairly minimal guide-lines, but they leave room for a lot of variation. Let me offer an example of "creativity". In my MSc work, I had the problem that my topic had links to three areas of physics, and unfortunately they all used different notation for the same things: there was a quantity that some texts called "alpha", some called "-gamma", and others called "-(k**2)". The texts which used "alpha" also had something called "k", which was not the same as the "k" in "-(k**2)". Coping with differences that were not different and similarities that were not similar was a lot of quite unnecessary pain. > In this terribly structured, dry, and mechanistic world, > I vote that we hang on to whatever means of creative expression > remain - even if it is a simple as how we box our comments! > Evidently Lagache and I don't live in the same world. The world I live in is full of water, living things, fractals, coincidences, and surprises. Laws and patterns *enable* the Great Dance, they are a trellis for the vine of life, a skeleton for the playing otter. If I want to be creative, I can write poems, I can play musical instruments, I can make up stories, I can invent new algorithms and data structures. I'm not so short of ways to be creative that I have to invent new ways of being obscure. YES, let's be creative. But let's be creative in ways that aren't a burden to other people! The layout rules and naming rules I work by are not a cage; they are *tools* just like the Prolog library (800 predicates and growing). They are things I don't have to think about any more. Let's take a current example: I have been challenged to produce a Prolog solution for a certain problem which is "about" as efficient as an existing C solution. This particular problem is going to require very careful thought, and it's also going to require most of my creative powers: I'm going to have to go back to an abstract description of the problem and turn it inside out a couple of times. ANY effort put into layout and naming is going to distract me, and if I didn't already have a kit of data structures and naming rules to take as given, I don't think I'd be able to do it. Even new style rule I add to my kit gives me more freedom: I get to spend more of my time on the mural and less time erecting the scaffolding. Without naming names or pointing fingers even indirectly at specific people, let me say that I have found a strong correlation between the care that people take to make their programs readable and the quality of their code in other respects. (If you think you know who I have in mind, you're *wrong*. Yes you are.) Summary: I believe that every aspect of my code should be criticised by objective standards, and worry about readability. Lagache believes that coding style is a matter of taste and an appropriate arena for "the depth of human creativity", and finds my "concerns about ... readability ... amusing." Who would you rather buy a program from?