[comp.lang.prolog] PROLOG code formatting

lagache@violet.berkeley.edu (Edouard Lagache) (02/07/88)

               I was interested and somewhat amused by Richard
          O'Keefe's comments about PROLOG coding style.  Since I am
          equipped with the barest of development tools, I enjoy
          neither the benefits, nor suffer from the curses of a code
          formatter/pretty printer.  While there are a number of
          conventions for proper PROLOG coding style, coding (in any
          language) is a very individualistic thing, one of the few
          places where a programmer can express the artistic aspects of
          what is truly a craft, not a science.

               While I know of a couple of simple PROLOG pretty
          printers (I suppose based on LISP conventions), I would be
          interested to learn if there has been much effort invested
          into designing PROLOG pretty printers and/or structured
          editors.  Does someone have a PROLOG equivalent of EMACS
          running around, and what should a PROLOG structured editor
          look like?

          Any comments?

                                        Edouard Lagache
                                        lagache@violet.berkeley.edu



          P.S. While this sort of discussion probably should occur
               elsewhere, one interesting question would be how to
               design a "tuneable" structured editor that could be made
               to conform to a programmers codings tastes.

ok@quintus.UUCP (Richard A. O'Keefe) (02/08/88)

In article <6890@agate.BERKELEY.EDU>,
lagache@violet.berkeley.edu (Edouard Lagache) writes:
>  Since I am
>           equipped with the barest of development tools, I enjoy
>           neither the benefits, nor suffer from the curses of a code
>           formatter/pretty printer.
"Curses"?  What can he be talking about?  *Having* a layout program
doesn't mean that you are forced to *use* it!  As for development
tools, all it takes is a C compiler...  (Or Prolog, for that matter.)

>  While there are a number of
>           conventions for proper PROLOG coding style, coding (in any
>           language) is a very individualistic thing, one of the few
>           places where a programmer can express the artistic aspects of
>           what is truly a craft, not a science.
> 
Amongst other things, a program is an act of communication.
**Coding** is no more the place for being individualistic than
is speech:  that is the Humpty-Dumpty school of programming!
A true artist will devote his creativity to devising worthwhile
things to say, not to individualistic babbling.  It's not the
*skilled* composers who long for something more individualistic
than the diatonic scale.  It's not the *skilled* poet who moans
about the rigidity of sonnet or haiku form.

I cannot stress this sufficiently:  the purpose of a program is to
COMMUNICATE.  We can *measure* how well people understand a program.
Suggested experiment:
	take a number of smallish Prolog programs (one or two pages)
	ensure that each of them contains one bug
	rewrite each of them in four or five different styles
	take several Prolog programmers with one year's experience each
	give each of the programmers one version of each program
	measure how long it takes each programmer to find the bugs
An experiment of this sort would be feasible, and I would be *very*
interested in assisting.  The possibility of making such a measurement
means that (relative to the population the programmers are drawn from)
the quality of a coding style is an objective matter.  If something
else turns out to be more effective than my current style, I mean to
adopt it.  I have already changed my Prolog style several times, in
the interests of intelligibility.  Looking back at some of my old code,
the layout which I liked is clearly and objectively inferior to my
present scheme.  In fact, all of the good ideas in my present scheme
came from other people!  (Thanks, Grant, Nevil, Lawrence, Leon.)

Has anyone out there conducted any psychology-of-programming experiments
with Prolog?  Could something be arranged as part of the next conference?