A centralized location for "The Case for OCaml"

OCaml.org has https://ocaml.org/success-stories which I think is really nice: the takeaway seems to be, “cool, okay, people are using this language in production at large, well-established companies.”

There is also OCaml Papers , which discusses many ideas that have influenced OCaml and shaped its development.

I have been thinking that there is a need for a centralized community location for “the Case for OCaml” which is a sort of halfway point between these. This page contains “OCaml for the masses”, I don’t see the “Caml Trading” paper, it contains the Xen experience report, which are of a different flavor than the other whitepapers on that page, in that they argue why you should use OCaml rather than discussing features which will go into OCaml.

In the Rust community you frequently see blog posts like this:

which demonstrate empirically a pretty sizeable and quantifiable benefit from transitioning from C to Rust. I am not really familiar with many blog posts like this for OCaml and I think it would be good if we could collect and centralize them. (OCaml does not really compete with C in my mind, it competes with other memory safe languages like Typescript, but the point stands.)

The first paragraph on the “Why OCaml?” page says:

Programming languages matter. They affect the reliability, security, and efficiency of the code you write, as well as how easy it is to read, refactor, and extend. The languages you know can also change how you think, influencing the way you design software even when you’re not using them.

I think that “Programming languages matter” is actually probably a pretty controversial claim. Obviously programming languages matter but how much does the language matter compared to what your team knows, where the ecosystem is, does it have packages you need, is there good tooling, what is the cross-deployment story… many people would probably put the programming language itself at like, number 5 on the list of priorities when choosing a language for a project.

So I feel this statement “Programming languages matter” itself deserves to be defended at length and with copious empirical evidence, and the OCaml community would benefit from an apologia for good robust programming language design which underscores its importance. I would love to hear anybody’s suggestions for good reading on why language design matters, why good static types matter, and how OCaml specifically can help programmers to be more productive while helping them to reason about their code and catch bugs.

1 Like

I had to create a very little dynamic site… I jave started with php, but quickly switch to OCaml.

With OCaml+dream+caqti, I have a quite complete framework, and the static compilation spot half my bug if not more before the compilation… a simple <%s … %> quote my string and avoid any cross-script-scripting (no need to use htmlspecialchars)… I guess I have saved some time with OCaml.

With GUI programming on Windows, it would be more difficult…

Depending of the problem to be solved, OCaml can be efficient… or not.

1 Like

So I feel this statement “Programming languages matter” itself deserves to be defended at length and with copious empirical evidence

The most persuasive evidence is of the form “I used X, and now I use Y, and here’s how the switch automatically made my life much better”, and the first trouble is that you are no longer talking about just Y, but also X, and this draws the attention of fans of X who can be unpleasant in its defense, and who are more motivated and able to defend it than fans of Y are to fault it.

Sorry for all the variables. In 1999 perl.com had an advocacy link, “Perl vs. …”, and today you can only find it on the Internet Archive, and can hardly find imitators of it.

You might have seen some of this with major rewrites into Rust: https://news.ycombinator.com/item?id=26227339

Anyway, I’d like a repository of arguments like that, and an easy way to start it is with something like ocaml-community/awesome-ocaml. You could start with your bookmarks and some remarks about them, and invite PRs.

My problem with “Why OCaml?” is that it lists features that in the zeitgeist are either already nearly universal, therefore not promoting OCaml much, or are now controversial as features, therefore needing a defense which is not provided. Defenses which are probably more naturally provided in a document titled “Why Not OCaml?” which covers concerns people might have with using OCaml, with “Are We X Yet?” links where appropriate.

For example, Rust and Swift and Nim (and Lobster, and more) all have automatic memory management “without garbage collection” as a feature. Nim even started with GC and replaced it with ARC with a long list of benefits and performance improvements. Zig has manual memory management with explicit allocators which removes a lot of the pain of MMM, and Zig’s own feature list starts with “No hidden control flow” (i.e., exceptions) and “No hidden memory allocations”. There some easy criticisms you could make here (Rust is a hassle, ARC is a form of GC), but the point is that you now have to make them - you must provide some defense of GC because GC is controversial as a feature. This one’s good: Garbage Collection for Systems Programmers

In our wacky world of madvise(), memory-mapped I/O, and file system caches, there’s no simple answer to, “what’s allocated and when?” We can only hint at our intentions, then let the OS do its best. Usually it does a great job, but on a bad day, a simple pointer access can turn into disk I/O!

Technical details and performance stats about OCaml can also help. One reservation people have with exceptions is that “they’re slow”, to the point of incurring a performance cost across the language just for having them, but if such statements aren’t true of OCaml, it’s very helpful to say that.

2 Likes

Yes, by actively addressing concerns and objections about using OCaml through “Why Not OCaml,” and including sections like “Are We X Yet?,” we can showcase the community’s efforts to tackle pain points and highlight progress.

With an appropriate category, discuss.ocaml.org could also be a good place for collecting cases in favor of OCaml. Even old cases could get refreshed commentary. For example, ocamlformat catches deceptive formatting around match cases, noted in Category: 0install - Thomas Leonard's blog

1 Like