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 QAA24704; Thu, 3 Jun 2004 16:20:44 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA24692 for ; Thu, 3 Jun 2004 16:20:42 +0200 (MET DST) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i53EKfSH007135 for ; Thu, 3 Jun 2004 16:20:41 +0200 Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.11.6/8.10.1) with ESMTP id i53EKXG08768; Thu, 3 Jun 2004 09:20:33 -0500 (CDT) Date: Thu, 3 Jun 2004 09:27:52 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: Jean-Christophe Filliatre cc: Holger Schulz , Subject: Re: [Caml-list] Teaching OCaml In-Reply-To: <16574.54515.560699.848619@gargle.gargle.HOWL> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 40BF33B9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 filliatre:01 quicksort:01 haskell:01 immutable:01 spotting:01 immutability:01 arrays:01 ocaml:01 ocaml:01 writting:01 concise:01 syntax:02 syntax:02 harder:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 3 Jun 2004, Jean-Christophe Filliatre wrote: > > > >> Iif you want practical features of OCaml, you could try the classic > > >> "QuickSort in n lines" where n depends on how efficient you want to > > >> make it, but you can still achieve O(n log n) in something like 4 > > >> lines. It takes 10 or so to be efficient, compared to at least 50 in > > >> C. Of course, Haskell has even nicer syntax for this, but it looks > > >> good in O'Caml too. > > I don't think sorting is a good example of ocaml power w.r.t other > languages. If you are sorting arrays, an ocaml code and a C code won't > differ so much and I don't see why the C code would be 10 times longer > (the C syntax could even make it smaller). If you are sorting lists, I > agree that ocaml syntax and pattern matching would make the code much > concise than the C equivalent. I don't think any 10-line program shows off the real power of Ocaml. That's because Ocaml doesn't turn 100 line C programs into 10 line Ocaml programs, Ocaml turns 100,000 line C++ programs into 10,000 line Ocaml programs *that work correctly*. Large programs are different from small programs. An example of this. 100 line programs- in any language- are generally simple enough I can hold the entire program in my head. It's easy to spot bugs in 100 line programs. So a feature like immutable data structures doesn't help you in writting 100 line programs. In fact, it often hinders you. But when the two interacting peices of code are thousands, or tens of thousands, of lines apart, spotting the interaction is a lot harder. Now, all of a sudden, immutability is a major advantage. -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian ------------------- 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