-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 14 August 2008 09:28:34 am Peng Zang wrote:
> OCaml let's you write however you think about it.  Haskell makes you think
> about it in *the haskell* way.  Sometimes this is good because it forces
> you to do certain things.  Othertimes it just gets in your way.
>
>
> Peng


Haha, I have some free time.  So, let me explain more about why sometimes it's 
good that Haskell makes you do things in a certain way.

One is that Haskell forces your program into two parts.  Parts that contain 
side-effects (in monads) and the part that is pure.  This is great because 
the compiler can now do some optimizations not available when you don't know 
if your code is pure.  This is also good because side-effects can be 
confusing and difficult to maintain over time.  By putting all the side 
effects in a box, you can compartmentalize it away.  For lots of changes you 
only have to consider the pure stuff which is easier to think about (no 
worries about state, no worries about the right order of doing things, 
program in a declarative fashion).  The downside is you have to put all the 
side-effect stuff in a corner and box it off.  This can be a little odd 
because it may make you organize your code in a counterintuitive way.  Also 
it makes side-effect creep very obvious (when you realize "oops, that needs 
to be in a monad too... and that... and that ... crap").  You really have to 
sit down and think about the design before you do anything.  Haskell is 
definitely a first-on-paper, then-in-code type of language.  This can be good 
because for complex stuff you probably want to think about the design ahead 
of time anyways.  Haskell forces this discpline on you.  On the other hand, 
if you like to do rapid prototyping type of approach and live on the edge a 
bit, it can be a bummer.

A similar argument follows for lazy (non-strict) evaluation as well.  Allows 
some really cool stuff (eg. infinite lists) and optimizations (eg. 
deforestation).  But has significant overhead (eg. you have to make a thunk 
for everything, if you're going to evaluate it anyways, all that work to make 
the thunk is wasted) and it's hard to reason about speed and memory 
performance (eg. it looks like a tail recursive function that uses constant 
stack space but because the accumulator is thunked, you end up creating O(N) 
thunks).

Anyways, I think Haskell has some really cool ideas and I like it.  It 
definitely expands the mind.  But OCaml is my go-to-swiss-army-knife of 
languages.  It used to be C but that was too low level for me and library 
support was crap (this was before Boost).  Then it was Java but it was waay 
to verbose and you couldn't even return a tuple without creating a class for 
it first.  Then it was Lisp, but it's dynamically typed and I got tired of 
finding bugs from 3 years ago.  Now days it's OCaml.  Maybe one day it'll be 
something else, but in the mean time, I'm enjoying it.

Peng
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)

iD8DBQFIpDq+fIRcEFL/JewRAv3eAJ9L3W43Qfn2bFpLpUiyRt4Dn1dt6gCeNvew
8w6kCN5AKcGJH8WYzJPyKVM=
=6HsO
-----END PGP SIGNATURE-----

_______________________________________________
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

Reply via email to