[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
>functional programming Is it just a meme? I took a course
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 41
Thread images: 3
File: 1437516593399.jpg (85 KB, 417x597) Image search: [Google]
1437516593399.jpg
85 KB, 417x597
>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?
>>
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.

https://news.ycombinator.com/item?id=7957193
https://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."
>>
>>54582684

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

very entertaining, thanks
>>
>posting actual tech or something interesting on /g/
45 replies then sage, or maybe 13
>>
File: Capture.jpg (114 KB, 1056x886) Image search: [Google]
Capture.jpg
114 KB, 1056x886
>>54582435
>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.
>>
>>54583133
i thought you were talking about the arch pacman for a sec.

Arch users i tell you
>>
>>54582435

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.
>>
>>54583326
>Also functional languages are often blazing fast
http://flyingfrogblog.blogspot.com/2010/05/why-is-haskell-used-so-little-in.html
>>
>>54582435
>Is it just a meme
Yes, a shitty one
>>
>>54583654

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

>http://timyang.net/programming/c-erlang-java-performance/
>>
>>54582684
>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)
>>
>>54582435
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.
>>
>>54583877
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)


>>54583877
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.
>>
>>54582435
Uses of haskell are very limited, and typically within AI and science.

It's fairly good for writing bespoke algebraic solvers, for example.
>>
>>54583326
>>>54582435 (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.
>>
>>54584127
>their expresivity
They're all Turing-complete.
>>
>>54582435
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.
>>
>>54584163
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?
>>
>>54584246
You probably won't become a worse programmer by learning another language.
>>
>>54584246
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.
>>
>>54584321
What's some good open source clojure program?
>>
>>54584214
>Base 10 is more expressive than base 2.
no
>>
>>54584337
Um...to contribute to? To use? Give me some intent here.
>>
>>54584401
To understand how clojure programs are actually written beyond tutorials.
>>
>>54584369
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.
>>
>>54584412
how about https://github.com/circleci/frontend
real program in production use, built using clojure/script
>>
>>54584412
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.

http://www.clojure-toolbox.com
https://clojars.org

However, Lighttable is a good start.
http://lighttable.com
https://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.
>>
>>54584476
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
>>
>>54584476
>by definition, more expressive
This is not what that word means at all.
>>
>>54584641
what does it mean to you?
>>
>>54583857
http://www.cs.cornell.edu/courses/cs6110/2010sp/lectures/lec18.pdf
>>
>>54584675
https://en.wikipedia.org/wiki/Expressive_power_%28computer_science%29#Expressive_power_in_formal_language_theory
>>
>>54584702
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.
>>
>>54584764
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.
>>
>>54584810
you're being a pedant
the page you linked even mentions the informal definition which is being used here
>>
>>54584810
>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 anon 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.
>>
>>54582684
>John Carmack is a moron
>>
File: 1388562866514.jpg (108 KB, 788x444) Image search: [Google]
1388562866514.jpg
108 KB, 788x444
>>54584810
>he doesn't think philosophy and computer science are intrinsically related
Thread replies: 41
Thread images: 3

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.