[racket] syntax, differently

From: Mathew Kurian (bluejamesbond at gmail.com)
Date: Sun Aug 1 14:44:53 EDT 2010

Matthias Felleisen: "What do you mean with that? When I have students write
large programs, my Racket programs are routinely a factor of 3 or more
shorter than those of the best of my students (5Kloc in Racket vs 15Kloc in
Java or C# or C++), tend to perform more tasks, and are more stable."

Reply: I apologize for not being more precise with my statement and what i
meant was slightly different. Students, like myself, and especially those in
the beginning of their programming career have challenges optimizing the
code. So what most students would like to do (i have had to help many at my
school with their code and have seen this directly) is actually write
whatever they can to make the program work. For instance, they write a
program with over 100 lines of code which actually only requires 50 lines of
code. In both cases, the program works, although optimization is overlooked
in the former case. Then realizing that their code is actually too long and
too hard to work with, these same kids go back and edit their code, cutting
down the number of lines in order to increase both optimization and ease of
program growth.

My statement: "it is important for students to be able to keep the code very
neat."
Matthias Felleisen' Reply to the above statement: That is true in all
languages, period.

Reply: I agree with Matthias in this case if one is not coding with
universe/world teachpacks. The basic Racket including the gui components and
the other basic components look very clean and easy to understand in a large
program. Usually these codes, like Matthias said, can be put in sets maxing
at 3 lines, and is very neat and easy to read to a third-party. However, in
the case of universe/world teachpacks, where the use of states is a vital
component, a set of code can get very long, especially if the program is
very complex and contains multiple structures (in some cases structures
inside structures inside structures) within the states. With that said, I
was trying to emphasize that it may be harder to students to keep their code
neater compared to some other languages which usually have code that rarely
exceed 1 line.

Example:
Racket using the universe teachpack:

(define (s-mouse-engine s x y event)
  (cond
    [(and
      (and (> x 248)           (< x 424))
      (and (> y 570)           (< y 649)))
        (make-S-STATE
         (get-s-background s)                ;;I have made methods here to
reduce length, but other wise it would be longer.
         (make-button
          (s-mouse-engine-worker1 event "button-img")
          (get-s-button-x s)                   ;;I have made methods here to
reduce length, but other wise it would be longer.
          (get-s-button-y s)                   ;;I have made methods here to
reduce length, but other wise it would be longer.
          (s-mouse-engine-worker1 event "button-initiate")))]

I hope I have clarified any of the questions and i will try to put a mock-up
of what i am talking about in my previous comment.

PS: I am sorry for my error in the statement about drracket compilation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100801/72510f8b/attachment.html>

Posted on the users mailing list.