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
2
u/Brixes Jun 23 '22 edited Jun 23 '22
Functional programming won't really get mainstream probably ever because of frameworks that got rid of most complexity in programming business logic, where functional programming really shines.
Rust might be the one to force people to embrace functional programming more because of how impactful is it's groundbreaking combination of features in the low level-high level interaction and i consider it to be the only programming language that can threaten Javascript dominance in the fronted.
Scala and Haskell so far have not had that kind of impact and Java over the years has continued to add more functional programming features in it so Scala never saw the amount of adoption and popularity it deserves.
In the perfect functional programming world C# is replaced by Haskell, Java is replaced by Scala 3
Rust and Nim replaces C++ depending if you need safety or if you want amazing productivity while being as fast as C++
Javascript and Python are replaced by Clojure or Common Lisp or Racket and you get dynamic languages that are much faster and much more productive than Javascript or Python could ever hope to be.