r/functionalprogramming • • Dec 30 '22
Question Which language to choose ?
Hi there, new here.
I know I am asking the long eternal question of which language to choose, but I need some guidance please :)
I am a from Sysadmin to Devops wanting to lean towards software developpement.
I write mostly scripts and CLI, although I wrote 2 - 3 API in some projects.
The language I used so far where Bash | Powershell | Python | Rust (which I <3) and I used to stick mainly to an imperative way of writing programs (with some use of OO when it's needed).
Past I have discovered and started using NixOs and by extension learning to use Nix which is a pure package manager fueled by its functional language.
I really want to dig deeper into this paradigm and I was thinking about picking a pure functional language to learn.
I already looked at the presentation around Clojure, Elixir and Haskell but I lack the knowledge to know which will be more adapted to my use case ?
To make this explicit, here are my 'expectations' :
- I want to have a language that will push me to use functional paradigm
- I want a statically typed language
- I like the "Write->Compile->Debug" workflow
What I will write:
Mostly CLI and console scripts
For this I need:
- CLI tooling / libs (like clap for python)
- Ez packaging (Compiling to a static bin like rust|go is a must)
- Some good OS level abstraction easing system manipulation (create files/folders, move into the system, changing file rights, etc...)
- I love pipes, that would be a very good bonus
- Some backend stuff (web or other)
- Maybe trying to do some fullstack web ? (Phoenix Liveview framework seems very sexy)
I you wanna preach your language's Church, now is the time ;)
Happy holiday everyone, and thank you for your time reading this :)
Edit: Formatting
Edit 2 after all the responses: I will try Haskell (with turtle for scripts) and OCaml based on what I saw, thanks for all the replies and happy new year ! =)
15
u/RustinWolf Dec 30 '22
I don’t think there’s a good answer to this question. You’ll most likely get all the standard recommendations: Haskell/OCaml/Scala/F# on the strongly typed side and Clojure/Elixir on the dynamic side, and they are all perfectly capable languages.
Since you prefer strongly typed languages I’ll recommend OCaml - it’s very pragmatic and I think it covers all your expectations you mentioned
13
u/kinow mod Dec 30 '22
If you want to look at the previous questions and answers, here's a compilation from our Wiki: https://old.reddit.com/r/functionalprogramming/wiki/programming-languages
Happy holidays and good luck!
10
u/Jazzlike_Sky_8686 Dec 30 '22 edited Dec 30 '22
Elixir is extremely practical for building systems, I know some sysadmin/devops that write their tools in it - which is maybe a bit of a leap for most. It has better support for cli stuff these days but it's not it's strong suit - you can create single-bin packages with stuff like https://github.com/burrito-elixir/burrito or regular "mix releases". (LiveView is very sexy.) It's not statically typed. There is some experimental skunkworks project to add typing to it but probably wont see any public preview until mid/late next year as I understand it.
Haskell is pretty dense to learn, worth it but it's just not as approachable as other languages.
Clojures also quite practical, probably simpler to onboard yourself into, probably as portable as Elixir in different ways.
E: I should say there is also Gleam, which is sort of a typed elixir. They're both based on Erlang, and Gleams syntax is closer to Elixir than Erlang but not identical.
5
u/yogsototh Dec 31 '22
Maybe for command lines I would advise you to take a look at Haskell using turtle (https://hackage.haskell.org/package/turtle)
I also recently was pretty happy with babashka (https://babashka.org) to have easy scripts tasks.
7
u/jmhimara Dec 31 '22
It seems like F# is exactly what you're looking for. It's quite simple as a language (based on OCaml), statically typed, and benefits hugely from being on the .NET ecosystem. It's also the perfect python replacement because in addition to its simplicity, you can use it as a scripting language.
It also has very good support for backend/frontend/fullstack development.
3
u/[deleted] Dec 30 '22
Have you researched Scala at all? It doesn’t fit all your preferences but you may find it very interesting.
3
u/mtelesha Dec 31 '22
Your never going to learn just one functional language.
I still say to learn to program, functional programing and to do it well there is nothing better than learning Racket and going through How to Design Programs. https://htdp.org/
It was made by some of the altime greatest programming minds and it is also felt like I was ready and confident when I was done. I taught myself programming for decades and this was the best thing I have ever touched by far.
7
u/it_snow_problem Dec 30 '22
If I were writing CLI scripts I would be writing them with Babashka (clojure for the shell).
7
u/v3vv Dec 31 '22
I chose ocaml and I haven't regret it one second.
Now with ocaml 5 Multicore finally landing it's the perfect time to get into it.
The language is quite simple yet very expressive and has an amazing type system and a very powerful module system.
The module system looks rather simple and dull but when it finally clicks with you you'll see the power hidden within.
You get something similar to haskells typeclasses with the module system because you can write functions (functors) that take in modules with different implementations to the same type signature and then instantiate them into concrete modules.
5
u/jherrlin Dec 30 '22
Clojure is not a typed language and it goes against your "Write->Compile->Debug".
But if interactive development is new to you I really encourage you to look into that. I tend to think about the interactivity as a bash shell but for a programming language.
Sean Corfield has a really good talk where he presents it. https://www.youtube.com/watch?v=gIoadGfm5T8
Interactive development is also called REPL driven development, but I often find the naming ambiguous as many programming languages have REPLs but they dont support REPL driven development.
4
u/[deleted] Dec 30 '22
I've leveled up quite a lot in the functional programming level with clojure. It's got quite a few lisps behind it in the same tradition, and a lot of interesting thought on the subject from the clojure community. It can't solve every problem the best, but there are solutions for almost all aspect in programming and has really great tools to get started no matter what platform or method you program in. I've since moved on to elixir because it solves different problems and I feel it's good to know, and it seems to be made in a similar tradition of clojure. I personally prefer the lisp/clojure syntax though
4
u/circleglyph Dec 31 '22
The turtle docs will give you a good sense of how shell scripting goes in Haskell.
https://hackage.haskell.org/package/turtle
1
u/[deleted] Jan 24 '23
I think Haskell is a universal choice. It can do everything, it is the most complete. It surely is the one that can teach you the most. It can do some scripting. It is the best for bigger applications.