r/functionalprogramming • u/mrToppo • Nov 26 '19
Question Favorite FP language
Dear FP community of reddit,
What is your favorite FP language? Are you using it or any other fp language on production?
I really enjoy Eliixr and I'm able to use it on prod. I used to enjoy Scala, but now kinda hate it. Also fan of Haskell and `F#.
17
u/ws-ilazki Nov 26 '19
OCaml. It has a lot of what I like about Haskell in it, but is a bit more pragmatic as a language, which I also like. I also really like Clojure for a similar mix of FP-first design and real-world pragmatism, though I've been using it less than I originally expected because of the requirement to use it through JVM, CLR, or transpiling to JS, which is what eventually led me to OCaml.
If I spent more time in the Windows ecosystem I'd probably be a bigger fan of F#.
6
u/phunanon Nov 27 '19
For me the JVM/CLR/JS was an appeal!
Knowing the tools around it was a plus. And now there's GraalVM if desperate to natively compile :)3
u/ws-ilazki Nov 27 '19
Yeah, I can see how that would be the case for someone already deep in the ecosystem. Choosing to piggyback on existing platforms' ecosystems was a deliberate design decision, and one of the reasons Clojure has seen success despite most lisp dialects being seen as novelties.
It didn't work that way for me, though, because I never liked Java and always actively avoided it, so I wasn't entrenched in the JVM ecosystem. I was interested in Clojure as a language despite knowing it was shackled to the JVM. Unfortunately, that also means that while I enjoy the language itself, I find the Java interop, dealing with JVM quirks, and the start-up time annoying and off-putting. I ignored it for a while because I like Clojure a lot, but eventually started looking for alternatives. First thing I tried was going pure CLJS and just using lumo and node instead as a workaround but that had its own annoyances so I started shopping around for other options again.
Since then, I've been liking OCaml quite a bit as well. I still prefer how Clojure works in some ways, but OCaml has a lot going for it as well. I miss the interactive development loop of lisps, but being able to run programs interactively as well as compiled is a nice runner-up option. It means I can start out writing like a scripting language, with a save->run->repeat cycle (and random REPL testing), then switch to testing compiled builds later on. Though compile times are fast enough I could just compile-and-run from the start, probably, I just don't.
1
u/phunanon Nov 27 '19
The start-up is a huge pain indeed - Clojure makes every function/def a class which JVM I suppose never expected. Especially now I'm personally getting really interested in FaaS, the JVM option goes right out the window. 'Native' compilation isn't the fastest thing either...
And I'm really at the mercy of existing libraries so while Clojure and its ecosystem is always appreciably stable, unchanging, emerging tech isn't.2
u/ws-ilazki Nov 27 '19
The start-up is a huge pain indeed - Clojure makes every function/def a class which JVM I suppose never expected.
Yeah. It's appreciably fast once it gets going, and you can do a bit of JVM tuning to get the start-up down a bit, but there's only so much you can do for it. Especially on Android, where the start time is far worse than on a normal system, which was unfortunately one area where I was initially excited to use Clojure. There may be some hope for that with GraalVM, I saw work being done to get it usable for Android applications, but it's not there yet.
Unfortunately, I also wanted to use an FP language to replace/reduce my reliance on typical imperative scripting languages for things like command line tools. I knew going into it that JVM start-up would be a thing, but the extra start-up caused by Clojure itself was a surprise. It was still fine for things I used infrequently or in cron jobs, but the delay got frustrating for anything I wanted to run more frequently, or needed immediate feedback on.
For example, on my desktop I use a hotkey to trigger a script to toggle volume on and off for specific volume channels. I used it as a test for a few lisp dialects, because the original Perl script was very short, and there's an objective but clear threshold of "this feels responsive" vs. "this is too slow" if the (un)mute takes too long. I could get Clojure down to about the same start-up time as CLJS, but both were far past the "too slow, feels laggy" threshold. Racket was a little better but still slow unless I took an extra step to make a compiled version. The unexpected winner, though, was Gauche Scheme, which was still slower than the instant-start Perl version, but well below the "feels laggy" point.
This isn't really a Clojure problem, though. I wanted to use it for something that it isn't currently suitable for and I understand that. I like the language enough that I spent a fair amount of time looking for ways to make it work for me, but it still isn't there yet, and it's still one of my favourite languages despite its expected use-case not matching well with mine.
so while Clojure and its ecosystem is always appreciably stable, unchanging, emerging tech isn't.
That's a good description of trying to use ClojureScript, too. Clojure is a nice, stable target, but the JS ecosystem below it is anything but. It's like having a sturdy castle built on a fault line, you never know when the ground is going to move under you.
Not having a good way to interact with async/await and libraries using it (plus nodejs callback hell) was annoying, too.
12
u/Shmeww Nov 26 '19
Big fan of F#, been using it in production for about a year now.
3
u/jamakai Nov 27 '19
What kind of system do you use it for?
4
u/Shmeww Nov 27 '19
Mostly just blob stuff, but I’ve also made an internal web application (100% F#) to manage our monitoring systems.
2
u/unicornh_1 Nov 27 '19
which framework? bolero? i want to build web-app for similar purpose..
2
u/Shmeww Nov 27 '19
It's in WebSharper at the moment, but I'm currently in the process of rewriting it in Fable.
2
u/unicornh_1 Nov 27 '19
man fable goes all over my head.. any way why choose fable over websharper?
2
u/Shmeww Nov 27 '19
Honestly almost every single aspect of (Fable or rather the SAFE stack) is in my opinion better than WebSharper. I had a much easier time learning and getting up to speed with Fable than I did WebSharper.
11
11
9
u/Quantixotik Nov 26 '19
Racket, a dialect of Scheme, is one of my favorites which I am learning deeper now. Haskell is definitely another, which I learned almost side-by-side along with Racket. I like Idris also, because of its strictness by default, compared to Haskell. Yet currently, I do not use Haskell or Idris -- until I finish some project with Racket.
7
u/gunnnnii Nov 27 '19 edited Nov 27 '19
I was just starting to look into elixir earlier today and I'm really digging the syntax.
The only language I've done something worthwhile in is Javascript/typescript and Java. I really like JS despite its many flaws. But I was introduced to Racket in a programing languages course I had a couple of semesters ago and loved it.
I've also tried ReasonML a little bit and it seems really nice, especially with React.
Can't really say I've tried enough languages deeply enough to pick favorites.
5
7
u/jhewlett Nov 27 '19
F#. Very mature, though ahead of its time in many ways. (Yes, at its core it basically started out as OCaml, but it has several other awesome features like computation expressions, type providers, and good async/multi-threading.)
Regularly gets new quality of life improvements, but the core of the language is so simple and useful that any new features these days may not seem huge. (Contrast that with, say, Java and C# which get tons of new, useful features, but that also means a bigger surface area and lots of ways to do the same thing.)
The fact that it’s a part of .NET core means it benefits from all of the awesome performance optimizations from Microsoft, including e.g. a super fast web server.
The tooling is quite good for an FP lang and getting better all the time.
3
u/ws-ilazki Nov 27 '19
I was impressed with what I saw of F# but like I was saying in my other comment, I mostly live outside the Windows ecosystem, which unfortunately made it a lot less appealing. I actually tried it before I got into Clojure and later OCaml, but using F# outside of Windows was not particularly pleasant at the time, so I didn't stick with it very long despite liking what I saw of the language itself. That could eventually change with .NET's improved cross-platform situation, but it's slow going. (Probably not as slow as OCaml's multicore work, though. Ouch.)
The tooling is quite good for an FP lang and getting better all the time.
OCaml deserves a shout-out for this as well: opam and dune are amazing. Dune's a very nice project management tool, and opam makes it extremely easy to swap ocaml compiler versions and manage libraries for each. Discovering that I could swap to an ocaml compiler variant that makes fully static binaries using musl with a quick
opam switchand then re-runningdune buildsold me on the system. I had been looking for a good way to make tools I could run on my dev-mode Chromebook, and I was blown away by how effortless it ended up being.5
u/Rodrigo_O-r Nov 27 '19
I'm developing in debian right now using .net core and VSCode with Ionide for a side project. I think it was a great experience (I also use it on Windows on my work so I could compare both, It hasn't been so much better on Windows) Probably things have changed a lot from your last try, I've used Haskell and Elixir and the tooling is at least at about the same level as Elixir in Linux.
3
u/mbuhot Nov 27 '19
You using NuGet or Paket for F#? I find neither as pleasant as mix/hex for elixir.
2
u/Rodrigo_O-r Nov 27 '19
I'm using paket on Linux, I agree that mix/hex is great, but dotnet/forge/paket is pretty good! I think that automatic type inference (in VSCode through annotations) and deployment are great points too! In general Ionide has a lot to offer and is really close to Visual Studio Tooling
3
u/LordOfSwines Nov 27 '19
I don’t mind F# but I wouldn’t say it’s ahead of its time.
1
u/jhewlett Nov 28 '19
I guess what I was getting at is that it inspired features in mainstream languages, e.g. async computation expressions which inspired async/await in C#, then JS, Rust, etc.
Though Haskell already had do-notation, so if you compare it to other FP langs, type providers were probably one of the only real innovations.
The creator of F# (Don Syme) was also involved in bringing generics to .NET/C#, which again, though not new to FP langs, helped introduce them to mainstream langs.
7
u/didibus Nov 27 '19
I'm just in love with Clojure and family. Only language that kept my enthusiasm year over year beyond the first year.
I've been using it in production at work for 2 years now I believe, maybe longer.
6
u/Rodrigo_O-r Nov 27 '19 edited Nov 27 '19
I've been using F# for about 1 year! I've been developing a new system for my work and also migrating an old SML project to F# as a freelancer. I really love the succinct and clear syntax of F# and stepping above the shoulders of the .Net environment is great! I also used Elixir and Haskell, Haskell was my first FP language a blew my mind, and I'm still in love with Elixir, probably making some side project in it the next year, but I'm a big fan of F# right now.
3
u/unicornh_1 Nov 27 '19
old SML project to F# as a freelancer
i am also looking F# for freelancing work can you give more direction on that?
5
u/D_4rch4ng3l Nov 27 '19
Favourite FP language (when I want to go full FP) - Haskell
Favourite language (I have choices now...) - Scala
5
u/fenek89 Nov 27 '19
Definitely Erlang. :) I've been using it for 9 years already in many commercial deployments, most of them related to messaging.
I don't like Elixir too much (even though I admit it does some stuff better than pure Erlang/OTP) but I'm taking a second attempt to get accustomed to its syntax. Maybe I'll change my mind. :)
3
u/indric Nov 27 '19
Second this.
Simplicity of Erlang, its concurrency model are very attractive for back-end type of jobs. I can't stress enough how many times remote shell/tracing saved me.
2
u/fenek89 Nov 27 '19
Exactly. This is one of my favourite features of the language. The degree of inspection and interaction with a live system is amazing. It's sometimes difficult for the customers to understand why I need a direct access to the production system in order to resolve issues much faster. :)
5
5
u/Ekstdo Nov 27 '19
Does Rust count (I know, it's not purely functional)? If not: Haskell
(Though I really like Elm, but its limitations make it unusable as a general purpose programming language)
4
u/bas_mh Nov 27 '19
Hard to answer, many cool languages to choose from. I especially like the statically-typed languages.
If I had to choose then Scala, but partly because it is the only functional language that can get me a job and the only one that I really know.
That said, I do love the language, and really like the direction where it is going in. Scala 3 seems like a game changer for me. Even though I hit the warts of the language on a regular basis, it is still by a wide margin the most productive language I got paid to use.
4
3
Nov 27 '19
Haskell and F# for me. I do like Elixir as well but I find that the lack of static types makes it really hard to reason about the code even with typespecs.
3
3
2
2
2
u/DaveWM Nov 28 '19
Clojure for me. Interactive development with the repl has completely changed the way I write and debug code. Also, being able to use ClojureScript on the front end makes full-stack web development much easier. I've tried other functional languages like Haskell, Purescript, Scala, and Elm, but I feel like I'm nowhere near as productive in them (some part of that may be due to my lack of experience though).
3
u/fear_the_future Nov 27 '19
Haskell, because I don't have to write code with it. If I had to I'd probably hate it. But it's good as a lingua Franca for talking about FP and PL ideas
1
1
Dec 04 '19
Python. :)
I use both Python and Erlang in production. Although the first isn't formally an fp language many of the most commonly used day-to-day tools in python have come from functional languages. Erlang is fine but as a language it's never achieved its true potential, still I'm fond of it because I know how to write stuff in it.
36
u/Comrade_Comski Nov 26 '19
Haskell