Why did you learn OCaml?

I think we are going OT.

As a user of Julia, rust and OCaml, my problem with Julia is that I was bitten multiple times by runtime errors which would have been caught by the type checker if the same code were to be writte in Rust or OCaml. Featurewise, it depends a lot on the kind of libraries you are looking for, for my needs Julia’s libraries shine and are top notch. Yet, especially because I don’t really need brute speed or optimal use of hardware, in many cases I can actually rely on OCaml for my computations and owl and lapacke, even if not complete, worked rather well. Besides, I can use OCaml on my old laptops find, while Julia is completely unusable there (the JIT takes forever, and iterations on the code become a real pain).

I think rust is still quite a lot behind on the numerical spectrum of the picture, and last time I checked many libraries either ended up unmaintained or with a super slow development (probably due to a too small community still). I would be really happy to see it catching up: some experiments I did a long time ago were showing very promising results.

We have them (pyml, ocaml-r, ocaml-rs) also in OCaml to be fair (although I have issues with pyml on recent versions of osx). I think shelling out to python or R, in many cases, defeats a bit the purpose when so much focus is on bare metal speed.

To go back in topic :slight_smile:

I learned OCaml because I was looking for a strict, simpler, haskell, and Paris Diderot had just announced the first edition of its functional programming course in OCaml (Trouver un cours en ligne - FUN MOOC). I thoroughly enjoied the MOOC and ended up using OCaml to solve that year’s advent of code. Besides some annoyances with oasis/ocamlbuild (this was before dune times), I was quite pleased with the experience. Soon afterwards, I ended up working full-time with OCaml at Citrix on xenserver which also helped me getting more and more involved with the community, and enjoying the fast improvements of the development tools that were happening in those years.

I still have to often use python, Julia, Mathematica or rust for my needs but, more often than not, I end up missing OCaml (and some of its development tools) fairly fast. I was always impressed by the compilation times and by the ease of refactoring that comes as a byproduct of OCaml’s type system.

5 Likes

Well, OCaml also have Ctypes, Pyml and something for rust. These wouldn’t help much if you want, say, OpenCV which is absent in both OCaml and Julia. It would be really tedious (and inefficient) to write even high level ffi bindings for selected parts.

I like Julia, it’s a really nice language and I would choose it for scientific computations as well (in fact, I’ve tried), but its library story is the same (if not worse) as OCaml’s.

3 Likes

If you don’t mind giving a name, who was the post-doc who converted you?

1 Like

I’m interested in things like translators, and software transformation and synthesis. OCaml looks the best for this domain for the first look, and easy enough to learn for the imperative-only programmer.

3 Likes

let’s just say his last name is an anagram of an opam package concerned with data interchange :slight_smile:

1 Like

Simply I fell in love with the language itself and I would like to work with MirageOS

3 Likes

Well,

Early on, I read a post on Perlmonks by Ben Tilly, he mentioned programming paradigms
and how each paradigm will make you think differently about programming

So I was eager to learn different languages representing different paradigms
I stumbled across Ocaml, and at the time on there website they had this text, when you click the main image

https://web.archive.org/web/20040209033519/http://www.ocaml.org/camel-worship.txt

“Do they not look at the Camels, how they are made? And at the sky,
how it is raised high? And at the Mountains, how they are fixed firm?
And at the earth, how it is spread out? Therefore do thou give admonition,
for thou art one to admonish.” (Al-Ghashiya - The Overwhelming, 88: 17-21)

I am muslim, and for some reason the reference of this verse, by a group of people that I assume are none-muslims, just felt good to me

We dont need a miracle to see that God is great, or that life is an intelligent design etc…
We can just look at Camels or … actually anything around us, and we will see God’s might

Many years later, OCaml is now part of a bigger family or languages
F#, Reasonml, BuckleScript and even Rust in a way

If you learn OCaml , it will be easier to also learn the rest of the family and get whatever you need done, done … without really needing other languages from different paradigms

6 Likes

I was among the first batch of TA at my school which had to do OCaml Lab sessions (while we had only learnt Delphi ourselves the year before.)

Challenging time… like I still remember where i was seating when I was trying to do an `iteration’ as a recursion (and the guy teaching us telling us to stop thinking of in terms of iterations.)

It must have been in the year two-thousand.

2 Likes

I learned OCaml because HackerRank had an OCaml option and I liked camels.

9 Likes

After spending many years in Haskell what do you miss in OCaml if anything?

1 Like

Same question for you too: curious to know what if anything do you miss in OCaml after coming fron Haskell

1 Like

Coincidentally I was just thinking about that last night. Just to pick one thing, let’s say it’s the provisions for list handling. Maybe it’s just the way I approach things because of Haskell, but to me, lists are integral to functional programming, as the recursive data structure.

Of course they’re even more integral to Haskell where the basic string type is [Char], and that undoubtedly has a lot to do with the plentiful and prominent list support functions. OCaml’s list support by contrast is missing some easy stuff like “take”, “drop”, “break” - and nothing automatically present but a couple of operators.

Which kind of leads to the string handling, but I’ll leave that alone.

1 Like

Oh, hm. So at least “take” and “break” (well, actually, “filter”) are common in most extension libraries. Those existed in Coq V5.8 when I first saw it.

It’s only recently that Ocaml has gotten serious about having an all-encompassing “platform” that you’re supposed to be able to use without including third-party libraries. It would be a little surprising if stuff like this wasn’t out there in some third-party libraries.

P…S. BTW, there’s a reason why one would find “filter” and not “take”: if all you want is to filter a list by a predicate, “take” does extra work that is discarded (since Ocaml is eager, not lazy).

1 Like

OK, now we may be getting into what is broken for me with OCaml. If OCaml really means to everyone ocaml + Jane Street’s libraries, then distribute it that way (except without the duplication.) If it doesn’t, let’s agree on what OCaml does mean, and not keep switching references. When I go out to try to get a grip on some programming concept by looking at helpful work online, I keep running into unfamiliar stuff which (I know to expect now) is not part of the language I’m working with.

I’m particularly sensitive to this because opam appears to be out of reach for me, which pretty much means if it isn’t in the distribution, I write it myself. (take and drop were not too hard.) opam is one of those wretched programs that depends on itself, and the bootstrap library you need to use to make up for that doesn’t build on my less popular platform. I don’t support software that works only on popular platforms, so ocaml is good; opam I filed a bug and that’s the end of that.

This is of course not everyone’s problem, but the impediment created by multiple overlapping 3rd party solutions to basic language needs is everyone’s problem.

1 Like

For the record, I rarely use Jane Street libraries: they’re too big, and impose too much worldview. But that said, why can’t you use opam? And if not opam, why not just download the libraries and do “configure/make/make install” the old-skool way?

As someone who watched Java extend pseudopod after pseudopod to engulf third-party libraries, I dom’t think having an all-encompassing “platform” is all that great. I mean, I’m implacably against dune, for instance: any “ocaml platform” that made me use dune, would be a big problem.

Why is opam out of reach for you?

2 Likes

Not sure why the build crashes, but it’s preceded by this rather suspicious error. The code around that gives me no clue, the sizes look like run time parameters to me. It’s kind of you to ask, though.

   ocamlc src_ext/mccs/src/glpk/wclique1.o
src_ext/mccs/src/glpk/misc/wclique1.c: In function '_glp_wclique1':
src_ext/mccs/src/glpk/misc/wclique1.c:121:7: warning: 'memset' specified        size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]

Some day when I’m really hot for an external library I may give it a look and see how much work it would be to manage without opam. Or for commonplace list functions, it ought to be easy enough to write my own.

1 Like

What operating system is this?

Haiku, x86_64 version. (byte-code only. Haiku uses gcc, but the x86_64 object code is different because we link with -shared, thus making certain relocations and the operations that depend on them illegal.)

1 Like

Holy cow. That sounds complicated. Does Haskell support that? Do they test on that? I mean, -really- ?

1 Like

Pardon me, what is “that?” Do you mean, linking with -shared? I don’t think that has anything to do with the glpk problem that’s taking out opam, if that matters.