On 02-04-2008, Jon Harrop <[EMAIL PROTECTED]> wrote:
>
> On Wednesday 02 April 2008 10:59:24 Sylvain Le Gall wrote:
>> On 02-04-2008, salog <[EMAIL PROTECTED]> wrote:
>
>> Don't be mislead... Parametrized class (like the List<XXX>) in C++ (and
>> maybe in C#) are "text replacement". These are piece of crap and one of
>> the reason i stop coding using C++. In particular, it requires to
>> compile every time the same code (with some string replaced).
>
> You are talking about C++ templates, which are completely different. Salog 
> was 
> referring to .NET generics which are equivalent to parametric polymorphism in 
> OCaml. Indeed, .NET generics were done by the creator of F#, Don Syme.
>

Indeed that is why i said "maybe C#". I don't know a lot of .NET
(appears after i migrate to Linux...)

>> Module and functor in OCaml are not perfect but are far better than
>> this (BTW, this kind of thing is a direct legacy of the famous COBOL
>> "COPY ... REPLACING ..." -- C++ is somehow lagging 30 years behind OCaml).
>
> I think this is a bit unfair. Functors in OCaml incur a crippling performance 
> penalty here because OCaml does not inline functions across functor 
> boundaries. You're looking at an order of magnitude slowdown on integer 
> addition!

I am not sure of this... I think this penalty can be removed by
providing .cmxa and .cmx files (but i am not sure). I think this point
should need a little more attention to be sure. Frankly, i would like to
test this before saying that there is an 'order of magnitude'.

>
> This makes the ability to factor primitive numeric types using functors 
> practically useless in OCaml. The effect is compounded by OCaml's inability 
> to handle many numeric types either not at all (e.g. int16, float32) or just 
> very inefficiently (e.g. int8, int32, int64). Finally, you could use 
> functional abstraction to achieve the same effect but this is also 
> practically useless in OCaml because it does not support arbitrary inlining 
> which is, ironically, exactly what you were saying. :-)

Need to check this also ;-) (i was not under this impression, but i can
do mistake).

>
> C++ is no better, of course. But F# really does provide the best of both 
> worlds with a variety of features:
>
> . A wealth of built-in types including int8, int16, int32, int64 and float32 
> that are efficient.
>
> . Typeful inlining of functions including higher-order functions to remove 
> all 
> costs associated with passing function arguments (which is slow in OCaml) 
> without the hideous obfuscation of error messages impose by C++ templates.
>
> . Type specialization during JIT compilation, removing the run-time cost 
> associated with polymorphism (which is slow in OCaml).

Are you talking about polymorphic variant? I am not sure you can find
real polymorphism at runtime anywhere else.

>
> We have some of the world's largest OCaml and F# codebases having migrated 
> from C++. I agree completely that OCaml is far better than C++ in practice 
> for any non-trivial work. However, OCaml does leave room for improvement and, 
> to date, the only competitive language is F# not least because it provides 
> many of the features touched upon in this thread but without sacrificing the 
> core features of OCaml.
>

Indeed, but F# has its own boundary (which we will discover in the
future).

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