caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Andrej Bauer <Andrej.Bauer@fmf.uni-lj.si>
To: OCaml <caml-list@inria.fr>
Cc: David Teller <David.Teller@univ-orleans.fr>
Subject: Re: [Caml-list] Which syntax to teach ?
Date: Wed, 24 Oct 2007 19:23:07 +0200	[thread overview]
Message-ID: <471F7F7B.9040905@fmf.uni-lj.si> (raw)
In-Reply-To: <1193225773.3612.27.camel@Blefuscu>

David Teller wrote:
>  In a few months, I'll start teaching OCaml for the second consecutive
> year. I'll solve a number of my problems by installing Linux on the
> workstations, although I'm pretty sure that will cause no end of
> complaints from the students when they need to continue their work at
> home.

My experience with teaching theory of programming languages, where we
implement mini interpreters and compilers with Ocaml:

1. Students want to use Microsoft Windows.
2. Students HATE Emacs because its basic behavior regarding selections,
   cut & paste is counter-intuitive to them.
3. Students think Make is an archaic nuisance (and they're right).

So this year we switched to Eclipse + OcaIDE + ocamlbuild. As long as
you instruct your students to install (in this order!)

  Cygwin
  Ocaml 3.10 (not from cygwin package manager!)
  Java 1.6
  Eclipse 3.2
  OcaIDE

on their home computers, they should be fine. This year students have
much less initial trouble. (The combination cygwin + XEmacs + tuareg +
ocaml + Make was a real nightmare in previous years.)

Even though OcaIDE is sort of half-done and ocamlbuild is very
Unix-centric, it's still a useful combination.

As far as teaching ocaml goes, here are a few tips:

1. Do not bore them with syntax. They will just absorb it, and it
doesn't matter which version it is, so pick the one that does not
require extra options and settings. There are a few traps they will fall
into--when they do, explain what is going on. With time you will be able
to anticipate them.

2. Point out differences with programming languages they know, e.g.:
- you can put if-then-else _anywhere_
- you can put local definitions _anywhere_
- "let x = .. in .." defines an _immutable_ value x
- functions don't have a "return" statement, you just write the result,
like you do in math

3. The following is confusing to beginners:

let f x = function <cases>

They think it's a function of one variable. When asked to define a
function of two variables, they might write

let g x y = function <cases>

So I always start strictly with the form

let f x =
  match x with
   <cases>

let g x y =
  match y with
   <cases>

Then I teach "shorthands"

let f = function ...

let g x = function ...

4. You will be sorry if they know Java and you teach them early about
references, assignments and loops.

5. Explain ahead of time why things like

   List.nth lst (List.length lst - 1)

are bad. From Java they know it's trivial to access the n-th component
and to find out the size of a container.

6. Special care is needed in explaining and advertising sum types
(variants) because they only exist in mutilated form in commonly used
languages.

7. They easily understand how the standard library is used (but not the
functors), the open statement, the fact that a program may be in several
.ml files. The .mli files are a bit more mysterious. Functors are _very_
mysterious.

8. Error messages come from hell. They are a big hurdle and you need to
devote special attention to them.

Best regards,

Andrej


  parent reply	other threads:[~2007-10-24 17:22 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-24 11:36 David Teller
2007-10-24 13:18 ` [Caml-list] " Loup Vaillant
2007-10-24 13:24 ` Peng Zang
2007-10-24 13:54   ` Julien Moutinho
2007-10-24 17:23 ` Andrej Bauer [this message]
2007-10-24 19:05   ` Adrien
2007-10-25  5:14     ` Aleks Bromfield
2007-10-30 16:26     ` Chung-chieh Shan
2007-10-30 16:38       ` [Caml-list] " Brian Hurt
2007-10-30 16:59         ` Chung-chieh Shan
2007-10-30 17:08         ` [Caml-list] " Edgar Friendly
2007-10-30 17:56           ` skaller
2007-10-30 19:02             ` Vincent Aravantinos
2007-10-30 18:50           ` William D. Neumann
2007-10-30 21:45           ` Eliot Handelman
2007-10-30 18:56       ` Daniel Bünzli
2007-10-25  9:43   ` [Caml-list] " Richard Jones
2007-10-24 22:52 ` Nathaniel Gray
2007-10-24 23:10   ` Jon Harrop
2007-10-25  1:48     ` skaller
2007-10-25  2:02       ` Jon Harrop
2007-10-25  9:49       ` Richard Jones
2007-10-25 11:32         ` Stefano Zacchiroli
2007-10-25 11:52           ` Daniel Bünzli
2007-10-25 12:39           ` Richard Jones
2007-10-25 12:59         ` Michael Ekstrand
2007-10-25 13:39           ` Loup Vaillant
2007-10-25 20:32             ` Andrej Bauer
2007-10-25 22:11               ` Loup Vaillant
2007-10-25 15:14           ` Richard Jones
2007-10-25 18:47             ` Re : " Adrien
2007-11-02 16:08       ` Nathaniel Gray
2007-10-26 11:11     ` David Teller
2007-10-24 23:02 ` Jon Harrop
2007-10-26 11:09   ` David Teller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=471F7F7B.9040905@fmf.uni-lj.si \
    --to=andrej.bauer@fmf.uni-lj.si \
    --cc=Andrej.Bauer@andrej.com \
    --cc=David.Teller@univ-orleans.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).