OCaml and Windows


#1

I know there are slowly ongoing efforts on improving OCaml support of Windows platform, but so far they look patchy and incomplete. And Windows users have to stuck to F# which is only a bleak shadow of OCaml obviously. Is there any roadmap or comprehensive plan to overturn the tables and beat F# on its own territory?


#2

Apparently Esy works on Windows (I don’t have a Windows machine handy so haven’t tried it): https://esy.sh/docs/en/what-why.html . It could be a good way for you to bootstrap.

There’s experimental support for building pure-opam projects: https://esy.sh/docs/en/opam-workflow.html


#3

Feel free to give bsb-native a try as well. Version 4.0.7000 should fully work on windows, without needing WLS or Cygwin. You should be able to just npm install bsb-native and it’ll work on your .ml files.


#4

I have used OCaml on Windows with Cygwin for years now. I think it is decent.

Opam for Windows works fine. Don’t know what kind of more compatibility is necessary, or is being worked on, but I haven’t hit any serious issues, despite pretty complex use-cases.

CSML makes it quite easy to make .NET bindings.

Merlin and Visual Studio Code work very well on Windows.

I’ve also used Dune, Lwt, Cohttp on Windows.


#5

@keleshev What configuration do/did you use for vscode + merlin under opam for Windows? Last time I tried it didn’t work well but I haven’t tried in a while.

Outside of editing, I’ve used the same tools and libraries @keleshev mentioned for building tools and services on Windows. I haven’t tried esy yet but I plan to soon.


#6

@hcarty I make sure that ocamlmerlin-server is on PATH in my Cygwin console, then I call code from within the console so that it inherits the path. In the editor settings I have only this:

"reason.path.ocamlmerlin": "ocamlmerlin-server",

#7

Cygwin is not native Windows development. I am speaking about proper port, with complete native support.


#8

@XVilka just to make sure we are on the same foot here, OCaml for Windows uses a cross-compiler version of GCC to produce native Windows executables which are independent of Cygwin and do not link to cygwin1.dll.


#9

A Unix shell is needed during the build step for many packages: OCaml itself, every package that uses ocamlbuild, zarith, and many more. Even packages that use dune, frequently rely on something like (bash <cmd>) or (run sh ./foo.sh). If you want to get rid of something like WSL or cygwin, you have to convince them to switch their build system (OCaml 4.08.0 just switched to autoconf :wink:).

Also opam internally relies on programs that are not available as native Windows application: rsync, git,…