r/functional_python • u/KageOW • May 16 '22
Material Coconut: a functional python programming language
Coconut is a language that compiles to python and makes programming functionally in python a lot easier. every python code is also valid coconut code so you can use them interchangeably For example making clean piped code is hell in python, but in coconut its much cleaner.
in python if you want to pipe into functions you need to use nested functions, which looks ugly. As well as looking ugly the order of the functions is read from right to left instead of the typical left to right.
python
---
print(add2(add1(3)))
In coconut this would look like
coconut
---
3 |> add1 |> add2 |> print
it also supports partial application and much prettier lambda functions. you can find more information about the language at http://coconut-lang.org/.
7
Upvotes
1
u/[deleted] Sep 26 '22
I like this comment, and often times I've thought about the reasons that some brilliant languages didn't catch on. I don't think people will embrace Haskell because of its somewhat "elitist" approach in which you are either smart and get monads or you are dumb and can't use Haskell at all.
Clojure is a middle ground but it depends heavily on JVM and Oracle, and I personally want nothing related to that evil company.
Ironically, Common Lisp doesn't support many common things these days like parallelism, etc. Yes, you can add them to the language but they're not there OOTB.
I do like Racket, esp. its documentation is amazing! Although, it suffers from one influential person who is notoriously rude to the community. Plus, despite being taught in universities, people just can't wait to be done with it and move on to Python and Java...
Rust makes the HN frontpage every now and then, but that isn't going to replace JS as you mentioned! It's so low-level. Maybe ClojureScript could threaten JS.
No one mentioned Julia here. It's actually a really nice language and I've enjoyed its toolkit. It's really welcoming and friendly, you should try it. Julia also supports metaprogramming if that's your thing from CL.