This obscure language represents a peculiar corner of the programming language world called functional languages. One of the peculiar things about such languages is that they don’t have variables. Although Haskell isn’t widely known among programmers, those who know of functional languages suspect that they, too, are rather slow
Name:
Anonymous2011-01-30 13:47
It needs to be said very firmly that LISP is not a functional language at all. My suspicion is that the success of Lisp set back the development of a properly functional style of programming by at least ten years. -- David Turner
LISP had its serious shortcomings: its promotion of the idea that a programming language should be able to formulate its own interpreter (which then could be used as the language's definition) has caused a lot of confusion because the incestuous idea of self-definition was fundamentally flawed. -- Edsger Wybe Dijkstra
>>11
Look at Scheme, it allows gotos (continuations), and this leads to problems, like you cant impement unwind-protect in Scheme. Funckin spaghetti. Java and C#, on the other hand, forbid continuations for security reasons.
Name:
Anonymous2011-01-30 18:25
import Control.Monad.Fix
import Control.Applicative
main = mapM_ print $ take 500 $ thor's_mother
>>1
Obvious troll. Haskell has two different kinds of variables, type variables and value variables. For example, the definition of id shows both:
id :: forall a. a -> a
id x = x
Here, "a" is a type variable. Every time you call "id", and most times you even use "id" as a value, that type variable takes the value necessary to make the program type check. This incurs no runtime penalty -- the types are stripped from the program during compilation, like most languages with static type systems.
Then "x" is a value variable. Each time you call "id", "x" has a different value. That is, it varies. Hence, variable.
Some people have the misconception that Haskell has no variables. This is like saying that "Why is it that northwestern American English speakers don't have an accent?" Of course they have accents, because an accent is, by definition, "the way they pronounce words". Because they do pronounce words, they have an accent. And because a variable is by definition "something that varies", Haskell must indeed have variables.
You just can't change the value which a variable holds, unless you're using an IORef or similar.
>>17
It wasn't a criticism ;), it's how I've seen one-shot continuations, and dynamic-wind implemented.
Name:
Anonymous2011-01-30 19:30
>>12
IMHO that's one of those idiotic CL misconceptions. You either:
1. Unwind and can't re-enter anymore, getting the same behaviour as in CL unwind-protect.
Or
2. Set a finalizer on an object and let the GC handle it, which is the right thing to do in 90% of the cases anyway.
Creating a difference between ``final'' and ``temporary'' exits really seems like a solution looking for a problem.
>>19 Obvious troll. Haskell has two different kinds of variables, type variables and value variables.
…except that neither of those are variables. They're bindings.
you seem confused. a binding is a pair (variable, value), so x = 3 is a binding of the variable x to the value 3. in haskell, once a varible has a binding then it retains that same binding for the duration of its scope, as opposed to imperative languages which let you change the value of a variable after it has entered scope.
this is why i recommend people fucking pay attention in those required cs classes like compilers/languages. there are two kinds of programmers: those who took compilers/languages and those who still think that x<<2 is faster than x*4.
Name:
Anonymous2011-01-31 5:38
>>21
>Set a finalizer on an object and let the GC handle it, which is the right thing to do in 90% of the cases anyway.
If only filesystem used immutable files and called GC, when out of disk memory.
Name:
Anonymous2011-01-31 6:16
>>24
Variable means "entity that varies". But in Haskell variables are constant, you cant setf them.
>>24
It is in ASM. Especially those ARM machines with hardware barrel shifters.
Name:
Anonymous2011-01-31 6:17
>>26
In fact, Haskell variables arent even a value cells, they're so called `thunks`.
Name:
Anonymous2011-01-31 6:19
>>28
Needless to say, that using thunks instead of variables makes Haskell slower than Ruby.
Name:
Anonymous2011-01-31 6:32
>>24 those who still think that x<<2 is faster than x*4.
"x<<n" is an idiom, which explicitly states that:
1. programmer wants fast multiplication by a power of two.
2. you will've no troubles translating this code to ASM
3. naive compiler for obscure hardware will have no troubles
4. compiling without optimizations would still produce fast code
>>35
Stop being fallacious.
Anyway, division by a number is multiplication by its reciprocal, and division by a constant can be optimised to a multiplication and a right shift.
>>26 Variable means "entity that varies". But in Haskell variables are constant, you cant setf them.
First of all, "can't" is a contradiction of "cannot" and thus requires an apostrophe. If you cant even properly grammar, how can you hope to achieve intellectual clarity of ideas?
Then, to your question: in a definition \x -> x * 2 2 is a constant, because it's value cant vary between applications of the function. While the value of x most definitely can, thats why its a variable. Clearly, reading SICP by itself doesnt make make you a better programmer.
Name:
Anonymous2011-01-31 10:52
First of all, "can't" is a contradiction of "cannot" and thus requires an apostrophe. If you cant even properly grammar, how can you hope to achieve intellectual clarity of ideas?
Autist detected.
>>39 2 is a constant, because it's value cant vary between applications of the function.
If we implement integers as mutable strings, then it can:
*&"2" = 3;
>>42
I'm not >>39, but in lambda calculus, arguments are called ``bound variables´´, extern bindings (from the outer scope) are called ``free variables´´.
In mathematics, a variable is indeed ``constant'', you don't setf them in the middle of an expression, but they can be any value, depending on what the function is called with.
Now, we all know that Haskell is for pure functional mathematical faggots, therefore it has variables, in the mathematical sense.
The bound variables/free variables thing applies also to Lisp, due to its resemblance with lambda calculus.
Name:
Anonymous2011-01-31 11:59
>>45
They are done this way in the first place. Computer circuitry manipulates bitstrings.
Name:
Anonymous2011-01-31 12:01
>>47
It needs to be said very firmly that LISP is not a functional language at all. My suspicion is that the success of Lisp set back the development of a properly functional style of programming by at least ten years. -- David Turner
Lisp owes its survival specifically to the fact that its programs are lists, which everyone, including me, has regarded as a disadvantage. -- John McCarthy
>>49
Professor David Turner is a British computer scientist.
He has a D.Phil. from the University of Oxford. He has held professorships at Queen Mary College, London, University of Texas at Austin and the University of Kent at Canterbury, where he now retains the post of Emeritus Professor.
He is currently (2004) Professor of Computation at Middlesex University, England.
He is best known for inventing combinator graph reduction and for designing and implementing three seminal functional programming languages SASL, KRC and Miranda, the last of which was awarded a medal for Technical Achievement by the British Computer Society (BCS Awards, 1990).
Name:
Anonymous2011-01-31 12:17
"SASL, KRC and Miranda" were led to invention of Haskell.