8 months of OCaml after 8 years of Haskell in production
Dmitrii Kovanikov

Dmitrii Kovanikov @chshersh

About: I'm a Functional Programming enthusiast and Senior Software Engineer at Bloomberg using OCaml at work. All opinions are my own.

Location:
London, UK
Joined:
Mar 7, 2023

8 months of OCaml after 8 years of Haskell in production

Publish Date: Dec 16 '23
53 26

This article was permanently moved to my personal website:

Comments 26 total

  • Anthony Alaribe
    Anthony AlaribeDec 28, 2023

    Lovely article! I look forward to trying out ocaml as well.
    It's tradeoffs seem a lot like Go. Fast compile times, minimal syntax and moving parts,

    • Dmitrii Kovanikov
      Dmitrii KovanikovDec 28, 2023

      Thanks! I think you'll enjoy OCaml 🤗

      I do see it like Go of FP languages. Which is kinda the best of both worlds 😉

  • re.natillas
    re.natillasDec 28, 2023

    Nice article, now I have a bigger picture of Functional Languages!

  • Pablo Bollansée
    Pablo BollanséeDec 28, 2023

    Great article! Really nice to see you're enjoying OCaml, I've been looking at it too, but have not actually used it yet, but this makes me even more interested in trying it out.

    • Dmitrii Kovanikov
      Dmitrii KovanikovDec 28, 2023

      Thanks a lot, Pablo!

      If you liked Haskell, I think you'll enjoy OCaml too 🙂

  • АнонимDec 28, 2023

    [deleted]

    • Dmitrii Kovanikov
      Dmitrii KovanikovDec 28, 2023

      Thanks! I hope you enjoyed your time at Bloomberg 🤗

      Indeed, this particular example could be written better with the usage of pattern matching. I wanted to show the difference between guards and if-then-else. But looks like this particular example is not that convincing.

      I'll change it to a better one when I come up with it!

      Meanwhile, you might have some other example in mind?

  • Escherial
    EscherialDec 28, 2023

    You forgot the best asset OCaml which is its Web framework. Ocsigen is the most advanced web development framework. It's revolutionary once you get how it works. Nothing else can compete, in any language.

    • Dmitrii Kovanikov
      Dmitrii KovanikovDec 28, 2023

      I never tried Ocsigen. I guess, it's hard to compare two languages fully because you can never try everything.

      But you reply gave me some motivation to try it 👀

    • Jay Lee
      Jay LeeJan 21, 2024

      I’ve been using OCaml for 4 years now, but never used Ocsigen for web development. I have some experience with ReScript with React tho. I’m really curious about using OCaml for both front/backend; why would you recommend Ocsigen (vs something like Dream)

  • Eric Torreborre
    Eric TorreborreDec 28, 2023

    Nice article. It's great to have the two languages side by side as I'm tempted to have a closer look at OCaml.

    • Dmitrii Kovanikov
      Dmitrii KovanikovDec 28, 2023

      Thanks!

      Yes, I really wanted to compare these two languages.

      You can find other blog posts comparing Haskell and OCaml (some are older, some are newer). But I wanted to provide my take anyway and share my experience 😌

  • ふわふわのうさぎ
    ふわふわのうさぎDec 28, 2023

    I follow you on twitter and saw your recent posts about ocaml, so I decided to actually try it out. Using it for a bit during the holidays made me feel like it's just worse Haskell. When I saw your post, I thought that I'd see some features that are amazing, while it might just be my viewpoint, the stuff you're showing me here makes me want to use Haskell even more.
    Less than language features a few of the libraries are really cool tho. I'd love to have something akin to owl (cl.cam.ac.uk/~lw525/owl/chapter/pl...)

    • Dmitrii Kovanikov
      Dmitrii KovanikovDec 28, 2023

      It's totally fine to have different preferences!

      If you enjoy using Haskell, you can continue using it 🤗

  • Yawar Amin
    Yawar AminDec 29, 2023

    If we are comparing succinctness, let me offer an alternative parsing example :-)

    let parse_line line =
      Scanf.sscanf line "Status: %d | Result: %d" (fun status result ->
        if status = 0 && result mod 2 = 0 then Some result else None)
    
    Enter fullscreen mode Exit fullscreen mode
    • Dmitrii Kovanikov
      Dmitrii KovanikovDec 29, 2023

      Good example! I often forget OCaml has sscanf too as well as printf 😅

  • Daniil Baturin
    Daniil BaturinDec 31, 2023

    To.ml: A TOML parser

    I was so infuriated by that library that I made one to fix all its problems. ;)
    github.com/dmbaturin/otoml/

    It's actually compliant with the TOML standard, uses transparent types (but also offers helpers for getting nested values), and uses functors to allow the user to plug any datetime and bignum libraries or stick with built-in native int and string dates.
    Well, and offers informative parse errors, too.

  • Dmitrii Kovanikov
    Dmitrii KovanikovJan 8, 2024

    I received tons of feedback on my OCaml vs Haskell blog post! Thanks a lot to all who read and shared their thoughts 🤗

    Using the feedback, I improved my post by:

    ✍️ Changing the most triggering exponentiation example to a different one
    ✍️ Added links to all discussions of my blog post all around the Internet
    ✍️ Changed feature from 'Laziness by default' to 'Composable laziness'
    ✍️ Added 'topiary' as an OCaml formatter
    ✍️ Changed the suggested TOML library from 'To.ml' to 'otoml'
    ✍️ Changed the suggested AWS library from 'ocaml-aws' to 'awsm'

    Hope you enjoy it!

  • Bart
    BartJan 8, 2024

    Terrific post!

    For the comparison table, possibly include records support. This has been a Haskell deficit for decades, and no thank you, lenses are a bloated, heavyweight bolt-on when you just want simple, lightweight record support.

    • Dmitrii Kovanikov
      Dmitrii KovanikovJan 8, 2024

      Thank you!

      Haskell kinda has a better record story nowadays. You can actually have nice records in Haskell without using lenses!

  • Hercules Lemke Merscher
    Hercules Lemke MerscherJan 21, 2024

    Awesome post!

    I tried OCaml many years ago. I think around the same time I started playing with Haskell, but gave up on OCaml due the fact that Haskell felt more pleasant to use. You definitely made me wanna try OCaml again :)

  • Giulliano Ferreira
    Giulliano FerreiraApr 17, 2024

    Great post! I'd like to see another comparison including F# as well.

Add comment