OCaml Weekly News
Hello
Here is the latest OCaml Weekly News, for the week of November 28 to December 05, 2023.
Table of Contents
- Highlexer
- Video Tutorial: How to Install OCaml on Linux and macOS!
- Eio TUI chat server and client demo
- dune.3.12.1
- OCaml Platform Newsletter: October 2023
- Advent of Code project template
- opam-health-check-ng 0.1.0: check the health of an opam repository on your home machine
- First release candidate of OCaml 5.1.1
- Compositional Automated Verification for OCaml
- OCaml and OPAM awarded The Open Science Award for Free and Open-Source Research Softwares
- ICFP 2023 OCaml Presentations on YouTube
- geojson and geojsone
- Rethinking abstract module types - feedback wanted
- TSan support in OCaml 5.1 and blog post
- Hilite 0.3.0
- You Can Attend the New OCaml.org Community Meetings
- A December update from the ocaml-wasm organisation
- Other OCaml News
- Old CWN
Highlexer
Emile Trotignon announced
I please to announce the first release of highlexer. It is a small library that allows you to highlight ocaml code snippets using a modified version of the ocaml lexer.
It was designed to work well in the browser with js_of_ocaml, but it does not have to, you can use it to color html in the backend or even probably latex.
Video Tutorial: How to Install OCaml on Linux and macOS!
Isabella Leandersson announced
Hello everyone!
I’m part of a group at Tarides that is focusing on creating video tutorials for OCaml. Since everyone learns differently – I myself use videos a lot when learning a new skill or concept – we want to provide different mediums through which people can learn OCaml.
This is our first video and there’s definitely room for improvement! Please let us know what could be better, and if you have any ideas for what we should cover next please share them with us! :D
Eio TUI chat server and client demo
Darren announced
Hello everyone,
I’m sharing a small demo of using Eio and Nottui (and Notty) to implement chat server + client.
The technical details are available in the README of the repo.
Server:
Client:
dune.3.12.1
Etienne Millon announced
The Dune team is pleased to announce the release of Dune 3.12.
Note that due to a mistake during the release process, version 3.12.0
was not published to opam and should not be used. So here’s the changelog for
3.12.1
.
Added
- Introduce
$ dune ocaml doc
to open and browse documentation. (#7262, fixes #6831, @EmileTrotignon) dune cache trim
now accepts binary byte units:KiB
,MiB
, etc. (#8618, @Alizter)- Introduce the
runtest_alias
field to thecram
stanza. This allows removing defaultruntest
alias from tests. (@rgrinberg, #8887) - Display cache location in Dune log (#8974, @nojb)
- Dune can now be built and installed on Haiku (#8795, fix #8551, @Alizter)
- Mark installed directories in
dune-package
files. This fixes(package)
dependencies against packages that contain such directories. (#8953, fixes #8915, @emillon) - Introduce new experimental odoc rules (#8803, @jonjudlam)
Changed
- dune-build-info: when
version=""
is found in aMETA
file, we now returnNone
as a version string (#9177, @emillon) - No longer force colors for OCaml 4.03 and 4.04 (#8778, @rgrinberg)
- Dependencies in the copying sandbox are now writeable (#8920, @rgrinberg)
- Rules that only use internal dune actions (
write-file
,echo
, etc.) can now be sandboxed. (#9041, fixes #8854, @rgrinberg) - Add
test_
prefix to default test name indune init project
(#9257, fixes #9131, @9sako6)
Fixed
- Do not ignore libraries named
bigarray
when they are defined in conjunction with OCaml 5.0 (#8902, fixes #8901, @rgrinberg) - Correctly ignore
bigarray
on recent versions of OCaml (#9076, @rgrinberg) - Absent packages shouldn’t prevent all rules from being loaded (#8948, fixes #8630, @rgrinberg)
- Correctly determine the stanza of menhir modules when
(include_subdirs qualified)
is enabled (@rgrinberg, #8949, fixes #7610) - Re-run actions whenever
(expand_aliases_in_sandbox)
changes (#8990, @rgrinberg) - Do not re-run rules when their location changes (#9052, @rgrinberg)
- [coq rules] Be more tolerant when coqc –print-version / –config don’t work properly, and fallback to a reasonable default. This fixes problems when building Coq projects with
(stdlib no)
and likely other cases. (#8966, fix #8958, @Alizter, reported by Lasse Blaauwbroek) - Dune will now run at a lower framerate of 15 fps rather than 60 when
INSIDE_EMACS
. (#8812, @Alizter)
OCaml Platform Newsletter: October 2023
Thibaut Mattio announced
Welcome to the seventh edition of the OCaml Platform newsletter!
In this October edition, we bring you the latest on the OCaml Platform, continuing our tradition of highlighting recent developments as seen in previous editions. To understand the direction we’re headed, especially regarding development workflows and user experience improvements, check out our roadmap.
Highlights:
- The three-year roadmap for the OCaml Platform has been adopted! We’re thrilled to have a community-driven roadmap for the improvement of OCaml developer experience, and we’re very grateful for all the excellent feedback we received from the community. Have a look at the announcement.
- After giving space for feedback and objections by the community, we have deprecated ocaml-migrate-parsetree (aka OMP). It is superseded by Ppxlib.
- We’re introducing a new format for our newsletter. Let us know your thoughts and how we can make it even better for you!
Releases:
[Dune] Exploring Package Management in Dune
(W4)
Contributed by: @rgrinberg (Tarides), @Leonidas-from-XIV (Tarides), @gridbugs (Tarides), @kit-ty-kate (Tarides), @Alizter
Why: Unify OCaml tooling under a single command line for all development workflows. This addresses one of the most important pain points reported by the community.
What: Prototyping the integration of package management into Dune by using opam as a library. We’re adding a new
dune pkg lock
command to generate a lock file and extend dune build
to support downloading and building dependencies specified in the lock file. Read the
Dune RFC for more details.
Activities:
- We reworked the storage for opam repositories. We now have support for multiple repositories, which we store and update in an efficient manner. – ocaml/dune#8950
- We introduced the
$ dune pkg outdated
command to view all the outdated packages in a lock directory. – ocaml/dune#8773 - We introduced
$ dune describe pkg lock
to print lock directories. This gives users a nice overview of what’s available in the lock directory’s build plan. – ocaml/dune#8841 - We added support for solver variables in
lockdir
to make sure opam variables are also available at build and install time – ocaml/dune#8973 - We managed to successfully generate a lock file for
cmdliner
on Windows! :windows: Next, we’re working on making build work on Windows as well. – ocaml/dune#9048 - And as usual, we fixed a bunch of bugs that prevented your regular packages from building:
- Require copying sandbox for build rules – ocaml/dune#8923
- Respect [flags] field in opam packages – ocaml/dune#9047
- Improve invalid substitute error – ocaml/dune#8922
- Correctly verify tarball checksums – ocaml/dune#8876
- Improve locations of conversion errors – ocaml/dune#8828
- Remove post deps – ocaml/dune#8834
- Move solver env printing to own command – ocaml/dune#8819
- Record installed directories in
dune-package
– ocaml/dune#8953
[opam] Native Support for Windows in opam 2.2
(W5)
Contributed by: @rjbou (OCamlPro), @kit-ty-kate (Tarides), @dra27 (Tarides), @AltGr (OCamlPro)
Why: Opam and opam-repository
currently don’t support Windows natively. This effectively makes OCaml a very niche candidate on Windows, as users either have to (1) not use a package manager or (2) use a fork of opam and the
opam-repository
. Making opam and the opam-repository
compatible with Windows will make OCaml a better choice for Windows users and help us grow the community. More Windows users able to use opam leads to more contributors, more testing,
more Windows friendly packages, and more packages in the end.
What: Releasing opam 2.2 with native support for Windows and making the official
opam-repository
usable on Windows.
Activities:
- Essentially focused on
setenv
&build-env
environment variables update handling on Windows - ocaml/opam#5636
[odoc
] Add Search Capabilities to
odoc
(W25)
Contributed by: @panglesd (Tarides), @EmileTrotignon (Tarides), @julow (Tarides), @jonludlam (Tarides)
Why: The in-package search added in OCaml.org’s central package documentation has been very well received by the community and improves how users navigate and discover OCaml documentation. We’re upstreaming it to
odoc
to bring it into the local documentation as well and provide more advanced features, like searching by type.
What: We’re adding support in odoc
for pluging in a search engine!
odoc
provides the UI (a search bar) and will generate a search index (that can also be used to be integrated into other search engine like Elasticsearch). We’re also building a default client-side search engine based on Sherlodoc.
Activities:
- We’ve merged the PR adding new search capabilities! :tada: This will ship in the upcoming version of
odoc
2.4.0. - We are currently experimenting with building an
odoc
search engine based on Sherlodoc --art-w/sherlodoc#4.
[odoc
] Syntax for Images and Assets in
odoc
(W25)
Contributed by: @panglesd (Tarides), @jonludlam (Tarides), @dbuenzli, @gpetiot (Tarides)
Why: Allow package authors to write rich documentation, making it more useful and improving OCaml developer experience by providing an ecosystem of high-quality documentation for OCaml packages.
What: We’re adding support for assets and new syntax to embed medias (images, audio, and videos).
Activities:
- We’ve decided to rework the asset support design a little to bring it more in line with how other elements are handled, such as modules, types, and values. The intent is to ensure the code is straightforward to maintain in the long term. – ocaml/odoc#1002
- We continued reviewing the PR, adding syntactic support for media. There were some good discussions relating to missing assets, and it’s ready to go in once the assets PR is merged. – ocaml/odoc#1005
[Dune] Generate Dependencies Documentation with Dune
(W25)
Contributed by: @jonludlam (Tarides)
Why: Make locally-generated documentation more useful by allowing users to navigate to their dependencies’ documentation from their package docs. Currently users can use
odig
, which provides a similar workflow. We’re adding support for this in Dune directly.
What: We’re writing new Dune rules for odoc
that (1) use the new
odoc
CLI to enable performance improvement and caching opportunities and (2) generate the documentation of every opam packages in your switch, allowing users to navigate to their dependencies’ documentation from their local docs.
Activities:
- The new Dune rules have been reworked a little following feedback from @alizter and @rgrinberg, improving the following areas: better support for multiple
findlib
directories; better support for system switches; and a more robust method for translating fromfindlib
paths to local paths. – ocaml/dune#8803
[Merlin] Support for Project-Wide References in Merlin
(W19)
Contributed by: @voodoos (Tarides), @trefis (Tarides), @Ekdohibs (OCamlPro), @gasche (INRIA)
Why: Project-wide reference as an editor feature is a great way for developers to navigate their codebase and understand it better. It’s also a feature that users expect to have coming from other ecosystems, so having support for it in Merlin and OCaml LSP will both improve OCaml editor experience and make it on par with other languages.
What: We’re adding a new merlin single occurrences
command and support for the LSP
textDocument/references
request. To do that, we’re extending the compiler’s Shapes to support global occurences, building a tool that generates an index of identifiers in a codebase and adding support for it in Dune, Merlin, and OCaml LSP.
Activities:
- We continued working on the compiler PR for project-wide occurrences, notably adding support for inline records’ labels. The PR is now ready for the next round of reviews. – ocaml/ocaml#12508
- Concurrently, we continued working on the tools involved in providing occurrences. We are still on track for releasing an experimental 4.14-based variant of the compiler to gather feedback on the feature before the end of the year. Our current aim is to provide official project-wide occurrences support in OCaml 5.2. – voodoos/merlin#8, voodoos/ocaml-lsp#2, voodoos/dune#2, ocaml-index#5
[Merlin] Improving Merlin’s Performance (W19)
Contributed by: @pitag (Tarides), @Engil (Tarides), @3Rafal (Tarides)
Why: Some Merlin queries have been shown to scale poorly in large codebases, making the editor experience subpar, with users reporting that they sometime must wait for a few seconds to get the answer for Merlin. This is obviously a major issue that hurts developer experience, so we’re working on improving Merlin performance when it falls short.
What: We’re building benchmarking and fuzzy-testing CIs to continuously benchmark and test Merlin. We’re addressing the performance bottlenecks identified from profiling Merlin and analysing benchmarking results.
Activities:
- We’ve continued our work on a fuzzy-testing CI for Merlin. Our first approach was to persist the testing data in sync with the Merlin commit history. However, that implied dealing with all kinds of data races when comparing the data between a PR and its base branch, when generating and persisting new data, and when approving changes. To avoid that, in October we experimented with a simpler approach that regenerates the data for every CI run - without compromising on CI run time. The new approach seems promising.
- We’ve also come back to work on Merlin performance improvements. We plan to
optimise Merlin’s space-time trade-off by experimenting (on an opt-in basis) with different lifetimes for the
cmi-cache
andcmt-cache
. For that, we’re adding information about Merlin’s memory usage to its telemetry. Furthermore, we’ve looked into refining the typer cache granularity and have analysed its challenges.
Advent of Code project template
Trent Small announced
Hey everyone!
I recently published a starter project for working on Advent of Code puzzles in OCaml: https://github.com/Sixstring982/tanenbaum
It works for all “years” (and should work for 2023, assuming no API changes will be made tonight), and has some other nice features:
- Automatic downloading + caching of puzzle inputs
- CLI for running puzzles + submitting answers to
adventofcode.com
- Automatic puzzle detection + registration
Hope some folks find this useful – I’ve been using it a lot myself!
opam-health-check-ng 0.1.0: check the health of an opam repository on your home machine
Kate announced
Hi everyone,
I’m happy to announce the first release of opam-health-check-ng that I’ve been developing the past 2 months.
opam-health-check-ng is a fork of opam-health-check (available at check.ci.ocaml.org) of which I’m also the author of and was its main user for the past 6 years. It fundamentally differs from its parent mainly by targeting small home servers using:
- an off-the-shelf Docker installation
- tightly controlled network access (e.g. you don’t want to have your home internet stop to a crawl at an unexpected time while you’re watching a video)
- a tightly controlled load making it easier to benchmark whole runs and have stable temperature, which also makes sure your hardware lasts as long as possible
My main goal was for it to be easier to maintain and deploy when I’m working for the OCaml Software Foundation on making sure the OCaml Software Ecosystem (aka. packages in opam-repository) is ready before each release of the OCaml compiler, as well as making sure the compiler itself doesn’t have any problem.
Incidentally, having a server at home, especially in colder countries like Scotland, makes it so that you’re not wasting any energy trying to get rid of heat from a server room. Instead it now serves as your own personal electric space heater that you can carry to rooms that need it, making the whole process a little bit greener overall.
If you’re in the unlikely case, where, like me you need to test an entire opam repository on a daily basis, you’re welcome to install opam-health-check-ng 0.1.0 using:
opam pin add git+https://github.com/kit-ty-kate/opam-health-check-ng#v0.1.0
You can read on the prerequisites and usage in the associated README.
Disclaimer: I’m not claiming this release to be stable or secure, if you do use it, use it at your own risk. If you have any questions, feel free to ask here or on the bugtracker.
I’d like to thank the OCaml Software Foundation for founding my work and this release.
First release candidate of OCaml 5.1.1
octachron announced
Two months (and half) after the release of OCaml 5.1.0, we have discovered three significant regressions in OCaml 5.1.0, affecting the packaging of executables, the typechecking of OCaml programs, and the performance of numerical codes.
Since those regressions affect many users and could have lasting effects, we have decided to cut a patch release of OCaml 5.1 with fixes for those issues next week.
To give time for opam packages to test this patch version, we have just published a first release candidate for OCaml 5.1.1 . The full list of changes in this release candidate is available below.
As a major exception to our policy for patch releases, OCaml 5.1.1 will contain one breaking change in the standard library: the
Compression
flag has been removed from the Marshal
module. This drastic measure was taken because supporting zstd compression in the standard library made zstd a dependency of all OCaml executables. Since the compiler should not impose
its dependency on end-users, the support for compressed marshaling has been moved to a compiler internal library in 5.1.1. This internally library might be released as an independent library in later releases of OCaml but not in OCaml 5.1.1 to give us time
to polish the library integration and packaging.
Installation Instructions
The base compiler can be installed as an opam switch with the following commands on opam 2.1 and later:
opam update opam switch create 5.1.1~rc1
The source code for the release candidate is also directly available on:
- GitHub: https://github.com/ocaml/ocaml/archive/5.1.1-rc1.tar.gz
- OCaml archives at Inria: https://caml.inria.fr/pub/distrib/ocaml-5.1/ocaml-5.1.1~rc1.tar.gz
- Fine-Tuned Compiler Configuration
If you want to tweak the configuration of the compiler, you can switch to the option variant with:
opam update opam switch create <switch_name> ocaml-variants.5.1.1~rc1+options <option_list>
where
option_list
is a space-separated list ofocaml-option-*
packages. For instance, for aflambda
andno-flat-float-array
switch:opam switch create 5.1.1~rc1+flambda+nffa ocaml-variants.5.1.1~rc1+options ocaml-option-flambda ocaml-option-no-flat-float-array
All available options can be listed with
opam search ocaml-option
.
Changes in OCaml 5.1.1
- Standard Library Dependency Fix:
- (breaking change)
#12562, #12734,
#12783: Remove the
Marshal.Compression
flag to theMarshal.to_*
functions introduced in 5.1 by #12006, as it cannot be implemented without risking to link -lzstd with all ocamlopt-generated executables. The compilers are still able to use ZSTD compression for compilation artefacts. (Xavier Leroy and David Allsopp, report by Kate Deplaix, review by Nicolás Ojeda Bär, Kate Deplaix, and Damien Doligez).
- (breaking change)
#12562, #12734,
#12783: Remove the
- Type System Bug Fix:
- #12623, fix the computation of variance composition (Florian Angeletti, report by Vesa Karvonen, review by Gabriel Scherer)
- GC Performance Regression Fixes
- #12590,
#12595: Move
caml_collect_gc_stats_sample
incaml_empty_minor_heap_promote
before barrier arrival. (B. Szilvasy, review by Gabriel Scherer) - #12318: GC: simplify the meaning of custom_minor_max_size: blocks with out-of-heap memory above this limit are now allocated directly in the major heap. (Damien Doligez, report by Stephen Dolan, review by Gabriel Scherer)
- #12439: Finalize and collect dead custom blocks during minor collection (Damien Doligez, review by Xavier Leroy, Gabriel Scherer and KC Sivaramakrishnan)
- #12491, #12493, #12500, #12754: Do not change GC pace when creating sub-arrays of bigarrays (Xavier Leroy, report by Ido Yariv, analysis by Gabriel Scherer)
- #12590,
#12595: Move
- Miscellaneous Bug Fixes
- #12581, #12609: Fix error on uses of packed modules outside their pack to correctly handle nested packs (Vincent Laviron, report by Javier Chávarri, review by Pierre Chambart)
- #12757: Fix ocamlnat (native toplevel) by registering frametables correctly (Stephen Dolan, Nick Barnes and Mark Shinwell, review by Vincent Laviron and Sébastien Hinderer)
- #12645,
#12649 fix error messages for cyclic type definitions in presence of the
-short-paths
flag. (Florian Angeletti, report by Vesa Karvonen, review by Gabriel Scherer)
Compositional Automated Verification for OCaml
Gabriel Radanne announced
This is an announcement for a postdoctoral position in the CAVOC project (Compositional Automated Verification for OCaml Code). The post-doc will take place in Nantes, France. It will be co-supervised by Guilhem Jaber (Nantes Université and Inria Gallinette team) and Gabriel Radanne (Inria CASH team). It aims to bring together approaches from abstract interpretation, model checking, and game semantics to statically analyze OCaml code.
The successful candidate will be employed by Inria and work in the Gallinette team (https://gallinette.inria.fr), at Nantes University. The position is for one year, and should start in the first semester of 2024 (to be negociated). The salary will depend on the successful candidate’s prior research experience with a guaranteed minimum of ~2200€/month after taxes. The working language can either be English or French.
We seek candidates holding a PhD in Computer Science or Mathematics, and with expertise in programming language semantics, λ-calculi, type theory, functional programming, abstract interpretation, compilation, model checking, or program logic.
Profile
The candidate should be familiar with formal approaches in programming language design, notably type systems, semantics, and logic. More concretely, knowledge of the OCaml programming language is expected, and a knowledge of abstract interpretation or model checking would be highly appreciated.
This postdoc strongly relies on the fact that practical implementation should have strong theoretical foundations and that further refinements of the theory should get inspiration from the practical side.
Application process
- Applications will be processed starting the 18th of December. Late applications will be considered until the position is filled.
- You do not need to have defended your PhD thesis to apply, but you will need to have obtained your PhD to start the contract.
- Candidates can send their application to Guilhem Jaber (guilhem dot jaber at inria dot fr) and Gabriel Radanne (gabriel dot radanne at inria do fr) with a subject containing “[CAVOC post-doc application]“.
- The application should contain a CV, two selected publications and two contacts of reference persons (or reference letters if available).
Context
The CAVOC project aims to develop a sound and precise static analyzer for OCaml, that can catch large classes of bugs represented by uncaught exceptions. The analyzer reasons compositionally on programs, in order to analyze them at the granularity of a function or of a module. It takes into account the abstraction properties provided by the type system and the module system of the language: local values, abstracted definitions of types, parametric polymorphism.
The main goal is to be sound in a strong way: if an OCaml module is considered to be correct by the analyzer, then one will have the guarantee that no OCaml code interacting with this module can trigger uncaught exceptions coming from the code of this module.
To model the behaviour of a module, we rely on game semantics, where programs formed by a module and a client of the module are modeled as calls-and-returns interactions. A module is then represented as a transition system that generates traces representing the interaction with any possible client. This transition system is directly generated from the module’s code (implementation and signature), using an operational semantics. We have implemented such an interactive semantics for a large fragment of OCaml, which we are using to develop our prototype analyzer.
OCaml and OPAM awarded The Open Science Award for Free and Open-Source Research Softwares
OCamlPro announced
Greetings to all our fellow Cameleers!
In case you missed it: two days ago, the OCaml Community, specifically, was commended by the Ministère de l’Enseignement Supérieur et de la Recherche (French Ministry of Higher Education and Research) in the context of their annual Prix Science Ouverte du Logiciel Libre de la Recherche (The Open Science Awards of Free and Open-Source Research Software).
Let’s appreciate this moment for what it is: an acknowledgement of the gargantuan amounts of work that have been poured into OCaml for the past 27 years, and an opportunity for celebration and praise! We are so proud and happy to be part of this strong and dynamic community!
OCaml is a functional programming language that embeds imperative and object-oriented constructs. Its design is centred around strong static typing, automatic type inference, and program modularity. Its applications span from the high-end academic research to various industrial domains. Among other things, OCaml is comprised of two compilers and an execution environment. It evolves inside a vast ecosystem centred around the package manager
opam
. The language has maintained its course since 1996 while maintaining the perenniality of the programs running on it.
ICFP 2023 OCaml Presentations on YouTube
jbeckford announced
The individual presentations of the ICFP 2023 OCaml track are available¹ at: https://www.youtube.com/playlist?list=PLyrlk8Xaylp7Tq5-ZN6jkir-sYrhGi_0E
Bios and papers are listed in the ICFP 2023 program schedule: https://icfp23.sigplan.org/home/ocaml-2023#program.
Thanks to all the presenters and participants who made this event happen!
– ICFP 2023 OCaml Chairs
[¹] Only the presentations that gave permission to be recorded.
geojson and geojsone
Patrick Ferris announced
Recently, a version 0.2.0
was released of Geojson
and
Geojsone
– the biggest change was to remove the explicit dependency on Eio from the core library and place it into a subpackage
geojsone.eio
. The
README has some documentation on this change.
Happy Geospatial Hacking :world_map: :camel:
Rethinking abstract module types - feedback wanted
Clément Blaudeau announced
I’ve written a blog post on abstract module types (module type T
without a definition), available
on the gagalium blog. The post sums up how abstract module types can be used, what are the current issues and proposes a restriction/simplification of their semantics. The goal
is to eventually update the typechecker with this simplified semantics.
Yet, as it is a restriction, it might break backwards compatibility. Therefore, the key question I’m trying to answer is whether or not the simplification I’m proposing is actually backwards compatible, because no one uses abstract module types outside of the setting I’m proposing.
I welcome any feedback from the both the pedagogical part or the proposed restriction (to simple-signatures-only instantiation), especially if you’re an user or potential user of abstract module types!
TSan support in OCaml 5.1 and blog post
Olivier Nicole announced
The video of our talk about ThreadSanitizer at the OCaml Workshop 2023 is now available.
Hilite 0.3.0
Patrick Ferris announced
The not too distant future is here!
Hilite 0.4.0
now uses Cmarkit
instead of Omd
for the underlying Markdown library. This is in very large part thanks to
Outreachy contributions to ocaml.org!
You Can Attend the New OCaml.org Community Meetings
Sabine Schmaltz announced
The meeting time for future ocaml.org dev meetings has changed to 17:00-18:00 CET.
Dec 11 agenda:
- Open issues for contributors
- Q&A
You can propose topics for the agenda.
A December update from the ocaml-wasm organisation
Jan Midtgaard announced
December is upon us and so it is time for an update since our last
ocaml-wasm
organisation September update.
Introduction
Earlier this year we formed the
ocaml-wasm
organisation to join efforts between two
WebAssembly (Wasm) targeting compiler projects for OCaml:
wasocaml
– a prototype backend for OCaml’s native code compiler based on the Flambda-intermediate representationwasm_of_ocaml
– a fork ofjs_of_ocaml
that translates OCaml bytecode to Wasm instead of JavaScript
Exciting news: The WebAssembly Garbage Collection (WasmGC) extension which both
wasocaml
and wasm_of_ocaml
depend on is now enabled by default in the latest:
wasm_of_ocaml
wasm_of_ocaml
currently requires the following
Wasm extensions:
- The GC extension, including functional references and 31-bit integers
- The tail-call extension
- The exception handling extension
As you may have inferred, with the latest release Chrome 119 can now run the output of
wasm_of_ocaml
out of the box!
For Firefox 120, one needs to enable the Wasm tail call extension first, but this will be remedied in the forthcoming 121 release.
OCaml 5.x code using effect handlers can be compiled in two different ways: one can either enable the CPS transformation from
js_of_ocaml
or emit code requiring the
JavaScript-Promise Integration extension.
Previously, wasm_of_ocaml
also required the
experimental stringref
proposal to convert strings between OCaml and JavaScript. The
stringref
proposal may however be superseeded by the newer
JS-string-builtins proposal, which is being implemented in both Chrome and Firefox. With the JavaScript string situation up in the air, for now
wasm_of_ocaml
instead uses the TextEncoder~/~TextDecoder
API on the JavaScript side to convert JavaScript to or from UTF-8 by writing strings to or reading them from a buffer in Wasm linear memory as an intermediate state.
Since September @vouillon has continued extending and improving wasm_of_ocaml
:
- Implemented unboxed
float
arrays - Small runtime improvements:
- Accurate fused multiply–add
- Improved handling of uncaught exceptions
- Improved the generated code by reducing the number of casts
- Optimised the JavaScript interface:
- Run CI tests after each push:
- Updated
Eliom
to work withwasm_of_ocaml
as a stress test. This included:- Finding and fixing a number of small bugs in
wasm_of_ocaml
’s runtime - Implementing a few missing features in the runtime, like
Json.output
andJs.export
- Fixed a performance issue with toplevel loops:- Our loops included all the code that follows, and the V8 engine used jump offsets to estimate the cost of a loop. So, it could widely overestimate the cost of loops at toplevel and produce optimised top-level code which is run only once. Since this code can be very large, this could take several minutes. Now, the code which is not involved in a loop is moved after the loop if it exceeds a size threshold.
- Finding and fixing a number of small bugs in
In addition, @vouillon also contributed with a couple of broader Wasm community improvements:
- Making
binaryen
more effective at cancelling out a boxing followed by an unboxing: WebAssembly/binaryen#5952 and - Improved the performance of Wasm exceptions in V8, the JavaScript / Wasm engine used by Chrome. After a number of optimisations, like using a cache to find which Wasm code correponds to a code pointer, they are about a order of magnitude faster. As a consequence the Boyer benchmark runs about 5 time faster.
Finally, he prepared and gave two presentations about wasm_of_ocaml
:
- A general
wasm_of_ocaml
talk at the WebAssembly Community Group meeting on October 12. In particular, he presented a number of performance measurements. - A talk on implementing OCaml effect handlers in Wasm at the WebAssembly’s Stack Subgroup
Other OCaml News
From the ocaml.org blog
Here are links from many OCaml blogs aggregated at the ocaml.org blog.
Old CWN
If you happen to miss a CWN, you can send me a message and I’ll mail it to you, or go take a look at the archive or the RSS feed of the archives.
If you also wish to receive it every week by mail, you may subscribe to the caml-list.