r/functionalprogramming • u/MrPezevenk • Mar 13 '25
Question What "non-FP" language implements FP the best?
The title may seem a little bit paradoxical, but what I mean is, that outside of languages like Haskell which are primarily or even exclusively functional, there are many other languages, like JS, C++, Python, Rust, C#, Julia etc which aren't traditionally thought of as "functional" but implement many functional programming features. Which one of them do you think implements these concepts the best?
50
Upvotes
39
u/it_snow_problem Mar 13 '25
Tempted to say Scala. Maybe Common Lisp if I’m feeling pedantic.
On the more major language side, I’ve honestly used JS/TS almost entirely functionally for large projects, and it’s easy enough to use that paradigm most of the time.
17
u/sacheie Mar 13 '25
Kotlin.
102
u/turtel216 Mar 13 '25
I would say Rust. It does not enforce functional programming, but it strongly encourages it. Immutability as a default, the option of lazy evaluation, ADTs, pattern matching. I enjoy writing functional-esk code in Rust.
3
u/burg_philo2 Mar 13 '25
C# seems to be the best out of the OOP/“enterprise-y” languages if you count Scala as primarily functional. Maybe Kotlin is comparable tho I haven’t looked into it. I don’t count Rust because not using a GC goes against the ethos of FP imo
11
u/123elvesarefake123 Mar 13 '25
Ts the language is really nice but everything around it sucks imo but just to plainly write code it gets my vote
5
u/Mediocre-Brain9051 Mar 13 '25
The boundary of what is an FP language is not well defined. You could as well have asked "what is your favourite programming language?" The answers are likely to be the same.
4
u/tuxedo25 Mar 13 '25
I never used it personally, but for a long time, F# was like crossfit. People wouldn't stop talking about it.
4
u/mprevot Mar 13 '25
Ocaml
6
u/gay_married Mar 13 '25
I like Python with the Pyrsistent library.
8
u/sdegabrielle Mar 13 '25
Racket, of course 😁
https://racket-lang.org
3
u/Marutks Mar 14 '25
Clojure.
2
u/TheRealStepBot Mar 14 '25
Honestly Java has very nice functional features. Which is somewhat ironic as it’s also the king of oop boilerplate.
2
u/thx1138a Mar 14 '25
F# but it seems to have a huge visibility problem.
2
u/tintin10q Mar 14 '25
Sac perhaps
2
u/fred4711 Mar 15 '25
Lua. Correct scoping (unlike Python and JS), TCO, everything first-class.
2
u/Ug1bug1 Mar 14 '25
Common Lisp. It is doing it so well that people think its a functional language.
2
u/mister_drgn Mar 14 '25
I’m betting no one else will say it, but I like Swift’s fp features. Between the core language, the standard library, and the macro system, you can go as functional as you want, pretty much. It also has an expressive type system that’s about as powerful as you can get without higher-kinded types. I wish more people outside of Apple’s ecosystem would try it.
That said, I wouldn’t be surprised if Kotlin’s on the same level, being a similar modern language.
2
u/recursion_is_love Mar 14 '25
C--
2
u/ScottBurson Mar 15 '25
Common Lisp with FSet.
3
u/benny-powers Mar 13 '25
JavaScript.
3
u/jmhimara Mar 13 '25
I would say Haxe. It's probably the language that get's you closest to doing FP without being a proper FP language. It even has actual pattern matching implemented. And it is expression based.
2
u/esesci Mar 13 '25
C# is getting closer every release now with pattern matching, LINQ, collection expressions, and generators. But, lack of default immutability, top-level functions, and discriminated unions leaves it behind languages like Swift or Rust.
1
u/Anarchiste-mouton Mar 23 '25
VBA ?
1
u/matthkamis Mar 13 '25
Kotlin or C#
-2
u/bsdooby Mar 13 '25
C++
6
u/[deleted] Mar 13 '25
[removed] — view removed comment
3
u/[deleted] Mar 13 '25
[removed] — view removed comment