In a sense, all of this is a “pipe dream” unless someone cares enough to do it.
The ultimate bottom line is that I don’t have the time or resources to add any of this stuff to the ecosystem. And unless someone else does, it’s not going to get done. So if this wasn’t a request for ideas for a project you could work on, I’m not sure what the point is. And if it was such a request, then modular implicits is a thing I’d like someone to work on.
But since you did ask:
I think OCaml is generally good with complex data structures, implementing some protocol or standard, and general “business logic” branch heavy code. Compilers and language tools are just a special case of that.
This is where the pattern matching and exhaustiveness checks shine. The bulk of bugs in most large programs comes from complex control flow, and synchronized if statements in particular (because they break the correspondence between each line of static code representing one point in the dynamic control flow of the program).
In principle, you can encode that sort of information using templates or inheritance systems and dynamic dispatch, but in practice, the requirements for business logic change so often and are so arbitrary that it’s usually just better to use pattern matching and rely on the compiler to enforce consistency throughout the program.
In any code like that, the only reason I don’t use OCaml is because the startup cost of is too high. I can’t use some kind of lightweight IO stuff like I can in Perl. I don’t have a good database driver. Etc. So in practice, OCaml only gets brought out when it’s a big mission critical thing that I know in advanced is going to get involved. It doesn’t get used for experimental code that has the potential to evolve that way.
IMO, this is where the biggest / easiest improvements are. Reduce friction on the small / hobby project end of things and build out libraries features that make writing that kind of work easier to do.
Now that we have multicore, if OCaml gets libraries for handling irregular parallelism in a sane way (e.g. nested data parallelism, or the newer research on GPU acceleration of business logic tasks), that would make it a lot more compelling. Same goes for if algebraic effects improves the ability to reason about resource usage in a way that improves on the RAII used in C++ and Rust.
Another area where I’d like to use OCaml more would be random IOT gizmos on a Raspberry Pi and general administrative scripts for managing my computer infrastructure. For the former, Python has more day-to-day libraries for any random task and OCaml doesn’t have a good, low friction way to interface with Python code. For the latter, OCaml doesn’t have a good Windows story right now.
The windows thing is hard, but better, python-specific FFI is something someone could do. I don’t know how Julia manages PyCall.jl, but that’s on the level that I’d like for things to be (and it has made doing scientific work in Julia essentially “free” since interfacing to the massive existing libraries is basically free).
If the barrier to formal verification comes down or if Coq gets more accessible, I’ll probably start using OCaml a lot more as a result. But just learning the basics is hard and I’m no where near good enough to use those tools efficiently. I’d really like to be though. And as I said in the other thread, most practical code bases are distributed systems and I’d really like to be able to make the kind of formal guarantees for the entire system that you can get from the type system for an individual process. But I don’t know how to do that easily and there don’t seem to be accessible tooling for that purpose.
Similarly, I’d like to know more about how to do soft real-time work in OCaml, but I don’t understand enough about how to tune the GC and the allocations. So for anything where I have memory and timing constraints, I default to C/C++/Rust. But this could just a documentation issue. People do use OCaml for this, I just don’t know how I’d learn to do it in the context of a hobby project.
As for where it doesn’t get used:
If I have a standardized problem with a standardized solution and I’m just plugging lego blocks together. Odds are the thing more people are using has more eyeballs and is going to work just fine.
If I’m doing mathematical or statistical work (which at this point is most of what I do), I want the code I type to be as close to my actual math as possible. Any mismatch is where my bugs are going to come from. The way you can use unicode in Julia is really powerful and has pulled me into using that language for certain types of problems instead of just doing it Matlab for example.
Similarly, if I’m doing visualizations or some other presentation, OCaml doesn’t have the library and the tooling. I mostly hate every library in existence for this though. Everything has problems and limitations. And if someone could make a good OCaml one, I’d hop on board immediately.
P.S. I wouldn’t say “never” on modular implicits. People used to say that about multicore. And we eventually got multicore. I’m not holding my breath or building a project around modular implicits being there in the short term. But I am going to point out situations where it would help. (Like with Owl).
I do think being able to specify memory layout stuff is going to come sooner and will have a more immediate impact on more code. IIRC, from a YT presentation I saw, Jane Street has an internal prototype as-is.