OCaml RFC#17: library linking proposal

The devil is in the details. I remember hitting odd hard-coded stuff e.g. on mt predicates. Also the behaviour w.r.t. includes when you use packages does not seem to be documented there (and in general what happens when you use packages in the different phases).

I mentioned in the first message, using the environment to setting up libraries, I gave examples on why it makes debugging build failures harder, because now you have two different environments for each target, so copying a command is not enough anymore, why setting up cross-compilation harder and that we will probably still need to rely in a solution like findlib so it adds more complexity instead of removing them.

And also itā€™s not only a technical argument, itā€™s an ecosystem decision, itā€™s about community, saying ā€œbut it doesnā€™t break anythingā€ is just not the complete story, because in practice it does. Read the example of TC39 breaking the JS ecosystem with ES Modules and how webpack does all sorts of magic to be able to handle it, and they didnā€™t ship a single line of code.

Yes itā€™s a very small step adding a bit of complexity and sending a message to the community that the standard changed. Iā€™m not saying the end result in 10 years will not be better, but will it be better in 6 months? 1-3 years? A change like this is not small.

Iā€™m not taking credits for anything that isnā€™t my work and donā€™t think that I donā€™t remember the people that were here before me, Iā€™m just saying that stuff is already working with a package manager, only that.

And this argument was made because the solution of opam-monorepo chosen by MirageOS 4 is just not going to be affected by anything, because it is a workaround for opam, instead of relying on packages it is essentially vendoring all the packages in the environment and delegating the work to dune. Yes it works and will not be affected by basically anything, as itā€™s just dune.

But not a solution to the root problem, which is the lack of cross-compilation on opam. If that was not the case, there would be zero needs to use opam-monorepo and this is why I say itā€™s not orthogonal.

Libraries as described by the RFC are directly connected to the compiler, build system and package manager, so it definitely affects cross compilation. If you still have a package manager.

Iā€™m not capable of building a little unikernel with esy, Iā€™m capable of building almost anything, I got Revery which uses all sorts of C deps to work(including different C compilers), got really old deps like camljava to work on Android 10, esy to build itself to iOS, Android and FreeBSD. And as soon as I have spare time the goal was to build Tezos using it. This is not small and not limited to opam, topkg is also supported. Also it manages C deps too, so a bit more powerful than dune + opam-monorepo, without any environment mess needed.

BTW Iā€™m not the author of esy, not even a maintainer of it.

It makes me wonder if there is already this specification, if we shouldnā€™t just embrace it instead. Itā€™s well documented, a standard and already implemented in multiple places.

Great, we have an amendment to do and avoid that others have the same problem, this is progress, no step back needed.

If thatā€™s really your only gripe then the OCAMLPATH could be bootstrapped via a configuration file rather than at configure-time like itā€™s done now in the RFC. I donā€™t see this as a big deal.

Thereā€™s benefit in having a simple notion of library, how it is to be installed and used by other tools. And thereā€™s also benefit in the OCaml toolchain understanding it. I think the RFC is pretty clear about why this is the case so I wonā€™t repeat them here.

And yes itā€™s an eco-system decision, nobody is trying to hide that. But no it does not try to break the eco-system, it tries to gradually simplify it.

6 Likes

Thatā€™s not the only one, that is a problem, that will make people life harder on the long run, incentivizing OCAMLPATH overall will lead to problems. But even then, my gripe is with the RFC deprecating ocamlfind.

I agree, there is benefits in a simple notion of library, but it already exists, following ocamlfind. This is not new, itā€™s an already solved problem, not perfectly solved, but solved.

About the benefits mentioned in the RFC:

  1. Is that even desirable? Why isnā€™t gcc introducing libraries support on the compiler? But I agree with the dynlink problem deeply, and we need to address it, but the RFC is not only about it.
  2. It is addressed by dune removing the direct dependency on the ocamlfind, so now you just need ocaml and dune.
  3. Iā€™m not sure it is even an advantage, having multiple namespace for different things seems reasonable, opam packages may include other things besides of ocaml libraries.
  4. Agreed, but the convention already exists, which is ocamlfind.
  5. Itā€™s mostly already in place, if you look at libraries generated by dune theyā€™re basically always a single library per folder.
  6. Agreed, but this is why most libraries are named the same the opam package, it could be better but that can be done on opam side.

An important thing, as a user I didnā€™t even knew ocamlfind until I started to look on the cross compiling problem, because dune already solves this for me, so 2 and 4 itself is mostly pointless. So as an end-user and a tool developer, I cannot see how having a new standard will make my life easier. Essentially most of the benefits mentioned are addressed already by dune and ocamlfind.

By adding a new standard it almost always will not be simplifying things. xkcd: Standards

Telling everyone to change the standard of what is a library, is a breaking change. And trying to deny it by saying ā€œbut your code will keep workingā€ is not taking responsibility for the change. Again in the same way that TC39 didnā€™t take responsibility for breaking the JS ecosystem which they did.

And remember that the RFC has a section dedicated to what dune will do.

1 Like

It seems that your world view of the OCaml system is limited to dune. Thatā€™s fine.

But personally nowadays I start all my projects with an (unreleased yet) best-effort build tool. So just be mindful that people may use the OCaml system in different ways than you do. Once you factor that in, most of your rebuttals fall.

Also Iā€™m getting quite annoyed at your repeated suggestion that the RFC is not taking responsability for the changes it introduces while in reality it precisely describes how the existing tooling that most people use is made to be changed to become compatible and take advantage of the definition. I think your stance is disrespectful for all the work that went into designing and prototyping this and I have to say, Iā€™m not interested in discussing this with you any further.

3 Likes

Is this still being worked on?