Version française
Home     About     Download     Resources     Contact us    
Browse thread
Experiences with learning OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: SooHyoung Oh <shoh@c...>
Subject: Re: [Caml-list] Experiences with learning OCaml?

I agree with you that the Ocaml is too complicated for a novice.
We don't have to adhere to full set of Ocaml to introduce how to program, do
we?
For HTDP, I'm planning to reduce the syntax of Ocaml,
and one example is the match-expression WITHOUT a guard.

In HTDP, chapter 4 "Conditioal expressions and Functions" seems to be a part
to teach boolean expressions and cond-expressions,
As you know, match-expressions are widly used in ocaml,
so, I think this chpater can be rewritten
to introduce booleans and subset of match-expressions.
This is why I said I need new examples.
(What about section 4.3 "Pattern-matching: Introduction",
and section 4.4 "Designing Pattern-matching Functions"?)

What I want is not to teach the syntax and semantics of one programming
langage
but to teach how to find solutions from problems and how to describe them
using a progamming language.
In my thought, Ocaml is good for such purpose
because it is a *functional* language ("functional" includes many things),
and
it has modern features such as
- simple syntax :)
- type system including polymorphism,
- module system,
- and OOP

In conclusion, I don't try to teach all functionality of Ocaml for beginners
but I'd like to show how to desing program using subset of Ocaml
from which I wish they would get some inspiration.


----- Original Message ----- 
From: "Michael Vanier" <mvanier@cs.caltech.edu>
To: <shoh@compiler.kaist.ac.kr>
Cc: <caml-list@inria.fr>
Sent: Friday, November 26, 2004 10:46 AM
Subject: Re: [Caml-list] Experiences with learning OCaml?


> > From: "SooHyoung Oh" <shoh@compiler.kaist.ac.kr>
> > Date: Fri, 26 Nov 2004 09:47:06 +0900
> >
> > Anyway, in my experience, the difficult parts to convert are
> > 1. cond-expression -> should be rewritten using pattern-matching; need
new
> > examples
>
> cond is very often used for the equivalent of pattern matching in scheme.
> If you need more flexibility you can always use pattern matching with a
> when clause e.g.
>
> let n = 10 in
>   match n with
>   | m when m < 0 -> -1
>   | m when m = 0 -> 0
>   | m -> 1;;
>
> > 2. symbol information -> decide which one is better? strings or varient
> > types?
>
> Symbols per se don't exist in ocaml (at least without using camlp4), and
> the whole notion of code-as-data is foreign to the ocaml world (again, not
> counting things like camlp4 and metaocaml), so some examples are going to
> be pretty hard to translate.  Still, you can learn a lot by translating
> like this.  I went through part 3.5 of SICP and translated the examples
> into ocaml; the results were very interesting, though haskell would have
> been more elegant for those examples because they all involved lazy
> evaluation.
>
> I'm not sure how appropriate ocaml is as a beginner's language.  I teach
> both scheme and ocaml now, and ocaml is very well-liked by advanced
> programmers (one of whom came up to me raving about his "programming
> epiphany" after learning ocaml), but I think it would overwhelm beginners.
> The syntax is pretty involved, for one thing, and there are just a lot of
> concepts to learn.  Cousineau and Mauny's book _The Functional Approach to
> Programming_ is a good attempt to teach functional programming and ocaml
> (actually caml-light, but it's basically the same) to a fairly naive
> audience.
>
> Mike
>
>