From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA25138; Fri, 14 Mar 2003 09:12:12 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA25214 for ; Fri, 14 Mar 2003 09:12:10 +0100 (MET) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from web11004.mail.yahoo.com (web11004.mail.yahoo.com [216.136.131.54]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id h2E8C9X12927 for ; Fri, 14 Mar 2003 09:12:09 +0100 (MET) Message-ID: <20030314081208.86223.qmail@web11004.mail.yahoo.com> Received: from [24.189.36.21] by web11004.mail.yahoo.com via HTTP; Fri, 14 Mar 2003 00:12:08 PST Date: Fri, 14 Mar 2003 00:12:08 -0800 (PST) From: Sergey Goldgaber Subject: Re: [Caml-list] poll - need for a good introductory OCaml book (LONG) To: Caml-list Cc: Graham Guttocks MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam: no; 0.00; sergey:99 caml-list:01 introductory:99 manning:99 hickey's:01 steadily:99 stumbling:01 recursion:01 inference:01 step-by-step:99 idioms:01 passing:01 programmer's:01 equivalents:01 ocaml's:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Disclaimer: Sorry about the long-windedness of this, but I think good, intuitive tutorials are some of the most important things a language needs in order to be successful. So I thought I'd share my experiences with learning OCaml in some detail. Graham Guttocks wrote: > > There seems to me clearly, a lack of a good, tutorial style, > introductory book about OCaml in English. Something akin to > ``Programming Perl'' (as someone mentioned). > > I'm talking to a publisher at Manning (http://www.manning.com) about > the possibility of such a book. They are intrigued, but would like to > see some indication that people are interested. > > Would you like to see such a book? Oh, god YES!! I have been struggling to learn OCaml for over a month now. It is, without a doubt, the hardest language I have ever tried to learn, and in some ways makes assembly language look simple and intuitive by comparison. Now, I am not a novice at programming. I have used computers since 1980, I know: C, Perl, Assembly, Pascal, Visual Basic, shell scripting, Logo, REXX, SQL, HTML. Picking up most any of those (except for assembly) was a breeze. But learning OCaml, as it is my first functional language, is painful (until I have an "aha" moment, when I glimpse its elegance and power, and all the pain seems worth it). I have gone through Bruce Hauman's "Intorduction to Ocaml" tutorial, Scott Smith's lecture notes, and Jason Hickey's "Intorduction to the Objective Caml Programming Language". I have also read through parts of the O'Reilly book, but it really wasn't doing all that much for me. Also, I really like to have a physical book in front of me (such a large online volume is uwieldy, and it's too much to print out). Fortunately, I managed to find Guy Cousineau's and Michel Mauny's "The Functional Approach to Programming" used and got that. I have been slowly and steadily making my way through that, and it covers the language in quite a bit of detail and in a good tutorial matter, and I am generally very happy with it. However, I think the presentation of the material could be even better. Also, it only covers Caml Light, so I think that might become an issue at some point. Coming from a purely imperative background I found the following concepts the biggest stumbling blocks in my attempts at learning OCaml: functional style, recursion, type inference Of the three, I would say that in all of the material I have read only type inference is covered in any serious detail. And even there the focus could be stronger and the explanations better. Recursion is usually glossed over, and assumed to be just the natural way to accomplish tasks. When being taught most imperative languages one is taught the very basics of recursion, but actual use is comparatively rare. As recursion is the mainstay of functional programming I think it needs to be covered in a much, much more detailed, step-by-step manner. And many relatively basic exercises (with answers and especially explanations of the answers) that should be done before attempting any of the more advanced and complex OCaml idioms. In your average Ocaml tutorial functional style is also not really emphasized or explained well (if at all). Sure, functional style is used in the examples, but rarely is any attention given as to why you would want to do things this way. As OCaml offers one the choice of using an imperative style, that's what I find myself naturally gravitating towards when I start coding on my own (as opposed to solving toy problems for the exercises). I have to stop and force myself to think: "now how can I do this in a more functional style, perhaps using recursion?" The tutorials show you how functions can be passed as arguments, but for me it is so much more natural to just pass around normal variables and values to distinct functions, rather than create a series of functions each of which calls the next while passing functions around. This practical aspect of the functional style is rarely explained. You are shown that problems _can_ be solved this way, but not really shown _why_ they should be solved this way rather than in an imperative manner, or how you can think of these complex constructions yourself. Too much is ready-made in these tutorials. "Here's a Y-Combinator", "this is how it works". But how would you ever think of a solution like that yourself? And why would you want to rather than implementing an imperative solution? That's what is needed. I think something like a "C Programmer's Introduction to OCaml" or "From C to OCaml" book would be really great. It should assume no previous experience with functional languages, and perhaps could start by showing the OCaml equivalents of C constructs like for loops. That will somewhat simplify learning OCaml's "strange" syntax. You could continue by focusing on OCaml's imperative aspects, so that C programmers will quickly feel comfortable because they are on home turf. And only then, in the intermediate and advanced sections of the book should you cover the functional aspects of the language, again with plenty of juxtapositions between the imperative and functional styles, and exercises, exercises, exercises. As for the object oriented aspects of OCaml, I have no comment yet. I'm saving trying to learn that until I feel very comfortable with the functional aspects of the language. But if you get the rest, and slap a "friendly" cover on (but not too friendly, or it will seem like a "toy" language), I think you'll have a hit. --Sergey __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners