[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

wanted: teaching do's and dont's



Our experience at MIT is that it is often the case that students with
previous programming experience suffer MORE in the course than
students without such experience, since the latter are not biased.

In particular, students familiar with BASIC and FORTRAN (and probably
PASCAL) tend to have a hard time adapting to the functional style
encouraged by Scheme.  They view DEFINE as assignment, which it isn't,
and even if they get used to the functional style, when assignment
(SET!) is finally introduced, they often revert to the ugly imperative
style.  They sometimes have this crazy notion that imperative style is
more efficient.  Interestingly enough, code with side effects is often
LESS efficient in T and in MIT Scheme with the new compiler.

Although Pascal is, like Scheme, lexically scoped, students do not
have a really hard time accepting this, so I'm not sure it's a real
advantage.

Obvious potential stumbling blocks, beyond style:

Absence of VAR parameters, used sometimes to "return" multiple values in
Pascal.  This is usually done in Scheme (in dialects without multiple
values) in one of two ways: returning a data structure (list or
vector) with the appropriate contents, or passing an explicit
continuation with many parameters to the procedure that wants to
return multiple values, which will, instead of returning, invoke its
explicit continuation with the multiple "returned" values.

Absence of iteration constructs.  Standard Scheme has DO, but it is
not used in S&ICP, in fact, we did not even have it in MIT Scheme
until the report describing Standard Scheme came about.  Iteration has
to be achieved through syntactic recursion.  One of the reasons for
not having syntactic sugar in MIT Scheme (originally) was to emphasize
this point, and force students to deal with the issue.

Absence of explicit allocation.  Memory management in Scheme is
automatic, rather than manual.

Eventually, the fact that thanks to tail recursion and first class
procedures (and worse, cwcc, but this is not covered in S&ICP), Scheme
is a completely unstructured language (in the sense of "structured
programming").  Procedures (lambda expressions) are labels, and
application is GOTO, and any arbitrary control structure can be built
on top of this.

PS: There is a teacher's manual for S&ICP written by Juile Sussman.
It is very good.  It contains more examples, more problems, and a very
detailed description of where students go wrong in various places, and
what points need further emphasis.  I believe (HAL or GJS can correct
me here) that it can be obtained through McGraw Hill.