Newsgroups: comp.edu,comp.lang.ada,comp.lang.c++,comp.lang.modula2,comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!europa.chnt.gtegsc.com!library.ucla.edu!agate!news.ucdavis.edu!csus.edu!netcom.com!adaworks
From: adaworks@netcom.com (AdaWorks)
Subject: Re: Comparison of languages for CS1 and CS2
Message-ID: <adaworksDB25t3.5nB@netcom.com>
Followup-To: comp.edu,comp.lang.ada,comp.lang.c++,comp.lang.modula2,comp.lang.scheme
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
X-Newsreader: TIN [version 1.2 PL1]
References: <3pdnsi$i2v@urvile.MSUS.EDU> <3r0asd$e5q@seagoon.newcastle.edu.au> <3ro6tf$e4q@tokyo.engr.sgi.com> <EACHUS.95Jun16171929@spectre.mitre.org> <3rtcht$1k9@crl2.crl.com> <3skshd$1uc@seagoon.newcastle.edu.au> <rsutc-2606950743360001@nsc189t100.twu.
Date: Sat, 1 Jul 1995 22:15:03 GMT
Lines: 97
Sender: adaworks@netcom16.netcom.com
Xref: glinda.oz.cs.cmu.edu comp.edu:13068 comp.lang.ada:31989 comp.lang.c++:136203 comp.lang.modula2:11896 comp.lang.scheme:12988


Theodore Dennison (dennison@escmail.orl.mmc.com) wrote:
: je@bton.ac.uk (John English) wrote:
: >Similar problems arose in Ada with everyone producing their own "simple
: >I/O" packages to avoid having to teach generic instantiations from day 1.

   I have found this to be quite effective for teaching Ada to community
   college students.  My "simple" package overloads PUT and GET operations
   for all the types in package Standard.  I call it Standard_IO.  The
   students never need to see Text_IO during that part of the course 
   where they are getting comfortable with writing simple programs. 

   The package also includes a procedure Set_Cursor so the students can
   program in Ada doing stuff they have learned to do in earlier classes
   in BASIC and Pascal.  The PUT operations are procedures.  The scalar
   GET operations are functions.  All GET operations have a prompt option 
   such as:

      function Get(Prompt : String := "") return Integer;

   The GET operation for Float includes an option for sloppy input of
   the floating point value:

      function Get(Sloppy : Boolean := False;
                   Prompt : String  := "" ) return Float;

   so the user an input floating values of 2., .2, or 2.0 without getting
   exceptions

   I also include a nested Catenator package that can be "used."  This has
   operators such as:

      function "&" (L : Float; R : String) return String;

   that can be used to catenate elements in various Put operations.

   
  As a little preview of abstract data types, this package includes a 

       type Answer is limited private;

  with appropriate supporting operations.  This allows the student to create
  little dialogue managers that accept Yes, Y, No,and N replies.

: Hmmm. I assume what you are saying is that you don't want to have to
: teach generics, but you feel you have to for any simple text output that
: involves numbers, because of the generic numeric IO packages. Is that
: what you are saying?

  A more important pedagogic issue than generics is abstraction.  I use this 
  package to demonstrate to students how we can start with a set of primitive
  resources such as those in Text_IO and raise the level of abstraction
  to the appropriate level for the set of problems to be solved. 

  This entire package specification is one printed page long. I refer to it
  frequently, even after we have gone on to use Text_IO directly, as an
  example of how, in software engineering, we focus on building appropriate
  abstractions rather than just writing computer programs.

  This also illustrates the "generalization" principle.  It complements
  the "specialization" principle that is currently so much in vogue in
  the form of inheritance.  

: I very seldom use those generic packages myself. If I have to print
: an integer I typically write something like: (warning:unetested code)

:     Text_IO.Put_Line ("The number of lines in the file is " &
:                        integer'image (Count)
:                      );

 This method is sometimes useful, and we agree that it should be available.
 But it is still at the wrong level of abstraction.  And it does not work,
 under Ada 83, for non-discrete types.

: It is rare I ever see anyone instantiate a generic IO package (and
: when I do, it tends to be Sequential_IO). Just about anything you
: might want to print out can be converted to text with an attribute.
: Why don't you teach your students this instead?

 Eventually, students do learn to use instantiation, attributes, and all the
 other goodies in Ada. When teaching community college students, we want them
 to begin doing exercises after the first class session.  By providing a
 package that permits this, we get them using Ada quickly, albeit with the
 same level of typing one would find in a BASIC or C class.  

 This works out quite well because there is little grumbling about how hard
 Ada is.  In fact, we seduce them into believing it is quite easy within the
 first two weeks of class.  Then they begin to learn the interesting stuff.

 Whenever when we are engaged in a teaching activity, we must assess the 
 skill and motivation of our target audience.  

 Richard Riehle
 adaworks@netcom.com

-- 
                                             adaworks@netcom.com
