5 ms·
OCaml Onboarding: Introduction to the Dune build system
- deleted 4mo ago[deleted]
- ihumanable 4mo agoI like OCaml, I spend most of my day to day though in Elixir and I think one of the things that's so nice about elixir is mix. There's a handful of mix commands you learn when you get started and it's such a great experience. You can crack open erlang application structure and learn more if you want, but if you just want to `mix compile` `mix deps.get` `mix test` that's also fine. When I first learned ocaml I watched this really wonderful series https://www.youtube.com/watch?v=MUcka_SvhLw&list=PLre5AT9JnKShBOPeuiD9b-I4XROIJhkIU https://www.youtube.com/watch?v=MUcka_SvhLw&list=PLre5AT9JnK... (highly recommend if you are at all interested) and it's great for learning the language and tooling but it's all opam up until the end when some of it switches to dune. I think wanting to provide more details about what's going on is nice too, but I think there's a place for "here's the commands you will actually need in your day to day"
- calvinmorrison 4mo agowhat is wrong with make why does every language need to re invent packaging, building, etc. I think these people have no useful software to write so they rewrite the development stack.
- troupo 4mo agoBecause Make sucks? Because it's really limited and not expressive? Because it's not really a build system (nor is it a package manager or a dependency resolver or...)
- klibertp 4mo ago> Because it's really limited and not expressive? It's neither of those unless you limit yourself to a lowest-common-denominator feature set. GNU Make, for example, is a Turing-complete, dynamic programming language and a CLI task runner. You can build a build system in GNU Make (https://github.com/omercsp/simple-build-system https://github.com/omercsp/simple-build-system) just like you can do so in any other language. Make suffers from unfamiliar and somewhat unorthodox syntax, and inconsistent language design. So it's not a good language, and saying it "sucks" is not completely unjustified, but not because it's limited. Looking at SBS, it also seems quite expressive, although I can't say I ever tried building something in it myself.
- yawaramin 4mo agoThe OCaml ecosystem tried the Make route, it was complex, turns out no one likes maintaining makefiles by hand, and they like opaque make rules even less. Like it or not, dune exists for a very good reason.
- rwmj 4mo agoMake works fine with OCaml. There's a handful of rules you copy and paste around which is not ideal, but that's much easier to deal with than dune.
- zelphirkalt 4mo agoCan you link a Makefile for an OCaml project, which ensures reproducibility and locality? What I mean is checking checksums of dependencies upon when they are installed, and acting only in the project directory, not changing the surrounding system in order to run the program. Asking, because I tried and failed.
- rwmj 4mo agoocamldep will set up the dependencies correctly. For examples, have a look at the multiple Makefile.am files in libguestfs, guestfs-tools & virt-v2v projects. All run as non-root so they don't change anything about "the system" assuming that's what you meant. (On mobile at the moment so can't link easily.)
- zelphirkalt 4mo agoYou mean this one: https://github.com/libguestfs/libguestfs/blob/master/Makefile.am https://github.com/libguestfs/libguestfs/blob/master/Makefil... ? I don't see how ocamldep is used in there. It seems to use multiple different programming languages somehow. I don't find it easy to understand what it does. It seems to be building a website as well.
- yawaramin 4mo ago
- pjmlp 4mo agoBecause there isn't one package system that works everywhere, and even inside a single OS, each group reinvents the packing as well.
- Levitating 4mo agoWhat are you proposing? Because make isn't really good for anything either.
- zelphirkalt 4mo agoI use GNU Make for my Python and GNU Guile projects just fine. For Python projects it becomes a job runner of tooling commands. For Guile projects it uses a SHELL that is a guix shell, which references channels and manifest, to ensure reproducibility.
- deleted 4mo ago[deleted]
- ux266478 4mo agoWhy is an opinionated build system for a language not useful software?
- cassepipe 4mo agoWhen I started learning make it wouldn't work and I wouldn't understand why so I dug into it and now I understand how it works and I can make it work but seasonned programmers still tell me my makefiles are wrong and then proceed to use even more arcade parts that render their makefiles incomprehensible. At some point I just gave up makefiles for anything non-trivial and went over to xmake where life is mostly simple and I never do it wrong.
- waynesonfire 4mo agoone day we'll get the equivelent of language server for build systems.
- rienbdj 4mo agoBuild systems are a much harder problem, probably because mainstream languages are all edited the same way, but not built the same way. The closest we have right now are build systems in the Bazel / Buck2 lineage.
- zelphirkalt 4mo agoI tried to write some Ocaml stuff using a Makefile, because I also didn't want to use even more specific tooling, but it became ugly quickly, because I had to use `ocamlfind` and `ocamlc`, and provide a list of all packages to include and so on. It felt a bit like writing C at that moment, where you need to tell gcc what system libraries you are using, so that it compiles the program with those. So in the end I tried using dune and opam and whatnot, but it all felt less than clear to me. Especially, the comment someone else made here about having 2 different types of files for dune to work ... I just want a project local directory, that contains all my dependencies and a lock file to reproducibly built my projects. That's the minimum I expect these days. Or some equivalent alternative.
- zombot 4mo agoI use Dune only for my local libraries, because the install step fits perfectly. But my app projects all use a Makefile, including apps with a table-driven parser (Menhir), where the OCaml `.ml` source has to be generated first. You have to know `make` well enough to do that, but it's definitely possible.
- legobmw99 4mo agowhat’s wrong with make is largely that people are bad at writing makefiles. A tool like dune is able to enable cross compilation of a massive number of libraries out of the box, but make based projects that weren’t designed with it in mind almost always require someone to go through and separate out the mess of what needs to run on the host vs be built for the target, etc, etc
- rixed 4mo agoJust to let you know you are not alone, stranger; but also to advise you to be careful when touching on group identities.
- p4bl0 4mo agoThis is a good introduction to Dune, but frankly, Dune kinda sucks. I mean, it is very powerful, and works very well, but it's too much of a hassle, especially for beginners. I don't want a language specific build system to require two different files to actually be usable, even on very simple projects… I still use it because it is the de facto standard, but I really preferred ocamlbuild [1], which was actually a tool that just worked without any configuration necessary for simple projects that uses standard tools. Where you would need to write a Makefile and call make, you could just write nothing and call ocamlbuild and it would just work. Dune lost that ability entirely. [1] https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc https://github.com/ocaml/ocamlbuild/blob/master/manual/manua...
- dharmatech 4mo agoI've been messing around with ocaml on plan9: https://github.com/dharmatech/ocaml https://github.com/dharmatech/ocaml
- ranie93 4mo agois uv to python what dune is to OCaml?
- natrys 4mo agoNo I think uv is to python what opam is to ocaml, it's mostly a package/dependency manager. Superficially, both uv and dune are also project runners. But dune is mainly a build tool, most important things dune does such as pre-processing, linking, compiling etc., are not needed in python in the first place (at least talking about pure python). You can use uv to create tarball/wheel but it's more akin to simple bundling than building in the dune sense. Dune can also run tests, but in uv you would need to delegate to something like pytest etc.
- deleted 4mo ago[deleted]
- chris_armstrong 4mo agoNot yet - it's mostly a build tool, but package management abilities (which is otherwised covered by opam) is being added to it^1. It's currently usable for some projects (and worth trying out), but still in preview mode. ^1: https://dune.readthedocs.io/en/stable/tutorials/dune-package-management/index.html https://dune.readthedocs.io/en/stable/tutorials/dune-package...
- redrobein 4mo agoDoes anyone know what's up with ocaml on windows? I haven't used it in a while. Trying to install utop on 5.x compiler and quite a few packages need a downgrade to 4.x? I've tried with both mingw and system-msvc. Same behavior.
- chris_armstrong 4mo agoInstalling via opam and using the cygwin method is supported and should be working fine (cygwin is just used for build - binaries still just link with mingw). That specific combination (ocaml + mingw) has a known problem with ocamlfind that's still awaiting a new release (see https://github.com/ocaml/ocamlfind/pull/112 https://github.com/ocaml/ocamlfind/pull/112). ocamlfind underpins quite a bit of the package ecosystem, so this one is annoying, as the mingw workflow is otherwise quite good.
- Tryk 4mo agoIt's incredibly painful working with OCaml and dune on Windows, unfortunately. Docs are insufficient and there is little information online :/, wish it was not the case.
- totetsu 4mo agoAre OCamls related to ollamas?
- nesarkvechnep 4mo agoMore related to OMamas.
- zombot 4mo agoI have been trying to read the original Dune "documentation", but it never told me how to do the stuff I needed to do. Finding pertinent information was based on pure luck, and even then it was tough as old chewing gum to find out "how do I do X?". The target audience is apparently limited to wizards who already perfectly understand Dune. Maybe this introduction will finally do the trick.