Difference between revisions of "Talk:1312: Haskell"

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search
Line 29: Line 29:
  
 
"thus Haskell may have value but no one has either invoked it to get that value or requested such a language." The point of the title text is (a joke that) programmers of Haskell are lazy, but no one tells them so. The point is not that no one uses Haskell. That is the point of the comic itself. {{unsigned ip|108.162.219.202}}
 
"thus Haskell may have value but no one has either invoked it to get that value or requested such a language." The point of the title text is (a joke that) programmers of Haskell are lazy, but no one tells them so. The point is not that no one uses Haskell. That is the point of the comic itself. {{unsigned ip|108.162.219.202}}
 +
 +
...  I am confused by the description.  Is it possible that someone can put this into "plain language" that a non-programmer and a non-mathematician can understand?  (Go ahead and add "slow" to that description, too, if you so choose...) [[Special:Contributions/173.245.54.54|173.245.54.54]] 09:11, 5 January 2014 (UTC)

Revision as of 09:11, 5 January 2014

"Thus, it is possible to have a variable representing the entire infinite list of Fibonacci numbers." Except that Haskell has no variables- nothing is mutable, as they say. You could certainly write a function that generates an infinite list of Fibonacci numbers when called (and lazily evaluated later), but it won't be bound to a variable. If it was, then the list would take up an infinite amount of memory, and lazy evaluation would be pointless.

I will, however, leave the above word "variable" in the explanation, because I can't come up with a concise way of explaining the above. --Someone Else 37 (talk) 09:07, 3 January 2014 (UTC)

"Expression?" I don't know Haskel, but that's what I would call it in another functional language. --Rael (talk) 16:31, 3 January 2014 (UTC)
That's a little imprecise, as it doesn't capture the idea of binding a value to a single symbol. 108.162.231.13 17:03, 3 January 2014 (UTC)
The sentence you quote is entirely correct... but might itself require further explanation!
  • Haskell variables aren't mutable, but they are nonetheless referred to as "variables". It's an appeal to the (earlier, after all) use of the word in maths, rather than in imperative programming languages. (No shortage of variables in algebra, geometry, calculus, topology... And no mutation involved.) One might equally say "symbol", "constant", or indeed "symbolic constant".
  • One can bind the fibonaccis to a variable (... constant, 0-place definition, etc) quite happily. In fact, that's the idiomatic way to do it, as it avoids the degenerate complexity of a naive recursive function. It's still evaluated lazily, all the same. (Meaning that it will take an infinite amount of memory... if you run it for an infinite amount of time, and never "consume" the result in any way.)
  • Equally, one can regard such top-level symbol definitions as functions with no arguments, if that's more helpful. 108.162.231.13 16:42, 3 January 2014 (UTC)
Shows what I know about Haskell jargon, even if I do know something about the language. I see what you're saying, though.
In any case, here's some Haskell code that does indeed generate an infinite list of Fibonacci numbers. It's not fast, and there's almost certainly more efficient ways to do it, but it's simple enough that people unacquainted with the language should be able to figure it out.
fibonaccis :: [Integer]		--Indicates that the function returns a list of arbitrary-length integers
fibonaccis = map fib [0..]	--Converts the infinite list [0,1,2,3,4...] into a list of Fibonaccis
    where fib n			--Defines a helper function that returns the nth Fibonacci number
              |n == 0    = 1	--The zeroth and first Fibonaccis are 1
              |n == 1    = 1
              |otherwise = (fib (n - 1)) + (fib (n - 2)) --And the rest are the sum of the previous two.
--Someone Else 37 (talk) 19:52, 3 January 2014 (UTC)

Does anyone have a clue what the Incomplete flag refers to? This seems like a pretty good explanation to me. --Mynotoar (talk) 11:22, 3 January 2014 (UTC)

Example programs written in Haskell are: pandoc, universal markup converter; git-annex, tool to manage large files in git DVCS. --JakubNarebski (talk) 11:37, 3 January 2014 (UTC)

I think the person Nealmcb who updated the incomplete tag to say " Add examples of popular Haskell programs" is boarderline trolling if not full on trolling -- Explanation looks pretty complete to me and I vote to remove the incomplete tag. Spongebog (talk) 01:59, 4 January 2014 (UTC)

"thus Haskell may have value but no one has either invoked it to get that value or requested such a language." The point of the title text is (a joke that) programmers of Haskell are lazy, but no one tells them so. The point is not that no one uses Haskell. That is the point of the comic itself. 108.162.219.202 (talk) (please sign your comments with ~~~~)

... I am confused by the description. Is it possible that someone can put this into "plain language" that a non-programmer and a non-mathematician can understand? (Go ahead and add "slow" to that description, too, if you so choose...) 173.245.54.54 09:11, 5 January 2014 (UTC)