Functional programming

>functional programming

Is it just a meme? I took a course on Haskell and I don't see why anyone would want this. Sure, some highly artificial recursion problems might be possible to write more compactly in Haskell, but in the end it's just eye candy and not very efficient. The alleged "mathematical beauty" vanishes quickly when you realize that you cannot even work with user inputs without having to do weird and unintuitive stuff with monads.

So what is the actual purpose of functional programming paradigm? Is it just a toy or are there any applications where it is to be preferred over imperative languages?

Other urls found in this thread:

news.ycombinator.com/item?id=7957193
news.ycombinator.com/item?id=9605926
flyingfrogblog.blogspot.com/2010/05/why-is-haskell-used-so-little-in.html
timyang.net/programming/c-erlang-java-performance/
github.com/circleci/frontend
clojure-toolbox.com
clojars.org
lighttable.com
github.com/LightTable/LightTable
cs.cornell.edu/courses/cs6110/2010sp/lectures/lec18.pdf
en.wikipedia.org/wiki/Expressive_power_(computer_science)#Expressive_power_in_formal_language_theory
myredditnudes.com/
twitter.com/SFWRedditImages

FP is considered "more mathematical" because schools no longer teach much about the origins of algorithms and imperative programming.

Did you know that for loops come from "for i = 1, ..., n" notation used in mathematical algorithms?

Did you know that structured programs are a kind of regular expression?

The average FP shills you see on Hacker News and Reddit know little about math and how it relates to programming.

news.ycombinator.com/item?id=7957193
news.ycombinator.com/item?id=9605926

Pro-FP shills are total morons, to put it lightly. To think they paid (or taxpayers paid) for this "education."

>news.ycombinator.com/item?id=9605926

very entertaining, thanks

>posting actual tech or something interesting on Sup Forums
45 replies then sage, or maybe 13

>Haskell

Functional Programming is something everyone should learn because it teaches modularity and seeing all programs as simply inputs->processing->outputs

However, building a polished version of pacman with sounds and flashy particles for example in a functional language is unintuitive because usually have to reach back into various systems to manage game state, perform effects, play sounds, solve collisions with world, etc. while operating inside various entities such as ghosts or pacman.

i thought you were talking about the arch pacman for a sec.

Arch users i tell you

Every computer langauge is just "eye candy", even assembler translates it into machine code first.

Also functional languages are often blazing fast, need very little code and teach you a cool way of thinking.

>Also functional languages are often blazing fast
flyingfrogblog.blogspot.com/2010/05/why-is-haskell-used-so-little-in.html

>Is it just a meme
Yes, a shitty one

Of course you have to pick a task that's apropriate..

>timyang.net/programming/c-erlang-java-performance/

>structured programs are a kind of regular expression
What do you mean by structured programs? Because IIRC, the grammar of a programming language is often context-free (and not regular)

If you want practical, try something that isn't Haskell. Something like Clojure or F#.

Haskell is purely functional, you absolutely cannot work with I/O without all kinds of functionally pure declarations and structure. But I/O is EVERYTHING. Making anything useful in computing that isn't a scientific simulation involves reading in data and pushing out data.

Clojure and F# are impure. They realize that the best things about functional programming are getting rid of OO and all the other abstraction cruft, passing functions around as data and using high-order functions, and representing data with simple data structures like lists and maps. Want to write a function that returns all the elements in a DB table that match some predicate? F# uses LINQ mobadically, which makes it super easy. In Clojure, just call a SQL query through jdbc. No fucking trouble.

Watch some Rich Hickey talks rather than some wankery by Haskell wackadoos. And learn Clojure or some other Lisp while you're at it, it's quite enlightening.

Sorry, LINQ is monadic.

And yes, those data structures should be immutable. Understanding data manipulation as transformations of one data structure into another through functions makes a whole lot more sense than allocating cubby holes and fishing around for shit inside them.

Even things like games make way more sense when each frame has an associated game state, and the next frame's state is a function of the previous state plus inputs. Shame the game industry is so dogmatically tied to C++.

Working with pure functions has huge advantages for parallelization and you can basically get free* memoization.

(*as free as applying a decent hash function across the argument list)


I don't follow why I/O is everything. It seems to me that most programs get input somehow, do computation, and produce output somehow. I/O is the least important part here. The computation is where anything interesting happens.

Uses of haskell are very limited, and typically within AI and science.

It's fairly good for writing bespoke algebraic solvers, for example.

> (OP)
>Every computer langauge is just "eye candy", even assembler translates it into machine code first.
Do you know how I spot people who attend shitty universities/universities with poor undergrad students?
Languages are not eye candy. The fact that you can translate a language to machine code does not take away the fact that they are languages by themselves. You could have programming languages without a computer.
What is interesting about them is their expresivity, not their capacity to be interpreted by a computer.

>their expresivity
They're all Turing-complete.

The kind of algorithm to use depends on the kind of problem you're solving.

One part of your program might profit from functional programming style while others profit from imperative or object oriented style. That's why all modern languages are multi paradigm.

Doesn't mean that they have the same expressiveness. Base 10 is more expressive than base 2.

SO should I learn Scala because it is has both FP and OO?

You probably won't become a worse programmer by learning another language.

I wouldn't waste my time. It's only a decent OO language and not a very good functional language.

If you're gonna go for a functional JVM language, just learn Clojure.

What's some good open source clojure program?

>Base 10 is more expressive than base 2.
no

Um...to contribute to? To use? Give me some intent here.

To understand how clojure programs are actually written beyond tutorials.

expresses same information in less space
by definition, more expressive

if binary were more expressive, mathematicians would be using it in their proofs to make them more readable

hint, they are not.

how about github.com/circleci/frontend
real program in production use, built using clojure/script

Clojure isn't really old enough to have a ton of open-source user-facing applications, but it has absolutely tons of open-source libraries.

clojure-toolbox.com
clojars.org

However, Lighttable is a good start.
lighttable.com
github.com/LightTable/LightTable

Most of what's being done in the language now is proprietary internal data and web applications at early-adopting corporations and startups. For locally-run, user-facing applications with buttons on a screen, most of that is going to be ClojureScript with Electron or some other windowing library, like LightTable.

I think that's a bad example desu
FF is shorter than 255, but as humans we tend to prefer the second one because that's what we're exposed to more often

>by definition, more expressive
This is not what that word means at all.

what does it mean to you?

cs.cornell.edu/courses/cs6110/2010sp/lectures/lec18.pdf

en.wikipedia.org/wiki/Expressive_power_(computer_science)#Expressive_power_in_formal_language_theory

The fact that you've defined a word in a particular way can't teach you anything about the world, only observations can. Therefore arguing by definition is futile. Worse still, the dictionary definition of a word doesn't even begin to capture the rich cognitive content that actually constitutes its meaning; the dictionary, defining a word in terms of other words, can only serve as a helpful pointer to what most people mean when they use a word. Better to keep the focus on the facts of the matter and trying to understand what your interlocutor is trying to communicate, then to get lost in a pointless discussion of definitions, bearing nothing.

Dude, we're not talking about poetry or philosophy here, we're talking about computer science. CS is a formal science and thus has rigorously defined terminology.

you're being a pedant
the page you linked even mentions the informal definition which is being used here

>words mean different things in different contexts
I know, it's hard not to be an autist when you've some limited knowledge of a topic. You want to show off after all.

That doesn't mean that you have to do it in this thread and embarrass yourself by making us think that you were unable to realize that, when user wrote
>What is interesting about them is their expresivity, not their capacity to be interpreted by a computer.
you didn't realize that he wasn't using the definition of "expressivity" used in formal language theory.

>John Carmack is a moron

>he doesn't think philosophy and computer science are intrinsically related