I know roughly how F# and OCaml differ in terms of "features" (e.g. functors, camlp4, units of measure...).
I wonder about the following: Concerning code that doesn't contain said features, is there a difference in coding style (other than say naming conventions) between F# and OCaml? To put it another way, if some (idiomatic) F# code can be translated in a straight forward way (maybe trivially) to OCaml, will this transformation necessarily lead to idiomatic Ocaml?
Edit: From the links provided by Guy Coder I guess that some "idiomatic" OCaml code might not directly translate to "idiomatic" F# code due to the fact that exceptions are much slower in F# (and more widely used in OCaml). What about the other direction? Will some F#ish OCaml code ever provoke a reaction in terms of "Don't do XX that way, the OCaml way to do XX is with exceptions instead of XY.."
Generally, what are the differences in using exceptions in OCaml when compared to the typical usage in F#. Are there other constructs that are differently used in the two languages (e.g. because of performance penalties in one language)?
When you have found the F value, you can compare it with an f critical value in the table. If your observed value of F is larger than the value in the F table, then you can reject the null hypothesis with 95 percent confidence that the variance between your two populations isn't due to random chance.
An F-test is any statistical test in which the test statistic has an F-distribution under the null hypothesis. It is most often used when comparing statistical models that have been fitted to a data set, in order to identify the model that best fits the population from which the data were sampled.
If both models have the same number of parameters, the formula for the F statistic is F=SS1/SS2, where SS1 is the residual sum of squares for the first model and SS2 is the residual sum of squares for the second model.
The F value is a value on the F distribution. Various statistical tests generate an F value. The value can be used to determine whether the test is statistically significant. The F value is used in analysis of variance (ANOVA). It is calculated by dividing two mean squares.
Yes the translation will be considered idiomatic by many OCaml users for the most part. Since idiomatic is not an exact standard there is no way to measure how idiomatic.
The caveat is that you will have to modify some of the code to make use of features in one language that are not in the other. In particular if a functor is the idiomatic way to do it in OCaml, then you would have to convert the F# code to a Functor. Or if F# made extensive use of the .Net library code, then you would have to recreate those functions in OCaml or find an equivalent.
I have translated my share of ML and OCaml to F# and as you note, and what I refer to as the environment and ethos are what are really the big differences, e.g. functors, camlp4, units of measure, Visual Studio, time travel, NUnit, WPF, etc.
Remember that F# started as OCaml when being ported so for the most part there is still a lot in common.
If you want to see some significant amount of code done in OCaml and F# translated almost line for line take a look at the code for "Handbook of Practical Logic and Automated Reasoning" by John Harrison
F#
OCaml
Then you can judge for yourself.
I do have to note that the code for "Handbook of Practical Logic and Automated Reasoning" does not make use of classes, records, events, and the like. It is almost purely functions.
Another way to compare any two languages in general for idomaticness (OK so I coined that word) is to use Rosetta Code. Rosetta Code contains solutions to programming task written in many languages. So find a programming task, e.g. create a class and then look at the OCaml and F# versions.
Not all of the task are done in all of the languages, but any one can contribute or even suggest new task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With