4 ms·
I keep thinking there must be great potential for using the ML Module system to create high-performance, customize-at-compile-time libraries, like C++ template
by jasperry 10y ago
I keep thinking there must be great potential for using the ML Module system to create high-performance, customize-at-compile-time libraries, like C++ template libraries but without the messiness and potentially even more expressive.
But I've had a hard time finding SML or OCaml projects that advertise this as a benefit. Does anyone know of a project that's achieved this? Maybe many do, but don't state it that way explicitly?
- Avshalom 10y agoI think that's what fftw does
- jasperry 10y agoInteresting, however, it emits C code, and the paper makes no reference to the module system as what's being leveraged about ML. http://www.fftw.org/pldi99.pdf http://www.fftw.org/pldi99.pdf
- jlouis 10y agoThis is what MLton essentially does as a system. It will expand away every module use such that they have no runtime overhead, but only exist in order to organize code. This allows you to build software consisting of many small functors which are composed together to form the final program. It is perhaps the reason to invest time in OCaml or Standard ML. But it requires a compiler which can reap the benefit as well. Newer versions of OCaml, with flambda as a backend, also help with this and gives you some of the advantages of full-module-expansion. In practice, any decently sized OCaml or Standard ML program written by someone fluent in the module system would be an example project. Unfortunately, most of these I know about doesn't live in the Open Source world where I can just point to them. (Disclaimer: I was involved somewhat with MLton)
- metafunctor 10y agoThere's the MLton Library project: https://github.com/MLton/mltonlib https://github.com/MLton/mltonlib
- dwenzek 10y agoMirageOS arguments its choice of OCaml in these terms: "the module system is among the most powerful in a general-purpose programming language in terms of permitting flexible and safe code reuse and refactoring" https://mirage.io/wiki/technical-background https://mirage.io/wiki/technical-background
- Drup 10y agoI've wanted to write a blog post for a while, that would list the various advanced usage of the module system in OCaml. Mirage has already been cited, see also [1]. Another example is ocamlgraph [2]. I have an old reddit post that attempted to make a list [3]. [1]: https://mirage.io/blog/introducing-functoria https://mirage.io/blog/introducing-functoria [2]: http://ocamlgraph.lri.fr/index.en.html http://ocamlgraph.lri.fr/index.en.html [3]: https://dd.reddit.com/r/ocaml/comments/364vqg/examples_of_ocaml_modules_which_cant_be_done_in/craziqb https://dd.reddit.com/r/ocaml/comments/364vqg/examples_of_oc...
- jasperry 10y agoThanks, these are great references, especially the last one. I would definitely read that blog post.