From: Philippe Wang <mail@philippewang.info>
To: Alan Schmitt <alan.schmitt@polytechnique.org>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] use of ";;" when teaching Ocaml
Date: Thu, 25 Jun 2015 18:51:27 +0200 [thread overview]
Message-ID: <CAAFfW_oEPqrraQfuDYTdVwAJRJfd5qwzVoWFAd8QMRnRNiBOAA@mail.gmail.com> (raw)
In-Reply-To: <m2si9itv0r.fsf@charm-ecran.irisa.fr>
On Tue, Jun 23, 2015 at 3:27 PM, Alan Schmitt
<alan.schmitt@polytechnique.org> wrote:
> Hello,
>
> Thanks to everyone for your answers, this has given me much food for
> thought.
>
> On 2015-06-23 01:41, Philippe Wang <mail@philippewang.info> writes:
>
>> In my opinion, it's a lot more relevant to use a very limited and very
>> simple subset of OCaml when teaching to beginners. And this subset
>> does not involve expressions at top-level because it's not worth the
>> trouble.
>
> I like this approach because it amounts to saying "one always starts
> a phrase with 'let' or 'type'" (and later in the year there can be
> 'open', 'module', 'include'). I sure can live without top-level
> expressions.
>
> On the other hand, I also like the idea of terminating phrases, simply
> because explaining when it terminates is not trivial otherwise, as
> a 'let' may not be the beginning of a phrase.
Well, a computer is (by definition) stupid, and languages made by
humans are like human: none is perfect! :)
So... there's the global `let` and the local `let...in`, it sucks a
little but everyone is free to propose a new language (yeah, that's
what i used to tell student who would complain about design) :)
>> Also, using the interactive top-level loop is, in my opinion, not good
>> for beginners. It should only be presented to those who already
>> understand very well the "core" of OCaml. The most frequent issue with
>> the top-level loop is that it gets in the way of the notion of
>> compiling a program, and it might give the false impression that OCaml
>> can be interpreted.
>
> I am curious about this. My goal is to teach the language, and I find
> that a REPL backed with a file works great to do this (using tuareg or
> ocaml-top). What do you use to make sure students have a fast
> compile/debug cycle?
Well, it depends a lot on the skills of the students: for beginners, I
believe it doesn't help a lot to have the REPL. The one very annoying
thing that goes with REPLs is understanding the difference between the
result of a program and what is printed on stdout (or even stderr).
For instance, lots of students would mix "42;;" and "print_int 42;;"
and you would need to spend quite sometime explaining this and
repeating they are not the same at all, and spend quite some energy
containing the bomb that wants to detonate inside of you when they
keep repeating that mistake!
But, if you have some experimented programmers, or some extremely
smart beginners, you may have fun with this kind of things because
there actually are so many of them in OCaml, like a gigantic gold
mine. (I have to admit, I kind of like it. But when I want efficiency,
I don't go there.)
So, fast compile/debug cycle? Well, my suggestion is to use a Makefile
and invoke make as often as possible (meaning as soon ). If the
program is small enough, I won't even use make, I will directly call
ocamlc. (Not ocamlopt, because ocamlc is faster at compiling than
ocamlopt.) Well, then when the program becomes "big" enough, I will
use a Makefile.
The errors messages of ocamlc/ocamlopt are not worse than ocaml
REPL's, sometimes they are even better. Also, it will avoid the
awkward situation where your program works fine with ocaml but won't
compile with ocamlc/ocamlopt, because there's a weirdo that has weak
types... ;-)
Note that it's possible to use `ocaml program.ml`, so you don't have
to do something like `ocamlc program.ml && ./a.out`.
Also, it's not bad to tell your students to declare all their
functions before implementing them. Use for instance
let koala food = failwith "koala not implemented yet", especially when
they have mutually recursive functions: this way they may compile
their programs before they have (wrongly-)implemented everything, and
look for errors, instead of having to have a giant mess to deal
with...
Cheers,
Philippe Wang
next prev parent reply other threads:[~2015-06-25 16:51 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-22 13:31 Alan Schmitt
2015-06-22 13:52 ` Ivan Gotovchits
2015-06-22 13:53 ` Daniil Baturin
2015-06-22 14:19 ` Gerd Stolpmann
2015-06-22 15:48 ` Damien Doligez
2015-06-22 15:56 ` Thomas Refis
2015-06-22 16:07 ` Mark Shinwell
2015-06-22 16:30 ` Gerd Stolpmann
2015-06-22 16:47 ` Mark Shinwell
2015-06-22 17:08 ` Daniel Bünzli
2015-06-22 18:56 ` Gerd Stolpmann
2015-06-22 17:18 ` Török Edwin
2015-06-22 17:42 ` Francois Berenger
2015-06-22 17:46 ` Ivan Gotovchits
2015-06-22 17:53 ` John Whitington
2015-06-22 16:07 ` Pippijn van Steenhoven
2015-06-22 16:25 ` Daniel Bünzli
2015-06-22 18:18 ` Steve Zdancewic
2015-06-22 16:42 ` Thomas Refis
2015-06-22 16:47 ` David House
2015-06-22 17:08 ` Daniil Baturin
2015-06-22 17:04 ` Daniel Bünzli
2015-06-22 23:41 ` Philippe Wang
2015-06-23 1:15 ` Kenichi Asai
2015-06-23 13:27 ` Alan Schmitt
2015-06-23 13:35 ` Ivan Gotovchits
2015-06-23 13:36 ` Ivan Gotovchits
2015-06-25 16:51 ` Philippe Wang [this message]
2015-06-29 0:12 ` Philippe Wang
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=CAAFfW_oEPqrraQfuDYTdVwAJRJfd5qwzVoWFAd8QMRnRNiBOAA@mail.gmail.com \
--to=mail@philippewang.info \
--cc=alan.schmitt@polytechnique.org \
--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