Live data from Hacker News

Coconut: Simple, elegant, Pythonic functional programming

coconut-lang.org

1–10 of 65 posts

Re: Coconut: Simple, elegant, Pythonic functional programming

#3
OMG there are multiline lambdas!!! https://coconut.readthedocs.io/en/master/DOCS.html#statement...

But trying it out, it doesn't even look like python anymore. Especially if you want to nest them a lot like in other callback heavy languages. It requires a lot of semicolons and parens to get past the parsing ambiguity problem: https://stackoverflow.com/questions/1233448/no-multiline-lam...

    # Incorrect, the lambda returns (y, [1,2,3]) here!
    map(def (x) ->
          y=x+1;
          return y
    , [1,2,3])
    
    # Right
    map((def (x) ->
          y=x+1;
          return y
    ), [1,2,3])

Re: Coconut: Simple, elegant, Pythonic functional programming

#5
This is cool stuff, but it's kind of sad that Python doesn't have any of this stuff.

Apparently the Pythonic way to do anything is to repeat yourself, type a lot, implement flatten yourself, and cripple lambdas so no one will want to use them.

It's a shame, because there's no reason why Python couldn't be an acceptable language for FP, like Julia. It'll never be great at it of course (just like Julia), but good enough that when I'm doing some ML/stats work in Python, I don't have to rip my hair at because of all the imperative stuff I'm practically forced to do.

Python still feels very much like a 90s programming language, except for maybe the async syntax. I'm not sure what exactly went wrong with the development, but the dev team needs to start shaping up or Python risks becoming completely obsolete in the next 5 or 10 years.

People might say it's hard to develop a language or whatever, but just look at Julia. Superior in every way imaginable and a much younger language. I've mostly switched over to Julia except for some legacy Python ML projects, and can confidently say there's no reason at all to start a new project in Python.

The Python dev team needs to do something drastic if they want Python to survive. They've been slowly boiled alive by conservatism and a host of missteps. I doubt they'll do anything to save Python, but I hope they at least try. Implementing some Coconut features would be a great start.

Re: Coconut: Simple, elegant, Pythonic functional programming

#6
post #5

This is cool stuff, but it's kind of sad that Python doesn't have any of this stuff. Apparently the Pythonic way to do anything is to repeat yourself, type a lot, implement flatten yourself, and cripple lambdas so no one will want to use them. It's a shame, because there's no reason why Python couldn't be an acceptable language for FP, like Julia. It'll never be great at it of course (just like Julia), but good enoug…

I think "whitespace matters" and Python's quite uninspired way of writing procedure calls make it difficult to really innovate in the syntax area, without breaking backwards compatibility and without causing ambiguity.

Re: Coconut: Simple, elegant, Pythonic functional programming

#7
post #5

This is cool stuff, but it's kind of sad that Python doesn't have any of this stuff. Apparently the Pythonic way to do anything is to repeat yourself, type a lot, implement flatten yourself, and cripple lambdas so no one will want to use them. It's a shame, because there's no reason why Python couldn't be an acceptable language for FP, like Julia. It'll never be great at it of course (just like Julia), but good enoug…

Functional is my preferred paradigm. I do a lot of work in Python, too, and often find myself rubbing up against Python's less-than-complete support for FP. That being said, I am quite happy that Python does not have most of this stuff. It's good for a language to pick a paradigm, and stick to it. Trying to be all things to all people is the best way to grow a good language into a great big mushball.

Python, for its part, is, first and foremost, a procedural imperative language. With some facilities for object-oriented and functional programming, yes, but its heart and soul are procedural. And, unless we're all ready for a backward-compatibility crisis that's even worse than 2->3, that's not changing any time soon. And that's fine. Despite it not being a paradigm that anyone has considered particularly sexy for a good 30 years now, for the problem domains where Python is most successful, procedural programming is a perfectly good way to work. Perhaps even the ideal one.

If that means that Python doesn't remain one of the world's most popular languages for the foreseeable future, that's fine. I'd honestly rather switch to a new clean language every so often than get stuck permanently on a Frankenstein's monster cobbled together from all of the most popular programming language design trends from every decade of my life. That said, I don't think that Python's existential peril is quite as great as you're making it out to be. It's got a truly impressive amount of staying power. I've spent a good two decades now watching this language repeatedly survive its own death.

Re: Coconut: Simple, elegant, Pythonic functional programming

#8
post #5

This is cool stuff, but it's kind of sad that Python doesn't have any of this stuff. Apparently the Pythonic way to do anything is to repeat yourself, type a lot, implement flatten yourself, and cripple lambdas so no one will want to use them. It's a shame, because there's no reason why Python couldn't be an acceptable language for FP, like Julia. It'll never be great at it of course (just like Julia), but good enoug…

About FP in Python I always feel like trying and I do make use of some of the ideas, like avoiding a lot of mutation, but the lack of TCO then makes me feel "Meh … it's not so nice actually.". No TCO is in my opinion a huge bummer when trying to do FP.

Re: Coconut: Simple, elegant, Pythonic functional programming

#10
post #5

This is cool stuff, but it's kind of sad that Python doesn't have any of this stuff. Apparently the Pythonic way to do anything is to repeat yourself, type a lot, implement flatten yourself, and cripple lambdas so no one will want to use them. It's a shame, because there's no reason why Python couldn't be an acceptable language for FP, like Julia. It'll never be great at it of course (just like Julia), but good enoug…

Python is likely to get pattern matching in 3.10, at least: https://www.python.org/dev/peps/pep-0622/
Post reply on HN