Jython vs Squeak for teaching multimedia

Roger Whitney whitney at cs.sdsu.edu
Thu Jul 4 03:41:29 UTC 2002


Here is a Squeak version:

firstResponse := FillInTheBlankMorph request: 'Type a number'.
secondResponse := FillInTheBlankMorph request: 'Type a number'.
result := firstResponse asNumber + secondResponse.
^result

No need to run headless. One can use GUI components fairly easily.

I missed the convert methods in Java, so your solution is shorter than 
mine.

I think the reason objects and classes may be avoided in intro classes 
is that the people who teach them think objects are too complex for 
students.

On Thursday, June 27, 2002, at 07:24  PM, Richard A. O'Keefe wrote:

> Roger Whitney <whitney at cs.sdsu.edu> wrote:
> 	Many places in USA, including where I teach, teach Java without
> 	classes. ...
> 	Try to do the following simple beginner assignment in Java:
> 	
> 		Prompt the user for two numbers and print out their sum.
> 	
> OK.
>
>     import java.lang.*;
>     import java.io.*;
>
>     public class MyFirstProgram {
>         public static void main(String argument[]) {
> 	    try {
> 		Reader r =
> 		    new BufferedReader(new InputStreamReader(System.in));
> 		StreamTokenizer t = new StreamTokenizer(r);
>
> 		System.out.print("Enter two numbers: ");
> 		if (t.nextToken() != StreamTokenizer.TT_NUMBER)
> 		    throw new IOException();
> 		double first_number = t.nval;
> 		if (t.nextToken() != StreamTokenizer.TT_NUMBER)
> 		    throw new IOException();
> 		double second_number = t.nval;
> 		System.out.println(first_number + second_number);
> 	    } catch (IOException e) {
> 		System.out.println("Oops!");
> 	    }
> 	}
>     }
>
> 	You will discover that using the command line you have to read & parse
> 	the input character by character and manually convert the input to a
> 	number.
>
> This claim at least is totally false.  (Amongst other things,
> Double.valueOf("<some number>") can be used for the conversion.)
> For my purposes, at any rate, StreamTokenizer is *the* answer to
> elementary text input in Java.  It isn't ideal, but it is _there_.
>
> 	You also have to deal with exceptions, streams, static etc.
> 	Java input is really too complex for raw beginners.
> 	
> This of course I completely agree with.  This is why several Java CS1
> books come with their own simple I/O package.
>
> None of this explains why it is better to avoid classes.
> Don't students _wonder_ what Reader is (it's a class) and
> what kind of thing they find string->number conversion in (they're 
> classes)?
> Or are you vehemently agreeing that "Java without classes" is like
> joining the group on the bandwagon so you can ride underneath?
>
> 	Now try the same problem in Squeak. How many weeks (months) earlier
> 	could you assign the problem in a Squeak class than in a Java class?
> 	
> Depends on how much luck you have getting Squeak to run headless,
> I suppose.
> 	
> The thing _I_ find objectionable about this example is that on a 250MHz
> UltraSparc I it takes fully three seconds from the time I type RETURN
> at the end of "java MyFirstProgram" to the time that the prompt appears.
> (Any Lisp programmers who remember how Lisp was reviled as too big and
> too slow?  Feh!)
>
>
>
>

----
Roger Whitney              Mathematical & Computer Sciences Department
whitney at cs.sdsu.edu        San Diego State University
http://www.eli.sdsu.edu/   San Diego, CA 92182-7720
(619) 583-1978
(619) 594-3535 (office)
(619) 594-6746 (fax)




More information about the Squeak-dev mailing list