News for hackers. Stuff that matters.
Re:Hasp: An S-Expression to Haskell Compiler by TheBoff on Saturday February 25, 2012 @08:49PM (#3634510)
"Syntactic sugar on the lambda calculus" is just silly, really. I wish people would stop saying this. It's like saying imperative languages are syntactic sugar on Turing Machines.

This is a bit of a pet peeve for me, really. It seems like an unnecessary pithy dismissal of computation theory.

Re:Hasp: An S-Expression to Haskell Compiler by DanWaterworth on Sunday February 26, 2012 @03:32AM (#3635155)
I disagree, it's not like saying "imperative languages are syntactic sugar on Turing Machines" at all.

Haskell compilers generally compile in the following way:

text -> tokens -> AST -> lambda calculus variant -> abstract functional machine code -> imperative IR -> machine code

the AST to lambda calculus variant step is a single step. It takes the Haskell representation of the lambda calculus and outputs lambda calculus.

Contrast this with an imperative compilation:

text -> tokens -> AST -> imperative IR -> machine code

The imperative IR may be LLVM IR. LLVM IR is almost a first order functional programming language, it is certainly not machine code for a turing machine. So imperative languages are not syntactic sugar of a turing machine, there is no desugaring step in the pipeline (except maybe when building the AST).

Re:Hasp: An S-Expression to Haskell Compiler by lubutu on Sunday February 26, 2012 @07:58AM (#3635526)
And what of Lisp, of which most dialects have mutable state? If a Lisp compiler would convert to genuine λ-calculus it would be as large a step as it would for C.
Re:Hasp: An S-Expression to Haskell Compiler by DanWaterworth on Sunday February 26, 2012 @12:52PM (#3636146)
If you would re-read my comment, you'll find that I didn't actually say I agree that all functional languages are syntactically sweetened lambda calculus, though I certainly said Haskell was.

My point was that although there are functional languages that are syntactic sugar over the lambda calculus, I don't know of any imperative languages (and in fact it would not make sense to design an imperative language) that is syntactic sugar over turing machine code.

I should have made my position clearer. I do agree that compiling any non-pure functional language via lambda calculus is a fruitless endeavor.

Re:Hasp: An S-Expression to Haskell Compiler by lubutu on Saturday February 25, 2012 @11:37PM (#3634841)
Especially since they aren't. GHC Haskell, for example, is essentially syntactic sugar for System FC, not λ-calculus.
Re:Hasp: An S-Expression to Haskell Compiler by DanWaterworth on Sunday February 26, 2012 @03:13AM (#3635130)
And system FC is... a polymorphically typed λ-calculus.
Re:Hasp: An S-Expression to Haskell Compiler by TheBoff on Sunday February 26, 2012 @05:33AM (#3635304)
Possibly we just a have a different idea of what a lambda calculus is: I was thinking of Church's untyped lambda calculus, which is a much weirder beast than System FC.
Re:Hasp: An S-Expression to Haskell Compiler by DanWaterworth on Sunday February 26, 2012 @12:40PM (#3636122)
Even if you restrict lambda calculus to mean untyped lambda calculus, it's common practice to discard the types once type-checking has completed and continue the compilation without them.
Re:Hasp: An S-Expression to Haskell Compiler by Locke1689 on Sunday February 26, 2012 @05:36PM (#3637033)
That was a joke -- calling all functional languages syntactic sugar on λ-calculus is just as ridiculous as calling everything with S-expressions lisp. Sorry, sarcasm doesn't translate well over the Internet.