r/functionalprogramming • u/talerinpinguin • Apr 08 '24
Question First pure functional programming language to begin with?
I'm quite experienced in programming and recently I've been interested in purely functional programming languages, I've heard wonders about people switching from C# to F# and would like to try it out but I want to first consider other options.
28
Upvotes
36
u/stylewarning Apr 08 '24
If the "pure" part of "pure functional programming" is a priority, then definitely Haskell.
17
u/Kavereon Apr 08 '24
Haskell is good. PureScript is also a great option.
15
u/pthierry Apr 08 '24
If you already know how HTML works, then Elm is great introduction to pure FP. Its tutorial is short and to the point and you'll write interactive programs in no time, which can be very satisfying!
Elm is an order of magnitude less powerful than Haskell, but that's why it's also an order of magnitude simpler…
Once you're comfortable in Elm, get out of that zone of comfort and dive into Haskell. I didn't do the Haskell MOOC but heard great things about it. I use Learn You A Haskell at work for onboarding, it's a great introductory resource.
25
u/engelthehyp Apr 08 '24
I tried F#, but I didn't like it much, then I tried Haskell and really enjoyed it. This surprised me because I had used C# before and tried F# because it would be less foreign, but Haskell ended up feeling more natural. Still learning Haskell - definitely recommend it as a first pure functional programming language.
9
u/Voxelman Apr 08 '24 edited Apr 09 '24
F# is a great language, but it's not pure. But you can use it like Python as a scripting language, you can use it in a notebook or you can develop almost any kind of application like in C#.
For pure languages try Haskell, Idris, Purescript or, if you want to make some web front end, try Elm. It has a great compiler.
7
u/yawaramin Apr 08 '24
F# is not a pure functional language. I don't know how important the 'pure' part is to you but for people new to FP in general I personally think it's not that important and it's rather more important to get used to the functional way of thinking in general without having to worry about purity. I'd recommend https://ocamlbook.org/ to get started.
7
u/tesilab Apr 08 '24
If the goal is to learn functional programming, go with the OG of pure functional programming languages: Haskell. From there you can take the lessons and find whatever is most practical for what you want to do with that knowledge.
12
u/0xAERG Apr 08 '24
OCaml 😍
6
u/GunpowderGuy Apr 08 '24
Idris2 is great beginner choice because of its excellent community and because it lacks the technical debt of older functional languages like haskell. However it doesnt have as many libraries. You can ask me what kind of libraries you would like to use to see if idris2 has them
4
u/Asleep-Dress-3578 Apr 08 '24
Just add the closest language to your current tech stack.
Java -> Clojure or Scala
C# -> F#
Python -> Coconut or Hy
JavaScript -> JavaScript*
4
u/messier_lahestani Apr 08 '24
I really enjoyed Racket when I started with FP. Elixir was awesome as well. Can recommend both.
4
u/SteeleDynamics Apr 08 '24
SML (via SML/NJ)
4
u/Rapierian Apr 09 '24
Odersky's Functional Programming in Scala is a great course you could check out.
3
u/catbrane Apr 08 '24
Haskell feels quite a bit more functional than F# (imo). If you're going to try a functional language, I think I'd really go for it.
F# is perhaps more pragmatic, and has CLR integration which is great, but the language design is somewhat compromised as a result.
3
u/bosyluke Apr 08 '24
I'd say checkout roc. It's similar to Elm but more for general purpose programming. I've been enjoying learning FP with it for a while now and think its really good to learn with.
3
u/trannus_aran Apr 10 '24
scheme. Just don't use
set!and code to your heart's content. Check out sicp when you get the chance2
u/sebasporto Apr 08 '24
Elm is great for learning (and for professional work too) as it is simpler than other languages. It has less theory to learn and the language used in the community is more on the plain English side.
2
u/fhunters Apr 09 '24 edited Apr 09 '24
There is an online MOOC by Eric Meijer for Haskell that is a good place to start for Haskell.
Now, personal opinion follows. Haskell is amazing, beautiful and incredibly dense declarative syntax, and a different universe than what you are used to seeing.
Personally, I have found that many newcomers find the OCAML or F# syntax more approachable. And it's not difficult for these newcomers to be told a Chinese wall of don't use the language features for mutable OOP or non idiomatic functional programming when learning.
Next, in my personal opinion, the OCAML and F# ecosystems are better for commercial/practical applications and thus jobs.
Finally, and probably the most controversial opinion, there are times when an object makes sense. Where the universe demands that you protect mutable state from certain invariants.
OCAML and F# are the only two languages that I know of where I have the full tool set of type design. Algebraic data types that are closed to variant types and open to new operations where it makes sense, and objects when I need to protect invariants with types that are open to variant types but closed to new operations. Well maybe Scala also.
So my advice is start with OCAML or F# and stick with the idiomatic functional parts at first until you conquer them. But, if your up to the amazing declarative and dense syntax of Haskell cool.
Peace
2
u/SIRHAMY Apr 09 '24
I am an F# fan. I think it's a great pragmatic functional-first language to learn, especially coming from C#.
* It has a huge ecosystem (cause can use C# libraries directly)
* It's pragmatic - functional-first but okay if you want to fallback to imperative cause easier / better in some cases
* It has great ergonomics - great type system, low boilerplate, focus on pragmatism
If you're looking for where to get started, I've collected a few resources:
* The best way to get started learning and building with F# - https://hamy.xyz/labs/2024-01_best-way-to-learn-fsharp
* How I got interested in F# - https://hamy.xyz/labs/2024-01_how-i-got-into-fsharp
2
u/WildMaki Apr 10 '24
If you don't want to have a syntax shock, give a try to elixir. Clean ruby like syntax and many features you can start to use once you are comfortable with the language. IMO easier than all ML languages (just my opinion...)
2
u/samelaaaa Apr 12 '24
I started with erlang, and honestly I’d recommend it. It’s a lot easier to wrap your brain around than Haskell and friends (for me at least) but it is “pure” in that everything is immutable and if you want object semantics you basically have to implement them with OTP.
It’s also a great entry point into Elixir which is probably one of the more commercially valuable FP languages. You could start with Elixir, and lots of people do nowadays, but erlang is a much smaller and simpler language.
4
u/FalseRegister Apr 08 '24
Scala IMO
2
u/MaxwellzDaemon Apr 08 '24
Try J, from jsoftware.com.
It has a simple syntax and is interactive so you see results immediately. The user community is very helpful and supportive.
There is the danger that it may blow your mind because it's quite different from any other language you have tried.
2
u/Esnos24 Apr 08 '24
Maybe scheme/racket?
19
u/[deleted] Apr 08 '24
[removed] — view removed comment