4 ms·
So in Python, imperative style is often more idiomatic than code that uses lambda expressions. While in some functional languages (Haskell) and array programmi
by dancek 8y ago
So in Python, imperative style is often more idiomatic than code that uses lambda expressions.
While in some functional languages (Haskell) and array programming languages (J), tacit or point-free style is often more idiomatic than lambda expressions (or equivalent).
There's something funny about that.
- jjnoakes 8y agoMany of the suggested alternatives to lambdas in the article are non-imperative though... they just don't use 'lambda'.
- dancek 8y agoCertainly, and I do agree with most of the article. But the instances where lambdas are better replaced with an ordinary function don't use a different programming paradigm. My observation was about how different communities consider different paradigms idiomatic in situations where you get to choose.
- dan-robertson 8y agoI somewhat agree but I think there are two things wrong with tacit style in Haskell: 1. It is usually taken too far (indeed I think flip is probably too far and (.).(.) is certainly too far. I’m also not a big fan of eg fmap.fmap) 2. (.) is the wrong way round. Code reads much better if it has type (a -> b) -> (b -> c) -> (a -> c) In APL or J was I don’t have enough experience to say other than that I find it difficult to read but the puzzle is amusing
- dancek 8y agoThat comes down to what code is easiest to read, and that is different for different people. If playing with the APL family has taught me something, it's that what someone sees as a completely incomprehensible mess might be very readable and intuitive to another. I personally have a hard time understanding almost any point-free Haskell code and deciphering a line of J might take me an hour. But as long as it's readable to the intended audience it's alright. Of course it isn't sometimes.