r/functionalprogramming • • Apr 30 '24

Question Functional language to replace python

Hi all, I'm looking for some suggestions on a functional language to learn.

Some background: I write a lot of code in c# and python. I write a lot of ci/cd tooling in python or bash, and small to medium sized apps in python, and large apps in c#. For web frontends I use htmx + hyperscript. A very important feature I can use in both of these languages is templating (jinja2 / razor pages).

Presumably, I could try swapping in f# for c#, but I typically only use c# for very large apps, and I'd like something that I can start chewing on at a smaller scale. Something for ci/cd scripts, automation tasks, basic web servers, etc.

What I'm looking for in another language:

  • (obviously) the goodness that comes with functional languages, a lot of things have been making their way to c# as I understand, but I figure I might as well get it straight from the source
  • a mature templating library
  • a mature standard library
  • nice to have: static typing system
  • simple dependency definition. I like that in both of the above languages I can define my dependencies in a single human-readable file (requirements.txt or pyproject.toml, *.csproj although managing shared dependencies between csproj files is annoying)
  • simple modularity. I love how easy it is in c# to just add a separate project to a solution to keep things organized. I hate how obtuse it is to maintain the .sln file and all the namespaces. It is impossible without an IDE. python doesn't have this issue, but understanding how modules work, __init__.py and __main__.py, modules vs packages, all that stuff is so annoying. I've been enjoying Rusts module system.
  • quick and easy startup. from 0 -> helloworld in python is literally echo "print('hello world')" > hello.py. compared to the saga of booting of vs, creating a new solution, picking a name, ... that is c#.

any suggestions?

13 Upvotes

36 comments sorted by

View all comments

Show parent comment

3

u/Martinsos Apr 30 '24

I have quite good time writing small scripts with Haskell! Both Stack and Cabal have support for writing standalone script files in which you can even describe dependencies (in the comment in the header, quite neat feature).

2

u/miyakohouou Apr 30 '24

yeah, I use nix for having self-contained haskell scripts, but I figured that was probably a bit too out there to make as a suggestion

2

u/Martinsos Apr 30 '24

Yeah, using Nix would be s bit more involved. However, as I said, there is native way to do it with just Canal or Stack, no Nix is needed, so that should be quite straightforward.

Here is a quick tutorial I wrote on how to do it: https://github.com/wasp-lang/haskell-handbook/blob/master/cabal-script.md .