Live data from Hacker News

Why I Prefer Functional Programming

morgenthum.dev

161–163 of 163 posts

Re: Why I Prefer Functional Programming

#161

Earlier quoted context omitted.

Javascript was marketed towards Java programmers, and those languages are pretty different from each other too.

I would say that C++ is closer to Java than JavaScript is; it's fairly easy to copy-paste and edit C++ code into a Java file with, just changing a small amount of syntax and get rid of the manual memory allocations. Try copy-pasting JS into a Java file, and there are semantics there that are completely foreign; you can't simply translate it.

I agree that JS and Java are very different; that was my point.

I disagree about Java and C++. If I have a C++ file that uses RAII or references, for example, it won’t translate to Java easily. And those aren’t unusual, they’re both common techniques.

Re: Why I Prefer Functional Programming

#162
post #145

Earlier quoted context omitted.

tbh if you have the ability to easily treat functions as first class citizens in a language then it's fair enough to say you can code functionally in it. I think the attitude "X is inherently a functional language" is being replaced by the idea that there are clusters of language properties with labels like "functional" or "object-oriented" or "array-based" or whatever, and that a language may overlap with bits of va…

There's more to the admittedly fuzzy-edged concept of functional programming than function application. I'd agree with you that the feature list is more important than a vaguer title. That's something Robet Harper talks about: http://www.cambridgeblog.org/2017/05/what-if-anything-is-a-p... But the selection of features has limited value if the selection isn't coherent and the features don't compose. Within both FP an…

Thanks, this is a measured response that's made me think a little deeper and refine my opinions.

Re: Why I Prefer Functional Programming

#163
post #11

Earlier quoted context omitted.

As a lisp programmer who never wrote in Haskell the snippet you quoted is crystal clear to me, while with explicit loops I always have to double check, because I am pattern matching the code "ah, a map or reduce was meant" but I still have to double check assignments and the abort condition (off by one, incrementing the wrong index etc).

I write Lisp but I have no idea what /x means in the example above for instance.

The "\" (which is "\" rather than "/", as already pointed out) is just an ascii approximation of λ (just like "u" is used to approximate μ).
Post reply on HN