Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Teaching OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] Teaching OCaml
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