[plt-scheme] 3rd-8th Grade

From: Brent Fulgham (bfulg at pacbell.net)
Date: Sun Mar 19 00:08:35 EST 2006

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Mar 18, 2006, at 3:09 PM, Richard Cleis wrote:

>> For example, I work with a bunch of physicists.  One of them is a  
>> LabView expert, and prefers to write all of his instrument control  
>> and data analysis routines in it.  To me, LabView looks like a  
>> rats-nest of connected wires and indistinguishable nodes  
>> performing mysterious tasks.
>>   Much of the effort of using it (from my inept fumblings)  
>> involved memorization of the various icons and what they meant  
>> (THIS is a loop counter, and THAT is a signal generator, and THAT  
>> takes user input in a slider, etc.).  Each icon has different  
>> connection points, and confusing knobs and switches that are used  
>> to adjust their behavior.
>
> This is one reason why the robots were programmed by the one whiz- 
> kid; he had the icons memorized. However, function names need  
> memorized for text programming.

True, but keep in mind the barrier of entry.  If we share a common  
language (English), it should be fairly clear what a function named  
"(rotate-arm-to-angle 85)" does, versus recognizing that an icon that  
looks like an arc with an intersecting line (with the number 85  
hanging off the line) means to rotate the robot's arm through a  
certain angle.  How can you be sure it doesn't change the speed of  
the robot to 85%, or that it doesn't elevate the robot's platform to  
85 mm, or that it sets the room's temperature to 85 degrees?

>> Documentation and commentary are another touch area.  I find the  
>> text-based approach very natural for embedding comments and  
>> notation.  The very variable and function names (and contracts)  
>> provide documentation.  On the other hand, a network of wires and  
>> nodes requires pop-up help or "mouse-over" text boxes that provide  
>> a place to write the text.  This seems like a clear indication of  
>> a missing element.
>>
> I was within a gnats-eyelash of using emacs to control and sequence  
> the operation of our custom laboratory equipment.  That way, we  
> could have 'taken notes', run experiments, and read the  
> documentation in the same environment.  Weather data, for example,  
> could have been periodically inserted by elisp into the notes of  
> principal investigators.  It seems more useful, in this case, to  
> have a text-environment control the creation of graphical ones (for  
> images, diagnostics, controls, etc.) than the other way around.

I got very excited when looking at the simulation module discussed  
recently on this list.  DrScheme looks almost like Matlab/Mathematica  
in that you can construct documents that contain text, graphics, and  
animations.  Very cool -- and this amalgam is probably superior to  
any single implementation.

>> In closing, I ask you to consider these two equivalent programs to  
>> compute the sum of five random numbers:
>>
>> http://ftp.rasip.fer.hr/research/labview/example5.html
>>
>> Compare that with a simple Scheme implementation:
>>
>> (require (lib "27.s" "srfi"))
>>
>> (define (accum count)
>>   (letrec ((accum-internal
>>                   (lambda (x y)
>>                      (if (eq? y 0)
>>                          x
>>                         (accum-internal (+ x (random-integer 100))  
>> (- y 1))))))
>>     (accum-internal 0 count)))
>
> My colleagues would not be convinced.

By my clumsy Scheme?  Don't blame Scheme (or text-based languages in  
general) on that!  :-)

I would argue that the graphical example I linked to above is an  
obscure, byzantine mess.  Why must it be so complicated to do such a  
simple task?

Discussion  of Example 5:
On the left side of the screen is a box with 5 inputs and some kind  
of mysterious rectangle with a dotted line in the middle.  Are these  
where the random numbers come from?  Or is the page some kind of loop  
construct?  I am guessing that the dice represent the random number  
generator, but what are the up/down arrows on the first box?  It  
looks like the second "page" is for summation, but all inputs seem to  
come from the lower input to the node -- how does this say to me that  
it is a running total?  What does the DBL mean on the right-hand-side  
of the screen?  The text comment (the only sensible thing on the  
page) tells me it's the "Sum of five random numbers".  I'll have to  
take their word on it.

Because I know C, the C example seems quite clear, and I would argue  
that anyone with basic programming skills would be able to puzzle out  
what it does.  The hieroglyphic (in contrast) seems messy and verbose  
(sort of like writing a GUI in MFC).

Perhaps it would be clearer if I had written it like so:

(require (lib "27.s" "srfi"))

(define (sum-loop running-total count)
   (if (eq? count 0) running-total
       (sum-loop (+ running-total (random-integer 100)) (- count 1))))

(define (sum-of-random-numbers count)
   (sum-loop 0 count))

This might be a bit more readable for a new schemer.

But of course, these are just my opinions.

- -Brent
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (Darwin)

iD8DBQFEHOdUzGDdrzfvUpURApfhAJ4lORQFTBrFD2/Y+OTbqxKQtpkDNQCfc4w4
239me34pPl/B5dq7d0YIgkY=
=yj5a
-----END PGP SIGNATURE-----


Posted on the users mailing list.