Hacker News new | past | comments | ask | show | jobs | submit login

The crippled nature of Python's lambdas are a big weakness of Python. They sit in a no-mans land of providing half a solution but being too crippled to actually to clarity / improve programming style.

I much prefer languages that go all the way and give you full integration like Ruby, ES6 and Groovy. For example, in Groovy closures just blend completely into the language:

    [1,2,3,4,5].grep { it > 3 }.collect { it * 5 }
Compare to python is almost incomprehensible:

    map(lambda y: y * 5, filter(lambda x: x > 3, [1,2,3,4,5]))
But breaking this into functions reduces to an almost silly level of verbosity. Of course, idiomatic python would write this as a list comprehension, but that is just proof that the lambda construct is broken, and the list comprehension is a band-aid and doesn't scale up to more complex scenarios.



Your Apache Groovy example doesn't work in Jenkins Pipelines, which cripples Groovy so the functional methods such as `collect` don't work.

You wrote elsewhere that

> I won't miss Grails because I think that, a bit like Gradle, it is an antipattern use of Groovy - needlessly applying its dynamic features where they are not even required

Groovy was designed as a dynamic language to complement Java. Its static compilation was tacked on much later, whereas Kotlin and Scala, like Java, were designed to be statically typed from the ground up, and they, unlike Groovy, also run on other platforms besides the JVM. If you're not going to use Groovy's dynamic features, you might as well use Java, Kotlin, or Scala.


    [x*5 for x in [1,2,3,4,5] if x > 3]
Though yes, I agree that lambdas in python are crippled. Maybe because list comprehension exists which replaces most uses of lambda, its just that they forgot about all other uses.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: