Live data from Hacker News

Why I Prefer Functional Programming

haskellforall.com

121–129 of 129 posts

Re: Why I Prefer Functional Programming

#121
I have looked around and determined that the only Haskell program I have ever used is Pandoc.

To first order, Haskell users self-select as uninterested in writing useful programs. Anybody who would like Haskell to be seen as a language that is useful for writing useful programs would better publish programs in Haskell that do useful things than explain what they like about monads.

I can confidently advise against choosing to add to the list of IRC clients, window managers or greps, or stuff only Haskell coders use. A program that does something no other program does, as pandoc does, that is badly needed, as pandoc was, would be the best choice.

A second course would be to find ways to make Haskell code run fast without need to jump through hoops that corrupt the design of the program. (It might be that it is too late for Haskell to move in this direction.) There appears to be room in the world for slow languages (Python, PHP), so slowness is not deadly, but it does limit a language's appeal. Haskell doesn't need that. Prima facie, Haskell should not need to be slow.

A Haskell program that generates a program in (e.g.) LLVM IR to do a useful thing quickly would serve in lieu of an actually fast program. FFTW is a fast C library for evaluating FFTs generated by an OCaml program that does not need to be very fast.

FFTW relies for its speed on a cache-oblivious array traversal order (re-)invented[0] by Todd Veldhuizen for use in a C++ template library Blitz++ that, in effect, generates programs that perform matrix operations. In Veldhuizen's library, the program was in (pretty slow) C++ template meta-language that ran during compilation of the user's program, but by generating C++ in place it produced a fast program in one step.

A Haskell or descendant not dependent on GC could find use in places where present Haskell is not welcome today.

[0] Cache-oblivious traversal was, apparently, originally invented in the '70s to speed database operations where the the storage cached in main memory ("core") was on disk and tapes, and was then mostly forgotten. It may be re-invented again, in another generation.

Re: Why I Prefer Functional Programming

#122
post #118

Earlier quoted context omitted.

You can do better, then. Read nendroids latest reply to me, and help them understand that it's the "use of statements" that makes a language imperative, not the "modification of state." I won't be responding, and they seem to think they're quite the expert in this sort of thing.

"In computer science, imperative programming is a programming paradigm that uses statements that change a program's state." The above quote is ripped straight out of wikipedia's definition of imperative programming showing that what I said wasn't a misunderstanding but an official definition. The definition of imperative programming must include mutation otherwise it's isomorphic to functional programming. Because fu…

You're correct, obviously. I'm in awe. Good for you for being right about everything. Congrats.

Re: Why I Prefer Functional Programming

#124

Earlier quoted context omitted.

> But all of computation can’t be reduced to just pure functions, which is why even Haskell has to call out to its runtime eventually. All of computation provably can, but not everything computers do, despite the name, is computation.

Computation cannot be reduced to simply functions, that’s why we need something like the lambda calculus to express computation. There are functions within the calculus, but to say that “computation is a function” is not correct.

Actually, computation, in the classic sense used by Turing, Church, and other pioneers, refers to evaluating the value of (mathematical) functions. The word computation first appears in the earliest papers of the field which would later become computer science referring to "computable functions", which refers to functions which can be evaluated by a mechanical process. Hence saying "not everything computers do is computation".

Re: Why I Prefer Functional Programming

#125
post #113

Earlier quoted context omitted.

>Mutable state means imperative instructions. It does not. I don't know where you got that idea, or why you just keep repeating it, but at this point your thoughts on the matter aren't worth reading, so lets consider this discussion tabled. I won't be reading anymore of your posts on it. Everything I said in my last post is basic, well-understood computing knowledge. If you want me to disagree with it, you need to fi…

Personal attacks are against site rules on HN. You are clearly across the line here. Moderators ban people for repeated violations, so if you want to continue here, you should stop posting abuse.

Case in point, This guy turned what was just fact checking into something personal. See, it's not about being civil. That's just the way people like to think they are. The reality is most people can't accept being wrong and they can't accept opinions they disagree with and the irony is everyone believes they're above this base behavior.

No one is above it.

Re: Why I Prefer Functional Programming

#126

Earlier quoted context omitted.

You've been here for over 10 years, under various accounts, but you don't know that people can't downvote direct replies? Not quite sure I believe that.

Welp most of my accounts don't have much karma to even downvote. I have some that went past 800 but I abandoned them because I like to tell people how I disagree.

We've banned your accounts in this thread because of offtopic flaming and personal attacks, and because you used sockpuppets. Not cool.

Would you please stop creating accounts to break HN's guidelines with?

Re: Why I Prefer Functional Programming

#127
post #126

Earlier quoted context omitted.

Welp most of my accounts don't have much karma to even downvote. I have some that went past 800 but I abandoned them because I like to tell people how I disagree.

We've banned your accounts in this thread because of offtopic flaming and personal attacks, and because you used sockpuppets. Not cool. Would you please stop creating accounts to break HN's guidelines with?

Haha how about no. Why the fuck should I follow your rules when you falsely accused me of an attack. I didn't launch a single attack. Literally cite a source.

Re: Why I Prefer Functional Programming

#128
post #97
post #43

Earlier quoted context omitted.

> You can do this in any language, functional or not. No, not in practice. For example, in an average imperative language, you'd have no tail-call optimisation, and so would run out of stack space pretty quickly. There'd also be no persistent collections, meaning you'd have to keep copying any sets of values for every recursive call with absymal complexity. And so on...

Do you have any resources you'd recommend on recursion in Perl?

I liked this book https://hop.perl.plover.com/

Re: Why I Prefer Functional Programming

#129

I like FP's other "timeless" feature, you can think of the operations without respect to time, there isn't a sequence of operations, it's just a relation between the input and output. It may be described sequentially in parts but there is no mixing of output with input so can be thought of happening instantaneously. This is also the same reason why I like SQL, it describes properties of the result set--if your thinki…

You might like Prolog.

I've tried Prolog. It required thinking in both the specification correctness and it's 'search/match' execution based on how it's specified (with manual path cuts inserted as needed) much more so than these FP languages. Effectively writing a procedural definition non-procedurally. SQL can be like this too but is a small space/number of cases that it's not so unexpected.
Post reply on HN