Switching to C/C+

Newsgroups: comp.edu
Path: lyra.csx.cam.ac.uk!sunsite.doc.ic.ac.uk!demon!btnet!newsfeed.internetmci.com!chi-news.cic.net!uwm.edu!psuvax1!news.cc.swarthmore.edu!netnews.upenn.edu!newshost!yang
From: yang@sju.edu (David Yang)
Subject: Summary: switching to C/C++ for a first programming language
Message-ID: 
Organization: Saint Joseph's University
X-Newsreader: TIN [version 1.2 PL2]
Date: Mon, 13 Nov 1995 20:27:06 GMT
Lines: 290


About a month and a half ago, I posted a survey for those who have
been involved in switching from Pascal to C or C++ in their
intro programming course.  I had promised to summarize in a couple
weeks, but have unfortunately gotten caught up with preparing for
classes-- apologies for the delay.  At the end, I have included
a posting presenting the case for using something else (Eiffel)
and for *not* using C++, as I thought it would present a more rounded
picture.  For the record, I am not making any decisions for St. Joseph's
by myself.  I am on a subcommittee of four-- the chair (not me) will be
bringing up the matter for discussion in the whole department (tomorrow,
in fact).  The department seems likely to move to C first and gradually
to C++, for the practical reasons mentioned by several of the folks below,
but things are not settled yet.

We're still interested in feedback on the issue:  please post or send
responses to yang@sju.edu

Thanks to all for your responses,
David Yang


~From: tuinstra@sun.mcs.clarkson.edu (Dwight Tuinstra)
-----------------------------
  I can make one small comment that might be of use.  If you do
switch to C++, you may want texts on C++ for students that already
know Pascal.  Consider/examine carefully before using
"C++ for Pascal Programmers" by Ira Pohl (Benjamin/Cummings Publishing).
One instructor here attempted to use it for a C++ class.  About
a month into the course, she apologized to the class for using
it, and recommended everyone take it back to the bookstore for
a refund.

It may be a matter of teaching style, as she was using it on 
the recommendation of another professor.  Caveat Emptor.

~From: ola@cs.duke.edu (Owen L. Astrachan)
-----------------------------

We switched from Pascal to C in 1990 and from C to C++ in 1993, so
we are now in our third year of using C++ in the first course.

The most important point: do NOT switch to C.  C is a terrible
language for beginning students unless you wrap up its inadequacies
so that students do not have to deal with pointers right away, e.g.,
with scanf.  

There is actually a good book that does this with C.  It is called
The Art and Science of C, by Eric Roberts, published by Addison-Wesley.
With this book you can actually have a good C experience.  However,
you don't get lots of the advantages of C++.  Particularly, when you
cover arrays, there is no way of covering up the inadequacies for
beginners of C-style arrays.  Using an "array class" in C++ makes this
very easy.  We do this in our course and students find the concepts of
arrays and matrices very simple.  This was not the case when we used C
because of the relationship between arrays and pointers.

----
Here are particulars you ask about, books mentioned at the end.

We cover pointers at the end of the first course, but we don't need to.
We don't use them for arrays (see above) but first for arrays of
pointers to structs rather than arrays of structs as a way of saving
space (and time when moving data).  We're experimenting with using some
inheritance with pointers, but don't really do this.  We touch on
linked-lists at the end of our first course, but don't cover them
completely.  Delaying pointers to the second course makes lots of sense.

We use g++, the code and libraries we use has been tested under Borland
(and at another institution with Visual C++) and Metrowerks.  We use
Unix, Emacs, and g++ in our classes.

Once students are accustomed to Unix, it works fine.

-----

Preparing faculty for change:  I initiated the change from C to C++
because of my terrible experiences using C in the first course.  I took
the time to train/educate the other faculty member who does the first
two courses, right now we're the only ones that know enough to do them.
This was a big time-sink for me initially, but there are lots of books
now that make this easier that weren't around three years ago.

Before 1990, only the first two courses used Pascal, all the others used
C.  Now that we switched to C++, students are demanding that they use it
in the upper courses instead of C++.

Many of our majors are double majors, using C++ is much easier than C,
this doesn't appear to be a problem.

We use a large group of undergraduate TAs.  Once a few have gone through
the courses they make much better TAs than the graduate students.  Not
all of our grad students speak good English, and almost none of them
know C++.  Initially this was hard, but now that we have lots of ugrads
with the requisite knowledge it works great.

----

Evaluation:  I'm ecstatic with C++.  Much better than C.  Students like
it (they can get jobs, not the best of reasons but it helps).

Students do just as well in later courses.

------

book:


In our first course we use a book I am writing (have written). 
~Title: A Computer Science Tapestry: Exploring Programming and
Computer Science With C++, published by McGraw-Hill.  The version
you can get now is a "custom-published" beta version, it is being
used at several places: U. Iowa, Gettysburg College, Rose-Hulman
Institute of Technology, St. John's in Minnesotat, Duke.

I don't want this to be an ad for my book, but obviously I think it does
things correctly.  An updated version of this book will be available in
January.  What makes it Beta?  It hasn't gone through full production
(only one color) and there may be some changes before the final book
comes out in the fall of 1996.  However, we've used it for two years and
other places are using it so that I can respond to needs in the final
version.  

It's possible to ftp the beta version

    http://www.cs.duke.edu/~ola/book.html

but McGraw-Hill should send you one if you ask, you can
send email to Eric Munson at emunson@mgh.com

From Karsten.Weihe@uni-konstanz.de Tue Sep 26 04:06:37 1995
--------------------------

Well, I do not teach CS1/CS2 courses in the US, but I've been teaching
similar courses at German universities, in cooperation with colleagues.
In 1992/93, we taught Pascal and, at the very end, a few introductory
lessons on C.  In 1993/94, we started C++.

We have developed a concept for teaching C++.  The most important
points are:

  * In, say, 1/2-2/3 of the first semester, we restricted attention
    to a clean, procedural subset of C++, which is similar to Pascal.
    However, this subset was taught thoroughly (``Pascal in C++ syntax'').

  * Pointers were introduced only in the second semester and very
    carefully and thoroughly.

  * To avoid difficult concepts such as pointers as long as possible,
    the students worked with safe array and string classes, which they
    got for free from us.

  * We introduced template functions very soon, and from then on,
    all assignments included templates. Introducing templates does
    not take too much time and helps students a lot to adopt a
    more abstract point of view.

  * Student were taught to implement their own classes only in the second
    semester.

  * Architecture and function of computers were taught at the beginning
    of the first semester, so teaching features of C++ that are close
    to the system could be based on thorough background knowledge.

  * Each of the last programming assignments included design and
    implementation of a thorough test environment.

  * In the second semester, we wrote _comparatively_ large sources
    ourselves.  In the assignments, we asked the students to fill
    in gaps that we left deliberately.  For example, the source
    of one assignment contained several classes derived from base
    classes, and a few of them were left out.

Hope this helps,

Karsten Weihe


~From: kim sang woo 

   I took high school AP test on PASCAL language and took C/C++ in college.
learning transition was very smooth.  It helped to know little bit of 80386
assembler language.

   When I first got start with C, I used Tom Swan's Learning C++.  I like it
because just my reading through, you have clear idea of how language works.
The drawback is that this book isn't good as a reference.  In my opinion,
you need a book on following topics in order to program C/C++.
   
   C/C++ language  - covers how language is used, syntex,...
   Run Time Library reference - covers function and prototypes of ANSI C
   OS API - to make a call to Operating system either Unix, Dos, Windows, OS2

   We started on the pointer pretty late and we cover little about data structure. I believe that pointers are important part of C/C++ language and think
you should cover it in the beginning.  so you can devote entire semester on
Data structure for link list,trees, hashing and sorting method.

   I have programmed under Borland C++, GCC,C++, unix Sun CC, VC++, Watcom C++,
Turbo C++, Quick C and student version of Zortech C++.  The best compiler
was Watcom C++ and am still using this product however Watcom environment is
design for advanced users.  For beginner, you should get a compiler with a very
simple environment like Turbo C++ or Borland C++.  Unix CC/ gcc is worst
compilers to use because error messages are not as specific as other compillers.

   I like OS2 environment.  Under C++, you can easily crash the machine without
proper protection.

   Far as I can see students really like Turbo C++ environment.  Borland put
lot of consideration on quick & easy interface.
 
~From: Mark Richard 

I am a May '94 EE graduate of LSU in Baton Rouge, LA.  When I started the 
EE recomended courses in 1989 Pascal courses 1 & 2 were on the schedule.  
When I got into the 3rd year of my Engineering courses all the professors 
wanted the programs written in C.  For those who made objections and 
didn't have any C experience the professors allowed them to write the 
programs in Pascal.   Doing this could be just delaying the inevitable.  
Some people found it easy to just jump from one to the other, I am the 
type that gets the syntax mixed up.  I took a C course to get started 
and found it difficult to transform, but there were those that found it 
harder and some found it easy; so it depends on the person.  Once I 
transferred to C I didn't dare go back to Pascal.

From Dr. Weisskopf of the University of Alabama at Huntsville:
(The following was extracted from a phone interview)
-- switched from Pascal to C gradually, with C being introduced as
   an elective the first 2 years
-- now both CS1 and CS2 are taught in C
   -- teaching different languages in the 2 courses led to students
      having syntax troubles and not learning either language.
-- object-oriented programming is an elective
-- pointers are introduced only for parameter passing in the 1st semester,
   mostly in the mode of "trust us on this for now"
-- expanded from 3 hour class to 4 hour class + lab,
   where the lab uses structured exercises
-- they have grad students as teaching assistants
-- no negative feedback from math/science/engineering majors,
   but some complaints from the liberal arts majors
-- start with Borland Turbo C++'s C subset, when they are comfortable
   with the language, they can move to workstations
-- They're using an Addison-Wesley book with Coffman as a co-author,
   C Programming for Engineers, for CS 1 and several choices for CS 2,
   with a book by Standish having a good intro to pointers, though the
   book as a whole is a bit theoretical.
-- they are reasonably pleased with the transition, and the students
   are overall happier

~From: riley@dellirium.uwlax.edu (David Riley)
--------------

IF (and I need a larger font for this "IF") we accept the premise that CS 
programs should concentrate on the usage of programming that are popular 
with programming shops or that may be required on future AP exams due to 
the influence of a single individual, then I still believe there is an 
important consideration that you have overlooked.  This consideration is 
that it is more important to worry about the student's skills at the time 
of graduation than to concentrate on the initial programming language.

It seems to me that one needs to begin with programming paradigms.  If you 
decide that students need are most likely to use the imperative paradigm, 
then Modula-2 seems like a better initial language than C++.  If you decide 
that students need to be functional programmers, then ml or scheme are 
better initial languages.  We happen to believe that the object-oriented 
paradigm is more important, so we're using Eiffel as the initial language.  
Our advanced courses make extensive use of C++, but we've found through 
experience that C++ doesn't work well for our beginning students.

In Eiffel we can, and do, teach encapsulation, inheritance, polymorphism, 
and genericity as a natural part of the first semester.  To do the same 
thing properly in C++ would require the discussion of virtual functions, 
constructors, destructors, copy constructors, and templates.  This is too 
much overhead, at least for our first semester students.   

The introductory C++ courses and textbooks with which I am familiar follow 
one of two paths.  Either they cover non-OOP C++ (almost a C subset of C++) 
or they are full of example C++ classes that would never be acceptable if 
written for production OO code.  It turns out that learning most of the C++ 
primitives are simply syntactic discussions once you understand the 
underlying OOP concepts.  Advanced CS students, who understand OOP don't 
struggle learning C++, but freshman certainly do.

~From: dhm63162@Pegasus (Dale H McCauley)
--------------

The University of Central Florida used to use Pascal as an introductory 
language but later went to Modula-2.  Their reasoning, to my knowledge 
was that Modula-2 and Pascal both have more error checking that C and 
this was better for a new student.


Tim Love, tpl@eng.cam.ac.uk