home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / tcl / 2245 < prev    next >
Encoding:
Text File  |  1992-12-23  |  3.7 KB  |  78 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!psinntp!sugar!karl
  3. From: karl@NeoSoft.com (Karl Lehenbauer)
  4. Subject: Re: Advice wanted on math functions for Tcl 7.0
  5. Organization: NeoSoft Communications Services -- (713) 684-5900
  6. Date: Thu, 24 Dec 1992 02:59:25 GMT
  7. Message-ID: <Bzqtn2.JrM@NeoSoft.com>
  8. References: <1h5pseINNkvu@agate.berkeley.edu>
  9. Lines: 67
  10.  
  11. My main argument, plain and simple:  What is so special about these math
  12. functions to differentiate them from any other command in Tcl that takes
  13. arguments and returns results?
  14.  
  15. It complicates the syntax, creates an arbitrary distinction between certain
  16. commands where there need not be one, and -- mark my words -- will not
  17. improve overall program performance one whit.
  18.  
  19. In article <1h5pseINNkvu@agate.berkeley.edu> ouster@sprite.Berkeley.EDU (John Ousterhout) writes:
  20. >    expr {$x*sin(2*$theta) + $y*cos(2*$theta)}
  21. >    expr {$x*[sin 2*$theta] + $y*[cos 2*$theta]}
  22.  
  23. Introduce this new syntax and add all that to expr in order to use parens 
  24. instead of brackets and save two characters in the expression?
  25.  
  26. And then configuring some widget with based on the output of that expression
  27. is going to incur a hundred times more overhead than evaluating the expression
  28. did, anyway.
  29.  
  30. >Here are the tradeoffs between the two approaches, as I see them:
  31. >1. The embedded approach avoids having to add a lot of commands (10-20)
  32. >   to the command name space and uses the normal functional syntax that
  33. >   people are used to in expressions in other languages like C.
  34.  
  35. I think it would be unfortunate and naive to look exclusively at the output of
  36. "info commands" as a measure of the complexity of the language.
  37.  
  38. For one thing, having twelve suboptions to a command, as "string" does,
  39. helps to keep the toplevel namespace small, but doesn't reduce complexity
  40. in any other way (does it?).  The names are still there, and so are the dozen 
  41. distinct string functions they invoke.
  42.  
  43. What we really need are dynamically loadable libraries, IMHO.
  44.  
  45. >2. By putting the functions into expr, there is less conversion to and
  46. >   from ASCII, which is more efficient (ASCII conversion is pretty slow
  47. >   on most machines).  In the second example above, the results of the
  48. >   sin and cos commands have to be printed in ASCII, then reparsed by
  49. >   expr;  in the first example the only conversion to ASCII is when expr
  50. >   creates its result.
  51.  
  52. Efficiency has never been an overriding consideration in Tcl, and I am
  53. a bit surprised to see John bringing it up in support of this position.
  54.  
  55. I'll tell you all, I got burned trying to speed up the early version of 
  56. arrays.  Although I was able to make the lookups several times more efficient,
  57. even when creating a test program designed to amplify the performance
  58. increase as much as possible with degenerate cases, I found something like a 
  59. 1.5% improvement in overall performance.  You must profile if you want to 
  60. know where to go to speed up a program.  I have profiled Tcl...
  61.  
  62. If you live by Tcl_Eval, so shall you die by it.  That's where most of 
  63. the overhead is, and that's where it will still be in any Tcl program
  64. regardless of whether floating point function calls (a small part of
  65. any Tcl program for sure) are slightly shortcut.
  66.  
  67. Come on, Tcl is a pig for any kind of serious floating point.  For sure
  68. you'd go to C, totally for sure, if performance was any kind of issue
  69. at all.  When it isn't, it isn't, and I say if you are using Tcl to do
  70. heavy floating point you have implicitly accepted that you not doing it
  71. the fast way, rather the convenient way.
  72.  
  73. If you agree, send John a vote for "commands".  If not, "embedded".
  74. I'll live either way.
  75. -- 
  76. -- Email info@NeoSoft.com for info on getting interactive Internet access.
  77. "In a minute, I'll burp up your droid."
  78.