r/functionalprogramming • • Mar 14 '24

FP Understadning Elixir but not really liking it

I have been developing in Go for the whole of 2023, and I really like typed languages, it gives me immense control, the function signatures itself act as documentation and you all know the advantages of it, you can rely on it...

I wanted to learn FP so after a lot of research I started with OCaml, and I felt like I am learning programming for the first time, it was very difficult to me, so I hopped to Elixir understood a bit but when I got to know that we can create a list like ["string",4] I was furious because I don't like it

What shall I do ? stick with Elixir ? go back to learn OCaml, [please suggest a resouce] . or is there any other language to try ?

12 Upvotes

54 comments sorted by

View all comments

Show parent comment

4

u/v3vv Mar 18 '24

Oh I totally get that.
I had my own share of trust issues with OCamls type inference system at first likely due to our backgrounds in languages where some sort of type inference is being advertised but shoots you in the foot if you depend on it.
It blew my mind with how spot on OCamls inference works.
I'd be coding thinking “no way it's gonna figure out this functions type” but it just does.
Sure, you get the odd 'weak ref' here and there but usually it's because you haven't given enough context for its type to be inferred.

I find it quite amusing when people talk about how amazing rusts type system is.
I mean rust is cool and all, but it's pretty clear they took some serious inspiration from OCaml.
Unsurprisingly as they even started out writing rust in OCaml. OCaml doesn't get the love it deserves honestly. People get all hung up on the syntax being different from what they're used to like the semicolons in lists, no explicit returns, or how there isn't any function overloading even for infix operators so you have to use different operators for int addition vs float addition.
But if you look past that there's this incredibly smart and well thought out language waiting.

The one thing I wish OCaml did differently is not burying the comments in mli files.
And they're not that concise either.
Coming from golang where you've got awesome docs in the stdlib and also in third party packages, even giving usage examples, their mindset about documentation can be somewhat disappointing.
OCaml could really benefit from something like that as it would lower the barrier of entry.

Apart from that I enjoy OCaml quite a bit.