r/functionalprogramming • u/No_Needleworker5106 • Sep 25 '24
Question Should I learn FP with Gleam or Scala?
I know those two language choices are weird, but I geniunely am interested in those two as my first FP lang. I have been using OOP (Java, Kotlin) and procedural (Python, Go) for a while. I am interested in Scala only because of ZIO and a new book that recently came out about the use of ZIO with Scala. I am also interested in Gleam because it is purely functional and the syntax is nice.
On the one hand, I know the Scala has a steeper learning curve. Yet it also has jobs. Gleam would be more for hobby projects. I'd like to emphasize that I enjoy the functional programming ways. I like pure functions and I enjoy writing a shit ton of tests for my code. As a newbie in this world, what do you think I should go for first?
EDIT: Hey everyone, thanks a lot for your input! Given the comments here, I think I will go with Scala + ZIO. It will be difficult but there is also no rush from my side :)
3
u/No_Needleworker5106 Oct 02 '24
For everyone here: yes, I want types
8
u/[deleted] Sep 25 '24
Elixir is the perfect choice here. Easy to learn FP using it. Plus decent number of jobs.
8
u/Traditional_Hat861 Sep 26 '24
Scala with ZIO is really good. Elixir is also good, Gleam is very new and I do not see much adoption right now.
In the Scala world too, finding a job that uses ZIO might be difficult since most still use typelevel stack and even more than that are Akka folks.
Elixir has a set standard of tools you do things with. Scala with ZIO can be a career option maybe sometime later, atleast that's how my thought goes. I put Rust in the same bucket as Scala with ZIO.
So, Elixir.
7
u/Voxelman Sep 26 '24
If you want to learn functional programming in general you should choose a pure functional language, not multi paradigm. And I would recommend a language with static typing.
Like: Haskell Gleam Elm PureScript
Other languages like Skala or Elixir might be easier to learn, but with pure static typed languages you learn the most. From there you can go almost everywhere
6
u/Arshiaa001 Sep 26 '24
As a C# dev, F# was perfect for me. If you're familiar with the Java ecosystem, I'd recommend Scala. (shameless plug: F# is also very good!)
4
u/harrismillerdev Sep 26 '24
Gleam is perfect for learning the core concepts. It's syntax and stdlin have a small footprint and you can run individual files as scripts. Go back and do your favorite Advent of Code problems with it, you'll learn a ton
3
u/123elvesarefake123 Sep 26 '24
Hey, what is the book that came out?
3
u/DevGiuDev Sep 26 '24
Surprised nobody suggested clojure coming from Java world
7
u/Kreeps277 Sep 25 '24
I may be biased since I have always used it professionally but Scala is a great language for FP, specially with ZIO and Cats. Would definitely recommend it. Never heard of Gleam so cannot really comment on it
2
u/pkumarn Sep 27 '24
We did quite a bit of functional programming in Kotlin. Yes, it has OOPs. But you can use it in functional style. I have programmed in Scala too. After Kotlin, Scala seemed a lot more harder to program in.
2
u/mister_drgn Sep 26 '24
Gleam is very new and has a small feature set. The small feature set isn't just because it is new--I believe it's a deliberate design decision to make it a simple language. So Gleam might well be easier to learn, but you'd be missing out on features that you'll find in other functional languages.
Also, you aren't going to find many resources for learning FP with Gleam, again because it is so new.
All that said, I actually think it would be reasonable to start out by checking out the Gleam language tour, just because it's so quick and simple--you could likely do it in under an hour. That could give you a taste of FP, and then you could move on to Scala (or Haskell or OCaml).
2
u/bilus Sep 26 '24 edited Sep 26 '24
It's a voyage, you won't learn FP in a week. I'd go slowly. Scala is a mix of OOP and FP, and it isn't pure so you can "cheat" and leverage imperative programming you already know. It's also rather complex.
Elm or Gleam - perfect as a starter. I'd definitely suggest starting with one of these. Elm is very simple and pure, so you're forced to write functional code so it's better at taking you out of your comfort zone.
As the next step, Haskell and (simpler) Purescript are pure so they'll take you out of your comfort zone, even further.
Then, when you go to Scala, you'll understand which Scala bits are functional, which are OOP, and are in a better position to consciously drive your design.
The best book for learning FP of the sort that your Scala code will benefit (monads). It's absolutely amazing: https://leanpub.com/fp-made-easier Even if you don't ever use Purescript, it's an incredible book to learn FP by writing code.
Another fantastic resource is Structure and Interpretation of Computer Programs. Again, you may never use Lisp but this book will blow your mind. Actually, I'd suggest watching these MIT lectures: https://ocw.mit.edu/courses/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video_galleries/video-lectures/
2
u/xiaodaireddit Sep 25 '24
Haskell
2
u/evencuriouser Sep 25 '24
I’d probably go with Scala. Gleam is a very new language. So there’s probably not many learning resources out there, and the community would be quite small which would make it harder to learn and get help. The language itself is also likely to go through breaking changes being so young.
1
u/sagittarius_ack Sep 25 '24
Gleam is a somewhat obscure programming language. The documentation is poor and you can't even find one proper book about it. You should learn Scala or Haskell.
-1
u/Away-Contest6515 Sep 25 '24
I used to learn FP with kotlin and arrow directly)