r/functionalprogramming • u/kichiDsimp • 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 ?
13
u/PersonalityExact1676 Mar 14 '24
Maybe you should try Haskell directly.
23
u/Voxelman Mar 14 '24
I'm also not a fan of Elixir. I prefer languages from the ML family like Ocaml and F#.
If you like the self Dokumentation try F# and read the book "Domain Modeling Made Functional" from Scott Wlaschin and watch his videos on YouTube
7
u/snarkuzoid Mar 14 '24
Can you elaborate on why you don't like Elixir? Aside from non-homogeneous lists? I feel like there's more to it than that (I don't often encounter "furious" reactions to language features).
13
u/mesonofgib Mar 14 '24 edited Mar 14 '24
I'd suggest F#; it's based on OCaml but it runs on dotnet and has access to the enormous ecosystem that comes with that. You can also write OO in F# allowing you to mix styles as you learn before going full functional. It's a great way to learn the concepts.
5
u/cagix_ Mar 14 '24 edited Mar 14 '24
since you're asking for reading resources: i quite like OCaml Programming: Correct + Efficient + Beautiful
3
u/Herku Mar 14 '24
I also felt like a complete beginner when I started with FP. But there are a lot of different languages to try.
Can you talk more about your motivations to learn? How do you like to practise (e.g. small programming problems vs building apps). What kind of things do you want to build? What OOP or procedural languages do you know?
2
u/brava78 Mar 17 '24
Can you please tell us what about ocaml didn't make sense? I just recently learned ocaml too so I may be able to help.
16
u/luhsya Mar 14 '24 edited Mar 14 '24
the Erlang ecosystem just produced a new statically typed language that compiles to BEAM (common target of both Erlang and Elixir). check out Gleam
edit: fixed link
edit: technical correction
6
u/83d08204-62f9 Mar 14 '24
F# is great
Scala is fun too
5
u/it_snow_problem Mar 14 '24
Maybe take a break from learning functional languages until you understand why you want to learn them and what you want to build with them. Then, stick with it for more than a couple days. How you instantiate a list is very, very low on my list of reasons for quitting a language, but I can understand how someone who’s only written Java and go would find it odd when they try an interesting language.
Otherwise, personally I’d recommend a lisp as a good starting point because you can focus on learning functional paradigms with minimal weird syntax rules. Clojure is pretty pragmatic with a strong community, and you can play with it in online editors.
3
u/[deleted] Mar 14 '24
Based on what you are saying, more specifically it sounds like you don't like not having a type system. As everyone else is saying, I would stick with ocaml or F#. Picking either those can kind of depend on what you want to do with the language and what frameworks/libraries are supported.
3
u/cr4d Mar 14 '24
Might want to check out Erlang instead of Elixr.
3
u/Puzzleheaded-Lab-635 Mar 14 '24
I personally love Elixir, its not as dynamic as Ruby or Python. I'm a big fan of OCaml as well.
I'm not sure why `["string",4]` would bother you though. There are type systems that have no issue with that specifically.
With Strongly Typed Heterogenous Collections, for example, each row returned by an SQL query is a heterogeneous map from column names to cells. The result of a query is a homogeneous stream of heterogeneous rows.
Haskell, a Strongly typed Functional language allows you to do the above. (with the help from Existential types and GADTs)
4
u/Pure-Shift-8502 Mar 14 '24
Check out OCaml. The type system is the rockstar of that language.
2
u/dashingThroughSnow12 Mar 14 '24
I’ve written in a few different FP languages and am pretty good at FP programming in languages that allow that. I like them a lot and prefer them.
That being said, Elixir is bit of a funky language. I don’t blame you for not finding it that comfortable to write with. In general, the meta for FP programming is to take the principles of FP programming (ex no to limited side-effects) into imperative languages.
2
u/OrneryEntrepreneur55 Mar 15 '24
I think you should stick stick to Ocaml or Haskell while learning statically typed functional programming. Gleam seems a promissing newcomer. I also think anyone who has a background in object oriented programming should avoid Scala or F# while learning. Once you have acquired the techniques of functional programming, you can use more "pragmatic" languages like Scala or F#.
2
u/crowdhailer Mar 16 '24
Gleam. There is a great tour to get started https://tour.gleam.run/
And an exercism track to do after
2
u/[deleted] Mar 17 '24
Gleam. It runs on Beam and is statically typed
2
u/a_cloud_moving_by Mar 15 '24
If you don't want the .NET ecosystem of F#, Scala is very much functional, very much into types