Live data from Hacker News

A different view on Functional Programming

matiasmorant.wordpress.com

41–50 of 100 posts

Re: A different view on Functional Programming

#41
post #31

Most of us spend 90% of our time reading other people’s code. So even though writing a concise and elegant formula in J might be a satisfying puzzle, I personally don’t want to deal with the cognitive burden of point-free style when sifting through my colleagues’ pull requests.

When it's appropriate, point free style doesn't increase cognitive burden. It's often inappropriate.

Re: A different view on Functional Programming

#42

Earlier quoted context omitted.

Understandability is more important than conciseness in a team environment. In a team, you're not writing code for you - you're writing code to be reviewed by other people, integrated with other people's code, and maintained by other people in the future. In the example from this article, all developers I've ever worked with would understand what the "good old C" example is doing within seconds. Most would understand…

> J is even worse. I stared at the J code for a full minute without any comprehension of the language syntax or what was being accomplished. That code isn't readable or maintainable. It is bad code. But why does code need to be readable to someone who doesn't know the language? Yes, it's true that Python and some other languages are pretty readable even to people who haven't written any of that language, and that is…

To avoid silos?

Re: A different view on Functional Programming

#43
Say we changed the problem to the geometric mean of non-negative numbers (instead of positive). This allows us to early-out if zero is encountered.

It's obvious how to change the imperative code: `if (x[i] == 0) return 0;` What would this optimization look like in APL or J?

Re: A different view on Functional Programming

#44
I think the main feature of Functional programming is not avoiding side effects but abstraction. You can compose different kinds of powerful abstractions and programmers are free to choose their "language" of abstractions, compared to "X Oriented" languages that forces programmer to think in certain terms and limits in ways you can create layers of abstractions.

Re: A different view on Functional Programming

#45
post #6

((+/) % #) &. ^. is the same as (+/ % #) &. ^. because adverb (/ in this case) binds with + before three verbs +/ , % and # are grouped into the fork. So some parentheses aren't necessary. It would be cleaner to show three expressions which share the common part as similar in letters as well.

Is this software? What does it do?

Re: A different view on Functional Programming

#46
post #31

Most of us spend 90% of our time reading other people’s code. So even though writing a concise and elegant formula in J might be a satisfying puzzle, I personally don’t want to deal with the cognitive burden of point-free style when sifting through my colleagues’ pull requests.

When it's appropriate, point free style doesn't increase cognitive burden. It's often inappropriate.

Well said.

Re: A different view on Functional Programming

#47
post #10

Earlier quoted context omitted.

Hi! I appreciate your honesty. Of course arriving at the Mathematical formula is the hard part, that's what it means to actually solve the problem. I consider the fact that you can't code your solution in this style until you have done so as a feature: you can't write code if you haven't really understood and solved the problem. (As opposed to imperative style which let's you implement a half done solution with hidde…

> Of course arriving at the Mathematical formula is the hard part, that's what it means to actually solve the problem. Most business problems can't be solved with a formula, or with a thousand formulas, or with a million formulas, especially if the problem is “our organization is an illogical clusterfuck” or “we don't even know what we should be doing”. > I consider the fact that you can't code your solution in this…

To put it another way - if you don't understand the problem, functional programming helps you be wrong more concisely.

It can be helpful to look for generality and abstraction when solving problems. But it can be unhelpful to assume that general solutions and common abstractions must exist to an extent that makes a given solution more robust and efficient than a patchwork of partial solutions that explicitly handle corner cases.

Re: A different view on Functional Programming

#48
It should be obvious that if a transformation is syntactically trivial, it can only solve trivial problems. If programming is not-math, it's not going to become math just because you change the surface syntax.

A mathematician's definition of a sorted list is different to a programmer's at least in part because a mathematician is interested in a sorted list and a programmer is interested in sorting a list. This difference is intrinsically invariant of the programming paradigm (though not of the context).

This issue isn't so much that this post didn't convince me that there is an underlying, semantically relevant sense in which the APL approach is more mathematical, but that it didn't even seem to notice that this was a thing that needed to be argued.

Re: A different view on Functional Programming

#49
post #23
post #14

Earlier quoted context omitted.

A good analogy would be music notation (pentagram) I could describe a piece of music in English prose, telling you were to put your fingers and for how long. The language itself would be easier to understand, but the efficiency of information transmission would be very low. Chinese looks complicated, unless you know Chinese. The ultimate criteria to judge a language should be how efficiently (concisely) it expresses…

> The ultimate criteria to judge a language should be how efficiently (concisely) it expresses the concepts of the subject matter. Some might say that the ultimate criteria to judge a language should be how quickly an inexperienced user starts to be fluent in it. I studied math (so the syntax isn't really an issue), but I think functional programming is completely inappropriate for general purpose programming tasks (…

By that criterion a shovel is always preferable to a backhoe. Powerful tools take longer to learn.

Re: A different view on Functional Programming

#50

Earlier quoted context omitted.

Understandability is more important than conciseness in a team environment. In a team, you're not writing code for you - you're writing code to be reviewed by other people, integrated with other people's code, and maintained by other people in the future. In the example from this article, all developers I've ever worked with would understand what the "good old C" example is doing within seconds. Most would understand…

> J is even worse. I stared at the J code for a full minute without any comprehension of the language syntax or what was being accomplished. That code isn't readable or maintainable. It is bad code. But why does code need to be readable to someone who doesn't know the language? Yes, it's true that Python and some other languages are pretty readable even to people who haven't written any of that language, and that is…

Readable code decreases ramp-up time, both in a language and in a codebase. I've never written a line of Java in my life, but if you dropped me in a Java codebase I could start understanding the structure immediately and contributing to it very quickly. If you dropped me in a J codebase I'm not convinced that would ever be the case.

Writing terse readable code is great. Writing code that is so terse that it doesn't have variable names is an antipattern.

Post reply on HN