home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / prolog / 2447 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  3.0 KB

  1. Path: sparky!uunet!ogicse!decwrl!waikato.ac.nz!aukuni.ac.nz!john-ha
  2. From: j_hamer@cs.aukuni.ac.nz (j_hamer)
  3. Newsgroups: comp.lang.prolog
  4. Subject: Re: Efficiency and 'good' Prolog (was: Help !!)
  5. Message-ID: <j_hamer-260193104919@john-ha.cs.aukuni.ac.nz>
  6. Date: 25 Jan 93 22:15:43 GMT
  7. Article-I.D.: john-ha.j_hamer-260193104919
  8. References: <lenn.726916615@du9ds4><j_hamer-210193105028@john-ha.cs.aukuni.ac.nz><93021.15 <93022.184813U35395@uicvm.uic.edu>
  9. Sender: news@ccu1.aukuni.ac.nz (News Owner)
  10. Followup-To: comp.lang.prolog
  11. Organization: computer Science
  12. Lines: 47
  13. Nntp-Posting-Host: john-ha.cs.aukuni.ac.nz
  14.  
  15. In article <93022.184813U35395@uicvm.uic.edu>, C. M. Sperberg-McQueen
  16. <U35395@uicvm.uic.edu> wrote:
  17. > > Because some of us do write large Prolog programs that depend on efficiency,
  18. > > and it's better to instill good programming habits from the beginning than to
  19. > > overcome bad programming practice later on.
  20. > Proof, I guess, that using a logic programming language does not make us
  21. > logical.  If I were willing to accept your equation of 'good programming
  22. > habits' with fast code, I wouldn't have posted my note about writing
  23. > Prolog as though it were Pascal with commas.  If you want to make anyone
  24. > believe it, you should provide an argument or two in favor of it, not
  25. > just say it again.
  26.  
  27. Ok, so here are some reasons.  The most important one is that the code I
  28. posted follows a regular and common pattern that Prolog programmers the
  29. world over will quickly recognise and understand.  If you want to
  30. communicate, you must speak the language (and I don't mean syntax).  As a
  31. bonus, the introduced relation max/3 is useful in its own right, such as
  32. when you wish to take the maximum over a second list.  As for you
  33. (apparent) claim that Heiner's code is more "declarative", I count 3 cuts
  34. (one is redundant) vrs. one (local) cut in my version.  Who are you trying
  35. to kid???
  36.  
  37. > The real problem for me in your note, however, is your assertion that
  38. > relying on Prolog's declarative semantics is 'bad programming practice'.
  39. > The relative clarity of its declarative interpretation is one of the
  40. > most appealing things about Prolog -- God forbid we should begin to
  41. > think of it as a 'bad habit' if we take advantage of one of the best
  42. > features of the language!
  43. >
  44. > If you write big systems that have to be optimized to be fast, you have
  45. > a right to worry about writing fast code.  You do not have the right to
  46. > spread the pernicious falsehood that speed is the only criterion of good
  47. > code.
  48.  
  49. There is nothing particularly optimised about my code; it was written to
  50. take best advantage of Prolog's strengths (esp. pattern matching), while
  51. avoiding obvious non-declarative inelegancies (the cut).  It just happens
  52. to be fast.  This is the daily experience of the proficient Prolog
  53. programmer -- write your code as cleanly as you can, and performance will
  54. come naturally.
  55.  
  56. -- John Hamer                           Email: J_Hamer@cs.aukuni.ac.nz
  57. -- Department of Computer Science
  58. -- University of Auckland, New Zealand.
  59.