[plt-scheme] Re: [plt-edu] Re: animation projects, video-game and not

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Feb 7 13:06:19 EST 2009

On Feb 7, 2009, at 12:48 PM, Mark Engelberg wrote:

> On Sat, Feb 7, 2009 at 8:46 AM, Matthias Felleisen  
> <matthias at ccs.neu.edu> wrote:
>>
>> ... it demonstrates
>> how JAVA is even MORE suited for this kind of programming than plain
>> functional Scheme when you get to large programs. (Of course, in  
>> Java like
>> in Cobol, everything is large.) -- Matthias
>
> Can you elaborate for a few sentences, maybe giving an example from
> one of these libraries that turned out more
> elegant/cleaner/organized/etc. in Java vs. Scheme, and what aspects of
> Java made it so?

Think of the World as an object for which you have three or four  
methods:

  ;; tick :  World -> World
  ;; click : World KeyEvent -> World
  ;; clack : World MouseEvent - World
  ;; draw :  World -> Scene
  ;; stop? : World -> Boolean

As you can see (1) these methods belong together, (2) in a functional  
language you must pass in the world, and (3) you usually destructure  
it via field access to the struct. So there is clearly a certain  
intellectual elegance to

  (define World
    (class ...
      ;; -> World
      (define/public (tick) ...)
      ;; KeyEvent -> World
      (define/public (click ke) ...)
      ;; MouseEvent -> World
      ... ))

Pardon my Java :-) You see it's really about having classes around to  
organize your code. It has nothing to do with Java.

Better still, you can use inheritance to prepare default behaviors  
and then quickly instantiate this anticipated scenarios. When I teach  
Softw Dev (~12 Kloc to 18 Kloc of Java for the poor students who use  
Java), I actually use the PLT Scheme class system to write code like  
this.

That's what I meant.

> I'm trying to help my son "Reach Java", but since he's spent a couple
> years getting quite adept at Scheme, he's having a hard time seeing
> the value of learning Java.  I'm having a hard time motivating the
> study of Java, so any words of wisdom about this would be helpful.


Unless you think your 12 year old son should prepare himself now for  
a career in software engineering of Java systems, I see NO NEED for  
him to listen to you. Tell him your former professor says so :-) Java  
sucks

-- Matthias





Posted on the users mailing list.