* Experiences with learning OCaml?
@ 2004-11-25 11:40 whenning
2004-11-25 11:59 ` [Caml-list] " Erik de Castro Lopo
` (4 more replies)
0 siblings, 5 replies; 15+ messages in thread
From: whenning @ 2004-11-25 11:40 UTC (permalink / raw)
To: caml-list
Hi,
I'm an undergraduate student studying computer science. My course
assignments generally use C, C++, or Java, and I find myself pining for
something more elegant. That is, I'd like to teach myself a functional
programming language of some kind. I don't think I like all the
parentheses in Lisp. But I was very impressed by a Haskell implementation
of the usual quicksort algorithm which was very concise -- only 5 lines or
so. However OCaml seems to have a larger community and has a reputation
for fast executation times, so that seems like a better fit.
The academic term at my university is ending soon and I'll have a few
weeks of free time on my hands -- I was thinking of checking out a
suitable text on some functional programming language from the library and
working through some of it.
Would doing this be difficult if one were sufficiently motivated? I sort
of did something similar with C++ a while ago with some amount of success.
Although I've of course Googled around for potential books to select, are
there any ones particularly suited for someone in my position?
Finally, although OCaml looks interesting, would some other functional
language be better for someone new to functional programming? If so,
which? I ask because I don't know anyone who uses functional languages or
even knows how to use one.
Thanks.
-Warren
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-25 11:40 Experiences with learning OCaml? whenning
@ 2004-11-25 11:59 ` Erik de Castro Lopo
2004-11-25 13:46 ` skaller
2004-11-25 12:28 ` chen yang
` (3 subsequent siblings)
4 siblings, 1 reply; 15+ messages in thread
From: Erik de Castro Lopo @ 2004-11-25 11:59 UTC (permalink / raw)
To: caml-list
On Thu, 25 Nov 2004 03:40:30 -0800 (PST)
whenning@ucsd.edu wrote:
> Hi,
>
> I'm an undergraduate student studying computer science. My course
> assignments generally use C, C++, or Java, and I find myself pining for
> something more elegant.
Indeed.
> Would doing this be difficult if one were sufficiently motivated?
If you are reasonably familiar with languages as complex as C++ and
Java, then Ocaml is definitely not too difficult but will require
you to develope some new ways of thinking about programming problems.
> Although I've of course Googled around for potential books to select, are
> there any ones particularly suited for someone in my position?
Before starting with Ocaml, I had not programmed in a functional
language since some scheme (Lisp dialect) programming in University
around 1990.
I didn't have a book. All I had was the web documentation and a
problem I needed to solve. I ended up writing about 100 small
test programs (100 lines or less) to test different concepts
and techniques.
> Finally, although OCaml looks interesting, would some other functional
> language be better for someone new to functional programming?
Ocaml is a good choice.
Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid)
+-----------------------------------------------------------+
"The RIAA is obsessed to the point of comedy with the frustration
of having its rules broken, without considering whether such rules
might be standing in the way of increased revenues. Indeed,
Napster and Gnutella may turn out to be the two best music-marketing
gimmicks yet devised, if only the RIAA would take its head out of
its ass long enough to realise it."
-- Thomas C Greene on www.theregister.co.uk
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [Caml-list] Experiences with learning OCaml?
2004-11-25 11:40 Experiences with learning OCaml? whenning
2004-11-25 11:59 ` [Caml-list] " Erik de Castro Lopo
@ 2004-11-25 12:28 ` chen yang
2004-11-25 13:52 ` Martin Berger
2004-11-25 13:36 ` Richard Jones
` (2 subsequent siblings)
4 siblings, 1 reply; 15+ messages in thread
From: chen yang @ 2004-11-25 12:28 UTC (permalink / raw)
To: whenning, caml-list
> -----Original Message-----
> From: caml-list-admin@yquem.inria.fr
> [mailto:caml-list-admin@yquem.inria.fr] On Behalf Of whenning@ucsd.edu
> Sent: Thursday, November 25, 2004 7:41 PM
> To: caml-list@inria.fr
> Subject: [Caml-list] Experiences with learning OCaml?
>
> Hi,
>
> I'm an undergraduate student studying computer science. My
> course assignments generally use C, C++, or Java, and I find
> myself pining for something more elegant. That is, I'd like
> to teach myself a functional programming language of some
> kind. I don't think I like all the parentheses in Lisp. But I
> was very impressed by a Haskell implementation of the usual
> quicksort algorithm which was very concise -- only 5 lines or
> so. However OCaml seems to have a larger community and has a
> reputation for fast executation times, so that seems like a
> better fit.
>
> The academic term at my university is ending soon and I'll
> have a few weeks of free time on my hands -- I was thinking
> of checking out a suitable text on some functional
> programming language from the library and working through some of it.
>
> Would doing this be difficult if one were sufficiently
> motivated? I sort of did something similar with C++ a while
> ago with some amount of success.
>
> Although I've of course Googled around for potential books to
> select, are there any ones particularly suited for someone in
> my position?
>
Firstly, I suggest that you should know some basic theory of lambda
culculus,
which definitely help you understand functional programming better.
Then you can write some basic algorithms, such as sorting, binary tree, etc.
Here is an good book, http://caml.inria.fr/oreilly-book/ , or
you can begin with more simple one,
http://www.cs.caltech.edu/courses/cs134/cs134b/book.pdf
> Finally, although OCaml looks interesting, would some other
> functional language be better for someone new to functional
> programming? If so, which? I ask because I don't know anyone
> who uses functional languages or even knows how to use one.
>
Ocaml will satisfy you. Scheme is another good choice, with its simple and
grace syntax.
-chen
> Thanks.
>
> -Warren
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-25 11:40 Experiences with learning OCaml? whenning
2004-11-25 11:59 ` [Caml-list] " Erik de Castro Lopo
2004-11-25 12:28 ` chen yang
@ 2004-11-25 13:36 ` Richard Jones
2004-11-25 20:39 ` Joshua D. Guttman
2004-11-26 6:56 ` William Lovas
4 siblings, 0 replies; 15+ messages in thread
From: Richard Jones @ 2004-11-25 13:36 UTC (permalink / raw)
To: whenning; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 809 bytes --]
On Thu, Nov 25, 2004 at 03:40:30AM -0800, whenning@ucsd.edu wrote:
> Would doing this be difficult if one were sufficiently motivated? I sort
> of did something similar with C++ a while ago with some amount of success.
I would get yourself a project. You could contribute to one of the
existing projects here:
http://caml.inria.fr/humps/caml_latest.html
or start a new one!
I wrote a tutorial for OCaml users which you may find useful:
http://merjis.com/developers/ocaml_tutorial
Rich.
--
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
>>> http://www.team-notepad.com/ - collaboration tools for teams <<<
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
Write Apache modules in OCaml - http://www.merjis.com/developers/mod_caml
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-25 11:59 ` [Caml-list] " Erik de Castro Lopo
@ 2004-11-25 13:46 ` skaller
0 siblings, 0 replies; 15+ messages in thread
From: skaller @ 2004-11-25 13:46 UTC (permalink / raw)
To: Erik de Castro Lopo; +Cc: caml-list
On Thu, 2004-11-25 at 22:59, Erik de Castro Lopo wrote:
> > Would doing this be difficult if one were sufficiently motivated?
>
> If you are reasonably familiar with languages as complex as C++ and
> Java, then Ocaml is definitely not too difficult but will require
> you to develope some new ways of thinking about programming problems.
Functional programming is easy. There's a whole lot of
fuss about something simple.. :)
let decade =
let k = 10 in
map (fun i -> i * k) [1;2;3;4]
I'm sure you'll understand the answer is
the list of integers [10,20,30,40] once you grok the syntax,
and that example contains a higher order function map
(a function accepting a function as an argument) and
a lexically scoped anonymous function (fun i -> i * k)
which binds to the 'k' in scope. .. but these are just
features 'you always wanted in C++ anyhow' and got
sick of writing lame workarounds for ... :)
Once you have these features, your style of programming
will change naturally, even though Ocaml also has classes,
object, mutable varables, and imperative constructions too.
> Ocaml is a good choice.
Yes, because you can have quite a bit of fun solving
problems 'the usual imperative way' and then trying
to make it simpler.. which you'll find functional programming
helps with a lot.
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-25 12:28 ` chen yang
@ 2004-11-25 13:52 ` Martin Berger
0 siblings, 0 replies; 15+ messages in thread
From: Martin Berger @ 2004-11-25 13:52 UTC (permalink / raw)
Cc: caml-list
> Firstly, I suggest that you should know some basic theory of
> lambda calculus, which definitely help you understand
> functional programming better.
while i agree that the lambda calculus is beautiful and very helpful
in understanding functional programming, for someone with a strong
background in programming, i recommend learning a functional
language first and then, later, to delve into the world of lambda.
martin
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-25 11:40 Experiences with learning OCaml? whenning
` (2 preceding siblings ...)
2004-11-25 13:36 ` Richard Jones
@ 2004-11-25 20:39 ` Joshua D. Guttman
2004-11-25 20:56 ` Michael Vanier
2004-11-26 6:56 ` William Lovas
4 siblings, 1 reply; 15+ messages in thread
From: Joshua D. Guttman @ 2004-11-25 20:39 UTC (permalink / raw)
To: whenning; +Cc: caml-list, Joshua D. Guttman
whenning@ucsd.edu writes:
>
>
> Although I've of course Googled around for potential books to
> select, are there any ones particularly suited for someone in my
> position?
>
In my opinion, a splendid book that's full of insights into
computation and languages and how to solve problems is Abelson and
Sussman, Structure and Interpretation of Computer Programs (MIT
Press).
It uses Scheme, which has the infamous parentheses, but really those
aren't as bad as you think. In fact, they're a syntactically minimal
way of writing programs, which doesn't get in your way when thinking
about problems. An outstanding Scheme implementation is PLT Scheme
from Felleisen and his colleagues, now at Northeastern.
Having taken a tour through Abelson and Sussman, you're sure to feel
at home in OCaml or other functional languages, and probably look at
programming in any language with a clearer pair of eyes.
Joshua
--
Joshua D. Guttman <guttman@mitre.org>
MITRE, Mail Stop S119 Office: +1 781 271 2654
202 Burlington Rd. Fax: +1 781 271 8953
Bedford, MA 01730-1420 USA Cell: +1 781 526 5713
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-25 20:39 ` Joshua D. Guttman
@ 2004-11-25 20:56 ` Michael Vanier
2004-11-25 21:16 ` Danny Yoo
2004-11-26 0:47 ` SooHyoung Oh
0 siblings, 2 replies; 15+ messages in thread
From: Michael Vanier @ 2004-11-25 20:56 UTC (permalink / raw)
To: caml-list
I second this (not just because I teach a course based on Structure and
Interpretation of Computer Programs (SICP) ;-)). Also, you should know
that the book is available for free on its web site:
http://mitpress.mit.edu/sicp. I learned most of what I know of functional
programming from reading this book. Another good book is How to Design
Programs, which also uses scheme, and which also is available for free on
its web site: http://www.htdp.org. This latter book is extremely
accessible even to non-programmers, although it's somewhat tedious at
first for more experienced programmers.
Ocaml is a fantastic second functional language after you've gotten the
hang of the functional style, and you can learn it straight from the
manuals. And when you want to go further you should learn Haskell and be
prepared for serious brain-expansion.
The only problem is that once you've learned languages like scheme, ocaml
and haskell (and I'll throw in common lisp for good measure), you'll find
languages like C, C++, java etc. to be deadly dull and annoying (sort of
like a racing car driver being forced to drive a tricycle).
Mike
> From: guttman@mitre.org (Joshua D. Guttman)
> Date: 25 Nov 2004 15:39:50 -0500
>
> whenning@ucsd.edu writes:
>
> >
> > Although I've of course Googled around for potential books to
> > select, are there any ones particularly suited for someone in my
> > position?
> >
>
> In my opinion, a splendid book that's full of insights into
> computation and languages and how to solve problems is Abelson and
> Sussman, Structure and Interpretation of Computer Programs (MIT
> Press).
>
> It uses Scheme, which has the infamous parentheses, but really those
> aren't as bad as you think. In fact, they're a syntactically minimal
> way of writing programs, which doesn't get in your way when thinking
> about problems. An outstanding Scheme implementation is PLT Scheme
> from Felleisen and his colleagues, now at Northeastern.
>
> Having taken a tour through Abelson and Sussman, you're sure to feel
> at home in OCaml or other functional languages, and probably look at
> programming in any language with a clearer pair of eyes.
>
> Joshua
>
> --
> Joshua D. Guttman <guttman@mitre.org>
> MITRE, Mail Stop S119 Office: +1 781 271 2654
> 202 Burlington Rd. Fax: +1 781 271 8953
> Bedford, MA 01730-1420 USA Cell: +1 781 526 5713
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-25 20:56 ` Michael Vanier
@ 2004-11-25 21:16 ` Danny Yoo
2004-11-26 0:16 ` Martin Berger
2004-11-26 0:47 ` SooHyoung Oh
1 sibling, 1 reply; 15+ messages in thread
From: Danny Yoo @ 2004-11-25 21:16 UTC (permalink / raw)
To: Michael Vanier; +Cc: caml-list
On Thu, 25 Nov 2004, Michael Vanier wrote:
> I second this (not just because I teach a course based on Structure and
> Interpretation of Computer Programs (SICP) ;-)). Also, you should know
> that the book is available for free on its web site:
> http://mitpress.mit.edu/sicp.
I want to third the recommendation. *grin* There's also a great set of
video lectures from the SICP authors:
http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-26 0:16 ` Martin Berger
@ 2004-11-26 0:15 ` Michael Walter
0 siblings, 0 replies; 15+ messages in thread
From: Michael Walter @ 2004-11-26 0:15 UTC (permalink / raw)
To: Martin Berger; +Cc: caml-list
On Fri, 26 Nov 2004 00:16:12 +0000, Martin Berger
<martinb@dcs.qmul.ac.uk> wrote:
> i have to disagree. while SICP is a brilliant book that i used
> to teach myself programming from (and nothing i learned as an
> undergraduate really went beyond), these days, i'd recommend
> Ocaml to beginners. scheme has one VERY BIG problem: it is
> untyped (in the sense of static type checking). thinking about
> types properly is such an important factor in becoming a good
> programmer. it seems to me that there is little one can learn
> from scheme that one couldn't learn from ocaml, and probably
> learn better.
So which equally "brilliant book" using ocaml do you recommend? ;-)
Cheers,
Michael
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-25 21:16 ` Danny Yoo
@ 2004-11-26 0:16 ` Martin Berger
2004-11-26 0:15 ` Michael Walter
0 siblings, 1 reply; 15+ messages in thread
From: Martin Berger @ 2004-11-26 0:16 UTC (permalink / raw)
Cc: caml-list
i have to disagree. while SICP is a brilliant book that i used
to teach myself programming from (and nothing i learned as an
undergraduate really went beyond), these days, i'd recommend
Ocaml to beginners. scheme has one VERY BIG problem: it is
untyped (in the sense of static type checking). thinking about
types properly is such an important factor in becoming a good
programmer. it seems to me that there is little one can learn
from scheme that one couldn't learn from ocaml, and probably
learn better.
martin
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-25 20:56 ` Michael Vanier
2004-11-25 21:16 ` Danny Yoo
@ 2004-11-26 0:47 ` SooHyoung Oh
2004-11-26 1:46 ` Michael Vanier
1 sibling, 1 reply; 15+ messages in thread
From: SooHyoung Oh @ 2004-11-26 0:47 UTC (permalink / raw)
To: Michael Vanier, caml-list
I strongly agree with your opinion.
I'v been looking for an introductory book for Ocaml as the first programming
book,
but I couldn't find any good book.
In theses days, I tried to convert some part of HTPC (How to Design
Programs) to ocaml version
and I found the book is very cool as "an introductory programming book with
Ocaml".
It is commenting about types and type errors
and the statements and examples are already almost type safe.
So, I'm looking forward to "How to Design Programs using Ocaml" :).
Anyway, in my experience, the difficult parts to convert are
1. cond-expression -> should be rewritten using pattern-matching; need new
examples
2. symbol information -> decide which one is better? strings or varient
types?
3. structure -> each example using structure shoud be resolved:
how to convert to tuples, records, or varient types case by case
What is needed for more advanced level
1. need a chapter explaining type system? -> currently, I don't think so.
2. need chpaters for module system and OOP? -> nothing or introductory level
only
Differences between Scheme (in HTPC) vs. Ocaml are
1. number : int, float
2. conditional expression: pattern matching expression
3. symbol: string, char, varient type
4. structure: tuples, records, varient types
5. structure definition + data definition: type definition
----- Original Message -----
From: "Michael Vanier" <mvanier@cs.caltech.edu>
To: <caml-list@inria.fr>
Sent: Friday, November 26, 2004 5:56 AM
Subject: Re: [Caml-list] Experiences with learning OCaml?
>
> I second this (not just because I teach a course based on Structure and
> Interpretation of Computer Programs (SICP) ;-)). Also, you should know
> that the book is available for free on its web site:
> http://mitpress.mit.edu/sicp. I learned most of what I know of functional
> programming from reading this book. Another good book is How to Design
> Programs, which also uses scheme, and which also is available for free on
> its web site: http://www.htdp.org. This latter book is extremely
> accessible even to non-programmers, although it's somewhat tedious at
> first for more experienced programmers.
>
> Ocaml is a fantastic second functional language after you've gotten the
> hang of the functional style, and you can learn it straight from the
> manuals. And when you want to go further you should learn Haskell and be
> prepared for serious brain-expansion.
>
> The only problem is that once you've learned languages like scheme, ocaml
> and haskell (and I'll throw in common lisp for good measure), you'll find
> languages like C, C++, java etc. to be deadly dull and annoying (sort of
> like a racing car driver being forced to drive a tricycle).
>
> Mike
>
> > From: guttman@mitre.org (Joshua D. Guttman)
> > Date: 25 Nov 2004 15:39:50 -0500
> >
> > whenning@ucsd.edu writes:
> >
> > >
> > > Although I've of course Googled around for potential books to
> > > select, are there any ones particularly suited for someone in my
> > > position?
> > >
> >
> > In my opinion, a splendid book that's full of insights into
> > computation and languages and how to solve problems is Abelson and
> > Sussman, Structure and Interpretation of Computer Programs (MIT
> > Press).
> >
> > It uses Scheme, which has the infamous parentheses, but really those
> > aren't as bad as you think. In fact, they're a syntactically minimal
> > way of writing programs, which doesn't get in your way when thinking
> > about problems. An outstanding Scheme implementation is PLT Scheme
> > from Felleisen and his colleagues, now at Northeastern.
> >
> > Having taken a tour through Abelson and Sussman, you're sure to feel
> > at home in OCaml or other functional languages, and probably look at
> > programming in any language with a clearer pair of eyes.
> >
> > Joshua
> >
> > --
> > Joshua D. Guttman <guttman@mitre.org>
> > MITRE, Mail Stop S119 Office: +1 781 271 2654
> > 202 Burlington Rd. Fax: +1 781 271 8953
> > Bedford, MA 01730-1420 USA Cell: +1 781 526 5713
> >
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-26 0:47 ` SooHyoung Oh
@ 2004-11-26 1:46 ` Michael Vanier
2004-11-26 3:09 ` SooHyoung Oh
0 siblings, 1 reply; 15+ messages in thread
From: Michael Vanier @ 2004-11-26 1:46 UTC (permalink / raw)
To: shoh; +Cc: caml-list
> 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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-26 1:46 ` Michael Vanier
@ 2004-11-26 3:09 ` SooHyoung Oh
0 siblings, 0 replies; 15+ messages in thread
From: SooHyoung Oh @ 2004-11-26 3:09 UTC (permalink / raw)
To: Michael Vanier; +Cc: caml-list
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
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Caml-list] Experiences with learning OCaml?
2004-11-25 11:40 Experiences with learning OCaml? whenning
` (3 preceding siblings ...)
2004-11-25 20:39 ` Joshua D. Guttman
@ 2004-11-26 6:56 ` William Lovas
4 siblings, 0 replies; 15+ messages in thread
From: William Lovas @ 2004-11-26 6:56 UTC (permalink / raw)
To: whenning; +Cc: caml-list
On Thu, Nov 25, 2004 at 03:40:30AM -0800, whenning@ucsd.edu wrote:
> Although I've of course Googled around for potential books to select, are
> there any ones particularly suited for someone in my position?
If you prefer dead trees, a decent book on the functional style is "The
Functional Approach to Programming" by Cousineau and Mauny:
http://pauillac.inria.fr/cousineau-mauny/main.html
As an added bonus, it uses Caml syntax -- but on the minus side, i really
do mean "Caml" syntax, and not "O'Caml", so there's a small translation
barrier you have to go through. Nothing that's insurmountable with the
O'Caml manual handy, though.
cheers,
William
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2004-11-26 6:56 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-25 11:40 Experiences with learning OCaml? whenning
2004-11-25 11:59 ` [Caml-list] " Erik de Castro Lopo
2004-11-25 13:46 ` skaller
2004-11-25 12:28 ` chen yang
2004-11-25 13:52 ` Martin Berger
2004-11-25 13:36 ` Richard Jones
2004-11-25 20:39 ` Joshua D. Guttman
2004-11-25 20:56 ` Michael Vanier
2004-11-25 21:16 ` Danny Yoo
2004-11-26 0:16 ` Martin Berger
2004-11-26 0:15 ` Michael Walter
2004-11-26 0:47 ` SooHyoung Oh
2004-11-26 1:46 ` Michael Vanier
2004-11-26 3:09 ` SooHyoung Oh
2004-11-26 6:56 ` William Lovas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox