Skip to content

OCaml 5.0.0 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Apr 20, 2023
Merged

OCaml 5.0.0 #6

merged 27 commits into from
Apr 20, 2023

Conversation

monadius
Copy link
Collaborator

This pull request updates OCaml to the latest version 5.0.0. Major changes from the previous version:

  1. Solution, preloaded and test files are not concatenated. Three separate files are required to run tests: solution.ml, tests.ml, preloaded.ml (preloaded.ml is optional if other modules do not import it). It is now necessary to import all modules explicitly. It is possible to preprocess old tests to update most katas automatically: If an existing test file starts with the line module Tests = struct, then it is enough to delete this line and the last line (something like end or end;;) and insert

    open Solution
    open Preloaded

    at the very beginning of tests.ml. It may also be necessary to insert open Preloaded to the solution file if preloaded.ml is not empty.

  2. Core is replaced with Base which is a lightweight version of Core.

  3. Num is replaced with Zarith (a recommended OCaml package for arbitrary precision arithmetic). Num is still installed as a dependency of Batteries so old katas which rely on Num should still work.

  4. A new package Domainslib is added to simplify parallel programming in OCaml 5.0.0 (the main feature of this major version of OCaml).

The updated OCaml version uses ocamlbuild to compile the project. It works well for simple projects with a few files. Later, we may replace ocamlbuild with dune (the modern OCaml build system) if any issues with ocamlbuild are discovered.

I also experimented with Alpine 3.17 (image size 565MB) and Ubuntu 22.04 (image size 645MB) images. The default image uses Alpine 3.17. But I observed that it may be slower than Ubuntu when arbitrary precision arithmetic is used in OCaml (see examples/zarith): 14.6 seconds vs 8.6 seconds for Ubuntu. I tested several existing katas which use Num and I did not observe any significant performance differences. So I think it is fine to use the Alpine image for now.

@monadius monadius changed the title Ocaml 5.0.0 OCaml 5.0.0 Apr 10, 2023
Copy link
Member

@kazk kazk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall.

Can you add .github/workflows/ci.yml like https://github.com/codewars/haskell/blob/main/.github/workflows/ci.yml to build the image and run some examples?

I also experimented with Alpine 3.17 (image size 565MB) and Ubuntu 22.04 (image size 645MB) images. The default image uses Alpine 3.17. But I observed that it may be slower than Ubuntu when arbitrary precision arithmetic is used in OCaml (see examples/zarith): 14.6 seconds vs 8.6 seconds for Ubuntu. I tested several existing katas which use Num and I did not observe any significant performance differences. So I think it is fine to use the Alpine image for now.

Is there a reason to use Alpine other than the size? It seems safer to use Ubuntu, and the size difference is negligible.

@monadius
Copy link
Collaborator Author

I am traveling right now. I'll return home on Monday and then I will add the requested git workflow file.

I chose Alpine because both Coq and Agda images use it. I agree that it is safer to use Ubuntu since it does not demonstrate any performance issues for big integers. I will change the default image to Ubuntu.

@monadius
Copy link
Collaborator Author

I added .github/workflows/ci.yml. I also changed the default image to Ubuntu.

@kazk
Copy link
Member

kazk commented Apr 19, 2023

Thanks! I'll merge this tomorrow.

@kazk kazk merged commit 8545abf into codewars:main Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants