←back to thread

Learn OCaml

(ocaml-sf.org)
203 points smartmic | 1 comments | | HN request time: 0.206s | source
Show context
rpeden ◴[] No.44405154[source]
I like OCaml a lot - but I think I like F# a little more. They're very similar, since F# as essentially Ocaml running on the .NET VM.

I know some people dislike the fact that F# lacks OCaml's functors, but I can see why they weren't included. Due the the way F# integrates .NET classes/objects, I can accomplish more or less the same thing that way. In some ways I prefer it - a class/type full of static methods has the same call syntax as a module full of functions, but gives me the option of overloading the method so it'll dispatch based on argument types. Having everything that's iterable unified under IEnumerable/Seq is nice, too.

Having said all that, I still enjoy OCaml a ton. One thing I wish I could have is F#'s updated lightweight syntax brought over to OCaml. I think ReasonML is great, but after using it for a while I realized that what I really want isn't OCaml that looks more like JavaScript. What I want is OCaml that looks like OCaml, but a little cleaner. F# gives me that, plus, via Fable, compilation to JS, TypeScript, Python, and Rust. And via the improved native AOT compilation in .NET 9, I can build fast and reasonably small single-file executables.

Despite all that, I still try to dive in OCaml whenever it's a decent fit for a problem for the problem I'm trying to solve. Even if it's a little quirky sometimes, it's fun.

replies(1): >>44408804 #
1. abathologist ◴[] No.44408804[source]
> F# as essentially Ocaml running on the .NET

IMO, a language without proper modules, GADTs, or (now) an effect system, does not seem to me like it could plausibly be described as "essentially OCaml". Your point about having ad hoc polymorphism (outside of an object system) is another good point about why F# really is not OCaml on .NET.

Not to mention the difference of being trapped in (or having the luxury of, as you prefer) .NET vs. compiling to native binaries.

Glad you like F# tho!