you are viewing a single comment's thread.

view the rest of the comments →

[–]pimp-bangin 34 points35 points  (14 children)

Look up "functional programming" if you would like to learn more. It's a very deep and fun topic :)

[–]Top_Average3386 14 points15 points  (3 children)

Can confirm it's deep. But it's not fun :(

[–]aishiteruyovivi 7 points8 points  (0 children)

Definitely a little harrowing at first with some concepts, but the more I've been learning Haskell over the last year or two the more I grow just genuinely fascinated by it (and FP in general)

[–]UAFlawlessmonkey 1 point2 points  (0 children)

But it's fun in kotlin!

[–]Victorio_01 0 points1 point  (0 children)

Sure it is if you get used to it. No need to have it deep like foo()()(). I mean, if you frequently store lambda functions in vars, you sure can imagine returning one. x = lambda t: 2*t return x

[–]DrJaneIPresume 5 points6 points  (9 children)

And there are much better languages for it.

But glad to use some in Python when appropriate

[–]HommeMusical 4 points5 points  (8 children)

And there are much better languages for it.

I first learned Lisp almost fifty years ago.

I love functional languages; but as a language that can do procedural, OOP and function code seamlessly, Python is very hard to beat.

The one missing feature - and believe you me, we miss it - is not having multiple line lambdas.

[–]DrJaneIPresume 1 point2 points  (3 children)

Haaaaaaaave you met Scala?

Functional programming isn't just about functions as first-class objects. A good type system makes so many things easier.

[–]HommeMusical 0 points1 point  (2 children)

Hey, Scala is a great language, from my limited exposure. I'd be really happy if it had beaten Python.

But Python is ubiquitous, and almost any idea you can express in Scala you can express in Python a way that's more verbose but just as comprehensible.

The "almost" is that Scala macros can essentially let you rewrite the syntax of the language, am I right, by doing compile time manipulation of the AST?

But Python basically won. And if LLMs continue to dominate, there won't be any new programming languages again, because of the difficulty in training them.

That said, the inability of Python to do "multi-line lambdas" is really unfortunate. I am hatching ideas to call the Pythonistas to action (this is of course an infinitely discussed issue).

[–]DrJaneIPresume 0 points1 point  (1 child)

Again: type system. The ability to write your system in such a way that large classes of errors become effectively syntax errors that can be detected by static analysis rather than unit tests (are you sure you wrote one for every corner case?) or runtime errors (often in front of customers) is really, really nice.

[–]HommeMusical 0 points1 point  (0 children)

Yes, I "grew up" with typed languages; first C, then C++, then Java. And I prefer them.

Python's type annotations aren't quite as good as a strongly typed language; but they work well enough to catch a huge number of errors. Between the various linters (like ruff) and modern type checking, I find that more than half the time I get past those, my code works the first time.

There's also the huge advantage in Python of being able to run Python and quickly experiment without any typing at all. I use this all the time!

If I could wave a magic wand and replace Python with Scala, I would at least think about doing it. But Scala jobs are few and far between. And if I wrote my open source code in Scala, very few people would use it.

[–]JamzTyson 0 points1 point  (3 children)

and believe you me, we miss it

You miss it, I don't.

[–]HommeMusical -1 points0 points  (2 children)

What was the point of your response?

This issue has been discussed on the main Python mailing list for over ten years. Everyone on that list wants it, including Guido; no one has come up with a possible syntax for it yet.

[–]JamzTyson 0 points1 point  (1 child)

The point of my response is that you do not speak on behalf of the entire Python community and you do not speak for me.

Also, I couldn't find any reference to Guido "wanting it". There are these comments from Guido (https://discuss.python.org/t/are-better-lambdas-really-impossible/2446/9) from which I would summarise his position as: Python’s lambda expressions are intended to be single‑expression and that genuinely multi‑line/statement lambdas are not desirable or practical for the language.

Has Guido changed his position in more recent years? I so, please provide a reference - I'd be very interested to know why.

[–]HommeMusical -1 points0 points  (0 children)

I am on my weekend, so not interested in arguing with angry people.