• FizzyOrange@programming.dev
    link
    fedilink
    arrow-up
    6
    ·
    5 months ago

    I’ve been working on some OCaml code recently. It’s a quite elegant language but it has two or three big flaws that really make me not want to write it.

    1. OPAM is buggy as hell. There’s one piece of OCaml software that we use at work and literally everyone that tried to build it had problems due to OPAM. One was that it couldn’t find zip if you are in more than 32 groups!? I don’t even want to think about the kind of code that could lead to that bug. And this is on Linux! Have you tried installing OCaml on Windows? Yeesh.

    2. Global type inference means loads of types are inferred as generics, which means you give up a lot of the utility of static typing. Yes you can add explicit types, but the code I’m working on doesn’t have them. Rust was 100% right to require explicit types on functions.

    3. The syntax is pretty awful in my opinion. Yeah I guess it looks elegant and I’m sure whoever came up with it was very proud, but honestly maybe 40% of my time fighting OCaml has been spent figuring out where to place the damn brackets and semicolons. It’s extremely unforgiving too. E.g. if you put an extra semicolon on a top level let where you weren’t meant to it can sometimes be “valid” but it pulls the rest of the file into an inner scope, which means the compiler gives you a valid but wrong fix suggestion. Languages using curly brackets don’t have this issue at all.

    The lack of brackets for function calls can also make it difficult to work out what’s going on because you have another operator precedence to remember. Have trouble remembering which is higher precedence out of & and ==? Well now we’ve thrown calling functions into the mix for you to forget too!

    Finally the functional focus can lead to mega-expressions that are very hard to follow, especially when combined with the lack of brackets it can end up looking like word soup.

    OCaml has a ton of really nice ideas but I’m glad it’s just inspiration for better languages (e.g. Rust) rather than actually popular. I mean… it’s still a million miles better than Python… But that’s a low bar.

    • namingthingsiseasy@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      5 months ago

      Agreed on all points. I think some of the issues that you’re facing are things that would be resolved if Ocaml were more popular. But some others would be harder to fix without making breaking changes to the language as I mentioned earlier. If I had to put it as succinctly as possible, I’d say that the language just needs a lot more polish which would probably happen if it were more mainstream. But not all languages have to be mainstream, and maybe Ocaml’s purpose in the world is, as you put it, to inspire other languages. It is definitely extremely good at that!