←back to thread

Learn OCaml

(ocaml-sf.org)
203 points smartmic | 1 comments | | HN request time: 0.201s | source
Show context
another_twist ◴[] No.44402433[source]
Is OCaml still worth learning these days ? Feels like plenty of languages are evolving quite well and most things can be done in imperative langs like Go/Java with pretty concise code and certainly better perf.
replies(6): >>44402448 #>>44402524 #>>44402790 #>>44404250 #>>44405117 #>>44408867 #
yawaramin ◴[] No.44402524[source]
Both claims are debatable.

Pretty concise code: Go code is full of `if err != nil {...}` song and dance and they seem pretty committed to keeping it that way. Java is stuck with decades of decisions and libraries made in their early days because they can't break backward compatibility. Eg, all the standard library collection types are mutable. And of course, both of them have the 'null pointer' problem, which OCaml doesn't.

Meanwhile OCaml has had the same main type-level tools (record types, variant types) and techniques (pattern matching, first-class functions) since the very beginning and those are still the workhorse till this day.

Certainly better perf: I'd say that really depends on how much tuning has been done. OCaml applications by default are fairly performant and with OCaml 5's multicore support and effect handlers will unlock even more performance wins.

replies(1): >>44402593 #
another_twist ◴[] No.44402593[source]
Go is definitely full of these issues. Java has pretty good perf out of the box due to JIT. The libs may be old but they do their jobs really well. Some common ones like Guava are updated as new features become available. Tbh the collections being mutable isnt really an issue since it gets the job done and reasoning about these things isnt that hard. However I do prefer immutability wherever I can get it.
replies(3): >>44403731 #>>44405727 #>>44417715 #
1. Quekid5 ◴[] No.44403731[source]
> Tbh the collections being mutable isnt really an issue since it gets the job done and reasoning about these things isnt that hard.

Have you worked in language with immutable collections by default? It's night and day -- no more defensive copies, no more weird ImmutableList wrappers (Guava) which will (interface-wise) say they're mutable but will throw at runtime, no worrying about multithreading, cheap subsequences, etc. etc.

The difference is so stark that I would literally choose a worse[0] language(!) over a better one if it had immutable collections by default.

EDIT: Since you mentioned Java in a sibling comment -- give Scala a try and try working with the collections there.

[0] Within reason, of course :)