ocaml / v2.ocaml.org

Implementation of the ocaml.org website.
http://ocaml.org
Other
323 stars 351 forks source link

Functional Programming tutorial claims all basic OCaml types are unboxed. #1611

Open ninjaaron opened 2 years ago

ninjaaron commented 2 years ago

In C or C++ you should have no problems constructing either of the two types of arrays above. In Java, you have two types, int which is unboxed and Integer which is boxed, and hence considerably less efficient. In OCaml, the basic types are all unboxed.

I'm not sure what is meant by "basic types" here, but this is extremely misleading, since, as far as I know, int is the only common unboxed type in OCaml and even float is normally boxed. It would be good if this was reworded to reflect the fact that almost every non-integer value in OCaml is boxed, and this is indeed a pain-point for OCaml in HPC.

patricoferris commented 2 years ago

Hi @ninjaaron thanks for the feedback.

I completely agree, the phrase basic types is ambiguous (at least in this tutorial's context) and most I assume would be thinking of "basic data types" in the manual (see https://ocaml.org/releases/4.12/htmlman/coreexamples.html#s:datatypes), where using that definition this statement is indeed incorrect. Perhaps it would be better with a small explanation and then a link to https://ocaml.org/releases/4.12/htmlman/intfc.html#s:c-ocaml-datatype-repr ?

This is the second time in not so long that this tutorial seems to be incorrect/misleading (see https://github.com/ocaml/ocaml.org/pull/1595) and I agree with @Octachron that overall the tone of the tutorial is not great. I'm wondering if it is causing more harm than good at this point?

Octachron commented 2 years ago

Overall, I think that all tutorials would need to be edited. Another piece from the label tutorial:

When and when not to use ~ and ?

The syntax for labels and optional arguments is confusing, and you may often wonder when to use ~foo, when to use ?foo and when to use plain foo. It's something of a black art which takes practice to get right.

I cannot disagree more with the use of black art to try to instill a false sense of familiarity with the reader, at the price of sending a terrible and inaccurate message.