On 01-04-2008, salog <[EMAIL PROTECTED]> wrote:
>
> I have encountered to this article about some OCaml experience:
>
> http://schani.wordpress.com/2007/07/23/why-ocaml-is-not-my-favorite-programming-language/
>
> The author gives an example of arithmetic calculations in OCAML and
> scares with weakness of the type-safe programming exceeding it's
> benefits.
>
> I doubt that the language developers planed using OCAML in this
> programming style.
> Probaly there is a problem in C- like author's thinking style but not
> in the language.
> At least I hope this.
>
> What's wrong in the article?
>

The article is quite funny... I think it miss most of the point in
OCaml:
* dealing with int32, int64, nativeint... is when you need the extre
 precision of 32 or 64 bit... 99% of the time you will deal with
 standard int of OCaml (which can be 31 or 63 bits) (not talking about
 big_int which is even more specific)
* bigarray and array are the same problem (i.e. using bigarray should be
 done on purpose: mmap, interfacing with C or fortran)
* i don't think having the choice is a problem (i.e. having int32 and
 int, bigarray and array)
* going back to lisp is not always the solution (this is a good
 language, but i won't switch back to it -- for many other reason)

Another point concerning example: author just take it the wrong way!

He should have used functor a little bit more

module type E =
sig
  type t
  val of_int: int -> t
  val add: t -> t -> t
end
;;

module Add3 (Elem: E) = 
struct
  type t = E.t

  let n3 =
    E.of_int 3

  let add3 z = 
    E.add z n3
end
;;

module Add3Nativeint = Add3(Nativeint)
;;

module Add3Int64 = Add3(Int64)
;;

module Add3Int32 = Add3(Int32)
;;

(quick and dirty example -- probably doesn't compile)

Off course, for just 1 operation this a little overkilling -- but it is
more in the spirit of OCaml IMHO.

FYI, this also far more efficient than the LISP equivalent, since no
dynamic typing will be involved, the code produced won't do any type
check before every operation -- this can save a lot of time at runtime.

Regards,
Sylvain Le Gall


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ocaml-developer" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/ocaml-developer?hl=en
For other OCaml forums, see http://caml.inria.fr/resources/forums.en.html
-~----------~----~----~----~------~----~------~--~---

Reply via email to