r/functionalprogramming • u/Voxelman • May 29 '25
Question Functional alternative for Python as de facto standard on Linux systems
Almost every Linux distribution has Python installed by default.
Is there a functional language that could eventually replace Python as the standard?
I think it should be a dynamically typed and interpreted language that, if possible, does not require Javascript or similar platforms in the background.
Potential candidates: Clojure (requires JVM) Elixir (requires Beam) Racket GNU Guile (not very common) F# (requires .NET and is statically typed) Purescript (but requires JavaScript)
Syntactically F# would be the best alternative and with fsx files Scripting is as simple as in Python. And because of the great type inference it might be as easy as Python. The only obstacle is the requirement for .NET.
21
u/lpil May 29 '25
I'd probably vote for Scheme.
24
u/revslaughter May 29 '25
Python is installed because many packages use it as a dependency. Likely some of the software that comes with your distribution uses python, so it must be installed.
Python is also a scripting language — it’s probably best if that role is kept imperative imo.
Rust is a “newcomer” that is not purely functional, but you might like Ocaml as well. I dunno what would come closest to a dynamically typed functional language though
20
u/Winchester5555 May 29 '25
Babashka for interpreted clojure.
8
u/EdgyYukino May 29 '25
Roc is kinda meant for scripting, I guess.
4
u/ab5717 May 29 '25 edited May 29 '25
So I can think of something that is fairly close to your criteria.
Have you tried Nushell? It is both a shell and a functional programming language. I personally love it.
Here's a link that explains the paradigm some
2
u/mister_drgn May 30 '25
You want F# without .NET? That’s basically OCaml (if you can get into its module system).
2
u/Jhuyt May 29 '25
Python does support many functional patterns and I use them quite a lot, so one answer could be to just wrote functional Python?
3
u/sacheie May 29 '25 edited Jul 10 '25
Python could be the functional equivalent of Python. It's not the best at it. For one thing, its lambdas cannot include statements.
But it does have lexical scoping (kinda), generators, functools, and itertools. It's not the worst language for functional programming.
A better choice might be JS. I don't really like Node, but surely there's some other, more lightweight JS interpreter available?
9
u/DataPastor May 29 '25
There are LISPs for Python, too, so you can even use LISP as a Python substitute today: https://hylang.org/
6
u/ThreeSpeedDriver May 29 '25
Guile was sort of supposed to be this but didn’t really catch on outside of the GNU world.
6
u/Business-Decision719 May 29 '25 edited May 29 '25
I don't know if Dotnet would be an obstacle. Compiling to byte code and running in a virtual machine is... the same thing an interpreted language like Python or Lua does anyway. JVM and Dotnet just turned the virtual machine into a specified, cross platform compatibility layer.
The "obstacle" is that if you're going to prepackaged Dotnet with linux, then you don't get just F#, you also get C#, and, well, Python again because there are Python implementations for Dotnet. There's no unbalanced force pushing the user toward functional programming on Dotnet.
But the upside is that you get the Dotnet ecosystem, so maybe a sort of "batteries included" FP for the people who are choosing F#. If people want the Java ecosystem instead then maybe Clojure could be the FP Python.
(edit - fixed weird typo for "Java ecosystem")
2
u/kitsnet May 29 '25
What's wrong with functional programming in Python?
5
u/alex-iam May 29 '25
I'd argue Guile is the best choice, as it is already used in GNU Guix for that. But I doubt anything would replace Python anytime soon, though, as much more people know it.
4
u/[deleted] May 29 '25
perl is installed in all distributions
4
u/GunpowderGuy May 29 '25
Almost as many distros have racket easily available as the ones that have python easily available.
3
u/callmesun7 May 29 '25
Guile, chicken
3
u/omega1612 May 29 '25
Well, Nix has its own distro.
Nix is a functional language, lazy, dinamically typed. So it follows all your requirements.
The downside? There's also the Nix package manager. If you are already using Nix the language, why not use Nix to have reproducible builds?
For a lot of distros that would mean redundancy with its package manager... So I don't think they would like it. At that point you better use NixOs.
That and one of the major problems I have with Nix is that for a time they had a lack of documentation. I think it improved over the years, but I'm not sure of the current state of that.
3
u/Lazy-Phrase-1520 May 29 '25
u want elixir
3
u/g1rlchild May 30 '25 edited Jun 01 '25
It's hilarious that you mention F#, as I've started work on an F# compiler that yeets dotnet and the massive standard library and compiles to LLVM IR, so it will compile executables that will basically run everywhere. I'm still in the super early stages and it still requires .Net NativeAOT to build, but my plan is to get it self-hosted as soon as I can.
5
u/havetofindaname May 29 '25
Perhaps Gleam could be it: https://gleam.run/
Compiles to Javascript, and written in rust, so I assume extending it would be possible. Also interops with Beam based languages.
2
u/gigi-bytes May 29 '25
Hy is a lisp you can use to write Python
2
u/Puzzleheaded-Lab-635 May 29 '25
I'm actually not a fan of python but theres
coconut -> https://coconut-lang.org (super set of python + a tone of functional features)
hy -> https://github.com/hylang/hy (a pythonic lisp)
2
u/MaxwellzDaemon May 29 '25
The J language is very functional and runs on Linux: jsoftware.com.
2
u/DoomFrog666 May 29 '25
To add to that list: Haskell with turtle works fine too.
2
u/khorgn May 30 '25 edited May 30 '25
Nu / nushell, just work extremely well with the rest of linux's tooling
2
u/Lord_Of_Millipedes May 31 '25
python will not be replaced soon because it doesn't stand for anything it does better than everyone else but because of its massive popularity, everyone and their grandma is writing their things in python and everything is in python especially things that should not be in python.
for composting languages i consider Julia to be a significantly better version of python, but it is also tiny in community and nowhere close in ecosystem (amount not quality, python ecosystem is the sometimes worse than npm), there is also Mojo that is designed as a better python.
the de facto standard should go back to perl2
u/ganzzahl May 31 '25
I like what I've seen of Janet
2
u/Anthea_Likes May 31 '25
I would vote for scheme or guile but have you considered Lua ?
2
u/Anthea_Likes May 31 '25
I would vote for scheme or guile but have you considered Lua ?
2
u/willehrendreich May 31 '25
Fsharp is a better python
2
u/Kavereon May 31 '25
Dotnet is very useful to install anyway. And you get to write F# apps or scripts. I'd say go with F# all the way. I've used it for scripting and it just works.
2
u/voivood Jun 01 '25
It could be js if (or when) bun runtime becomes more stable to ship it to embed them in distros. I rewrote all my bash scripts to js and it works like a charm
2
u/KeretapiSongsang Jun 01 '25
can't we just go back to Perl?
2
u/maridonkers Jun 01 '25
Haskell - Shh
Shh is a library to enable convenient shell-like programming in Haskell. It works well in scripts, and from GHCi, allowing you to use GHCi as a shell. It's primary purpose is in replacing shell scripts. As such, many functions are provided to mimic the shell environment, and porting shell scripts to shh should be fairly straightforward. A simple "cargo culting" port should work in most situations, and perhaps be even more robust than the original.
https://github.com/luke-clifton/shh
2
u/nicheComicsProject Jun 01 '25
Ocaml? It can be ran in interpreted mode and wouldn't have any dependencies beyond the compiler.
2
u/Compux72 Jun 01 '25
bash holding together absolutely every single linux machine out there: am i a joke to you?
2
u/bakaspore Jun 03 '25
Guile it is then. It's not very large, sufficiently advanced (see continuation prompts) and is already being used to build a brilliant Linux distro, Guix System.
2
u/ad-on-is Jun 03 '25
While being compiled, golang might be an option. Compilation takes a few miliseconds
2
u/dude132456789 May 29 '25
I've heard of people using Haskell in the interpreted mode for Linux scripting.
2
u/deaddyfreddy May 30 '25
Babashka - a Clojure dialect that starts quickly and doesn't require JVM. I use it for all my scripting activities.
2
u/regular_hammock May 30 '25
I you want Clojure for scripting, you probably want Babashka, that would you better start up times and you'd also be ris of the JVM dependency.
2
u/Eitel-Friedrich Jun 01 '25
Decades ago Perl was the cool scripting language. There will probably come a new popular scripting language, and developers will develop their new script in the new language, and old scripts and applications will get replaced one by one (and maybe in the end rapidly to clean up the code base). It's normal....
3
u/dannuic May 29 '25
Why not bash? It's not exactly functional, but integrates into the Linux ecosystem flawlessly. I know I generally reach for bash when I need to script or automate something, and I don't have to worry about venvs or dependencies nearly as much.
0
u/Pure-Shift-8502 May 29 '25
Hard to beat python for scripting
1
u/bayesian_horse May 30 '25
Forget it. For functional programming you need a special kind of programmer.
You can use Fable to compile F# to Javascript or Python, that would be closest. But even that would be more complicated than using the System Python (for system scripting).
You can compile both F# and Scala to native code, by the way.
1
u/megatux2 May 31 '25
Should be Guile (but you know)
0
u/[deleted] May 29 '25
[deleted] — view deleted comment