Most active commenters

    ←back to thread

    Learn OCaml

    (ocaml-sf.org)
    203 points smartmic | 11 comments | | HN request time: 1.083s | source | bottom
    1. hyper57 ◴[] No.44400829[source]
    Loved using OCaml for a compiler course at uni when I was a student. But I've always felt that the tooling side is pretty rough, especially on Windows. Opam recently added Windows support, but it involves installing MinGW, and when following the official docs https://ocaml.org/docs/installing-ocaml#install-platform-too... the process breaks down with an error when trying to install utop due to a path separator error, which one has to fix manually (at least that was the case last time I tried). By comparison, installing Python or Rust on Windows is a breeze.
    replies(3): >>44400889 #>>44401349 #>>44401688 #
    2. lor_louis ◴[] No.44400889[source]
    Even in Linux, I'd say the tooling is a bit rough, dune and the new lsp are going in the right direction though.
    replies(1): >>44401130 #
    3. jact ◴[] No.44401130[source]
    Dune is a very powerful and good build system — it can do some very magical and useful things. The only problem is most of these useful features are very poorly documented…
    replies(1): >>44408827 #
    4. BrawnyBadger53 ◴[] No.44401349[source]
    The sluggishness of setting up new opam switches is definitely limiting in my experience
    5. emacdona ◴[] No.44401688[source]
    Never played with OCaml, but I spent the past few days learning about F# (my understanding is that it inherits a lot from OCaml). Tooling seemed great: I used JetBrains Rider; VSCode and Visual Studio are also options. Support seemed great: good official docs; good book choices. Ecosystem seemed great: entire .Net class library.

    I’m been on the JVM for 20+ years, but an opportunity came up to leverage some of my other experience to get some CLR work… and I dove in.

    replies(3): >>44402376 #>>44404548 #>>44405205 #
    6. sealeck ◴[] No.44402376[source]
    F# tooling is much, much better than OCaml's
    7. akkad33 ◴[] No.44404548[source]
    I used to fiddle with F#, its tooling is good, but it's interweaved with too much dotnet c# cruft and also there's the dark shadow of Microsoft. I wish it had zero cost abstractions like Rust because most things you write in F# is also slower than C#
    8. rpeden ◴[] No.44405205[source]
    F# has diverged from OCaml a bit, but they're still very similar.

    I mentioned in a top-level comment that F#'s "lightweight" syntax is basically what I want when I use OCaml. I know ReasonML is a thing, but if I'm writing OCaml I don't want it to look more JavaScripty - I prefer syntax like "match x with" over "switch(x)" for pattern matching, for example.

    I know some people dislike the way F#'s newer syntax makes whitespace significant, and that's fair. But the older verbose syntax is there if you need or want to use it. For example, something like

      let things = 
        let a = 1 in
        let b = 2 in
        let c = 3 in 
        doSomething a b c
    
    
    should still work in F# like it would in OCaml.
    replies(1): >>44405256 #
    9. yawaramin ◴[] No.44405256{3}[source]
    > F#'s "lightweight" syntax is basically what I want

    It's actually not that far off. For definitions that don't need to be self-referential you can use 'and':

        let things =
          let a = 1
          and b = 2
          and c = 3 in
          do_something a b c
    replies(1): >>44406703 #
    10. rpeden ◴[] No.44406703{4}[source]
    Thank you! I knew this, but of course blanked on it when I came up with an Ocaml example.

    There are a few other places I prefer F#'s syntax, but overall it's not the reason I'd pick F# over OCaml for a project. It's usually mostly about needing to integrate with other .NET code or wanting to leverage .NET libraries for specific use cases.

    Can't lose either way - they're both a please to work with.

    11. abathologist ◴[] No.44408827{3}[source]
    Would be great to get concrete feedback on the docs, because a lot of energy has gone into improving them in the last 2 years: https://dune.readthedocs.io/en/stable/index.html