The same can be done with Python lambdas: >>> ZERO = lambda f: lambda x: x >>> FIVE = lambda f: lambda x: f(f(f(f(f(x))))) >>> to_int = lambda f: f(lambda x: x+1)(0) ... etc.
https://raw.github.com/sdiehl/church-numbers/master/church.p...
11–20 of 55 posts
The same can be done with Python lambdas: >>> ZERO = lambda f: lambda x: x >>> FIVE = lambda f: lambda x: f(f(f(f(f(x))))) >>> to_int = lambda f: f(lambda x: x+1)(0) ... etc.
https://raw.github.com/sdiehl/church-numbers/master/church.p...
Holy cow. This could have replaced ~8 weeks of my CS languages/compilers class, and I would have understood the material better at the end of it.
I especially like how he neither uses a fancy academic language which people can dismiss outright for not being practical - like Haskell. But neither do you need ridiculous amounts of boilerplate that obscures the message - like in Java. Ruby is used for real stuff and doesn't have pretentious academic baggage.
Edit: spelling.
Holy cow. This could have replaced ~8 weeks of my CS languages/compilers class, and I would have understood the material better at the end of it.
Yay, I have a new project for this weekend! For those who missed it, he has a github project at ( https://github.com/tomstuart/nothing ) where you can reimplement this yourself, with some tips to help you out. I especially like how he neither uses a fancy academic language which people can dismiss outright for not being practical - like Haskell. But neither do you need ridiculous amounts of boilerplate that obscures…
Actually that could be a good way to filter your audience. Some of those who would be least likely to appreciate this tutorial (and would be likely to post comments complaining how pointless (no pun intended) it was) would avoid a Haskell article in the first place.
I did a lightning talk at SCNA this year which covered similar, if somewhat different, and certainly less comprehensive ground, which may be of interest to readers of this thread/article.
http://git.io/objects-as-closures (full code and all everything)
https://gist.github.com/1372131#file_v2.md (outline/notes)
(please don't make fun of me, Scheme peeps)
That was pretty cool. Interesting to note that the numbers he used are essentially an implementation of the Peano Axioms, where the successor function wraps the predecessor in a lambda. ( http://en.wikipedia.org/wiki/Peano_Axioms ) Here's a simple recursively defined number system in scheme: https://gist.github.com/1466985
this is the definition of a turing tarpit.
Holy cow. This could have replaced ~8 weeks of my CS languages/compilers class, and I would have understood the material better at the end of it.
I see it as a kind of entertaining academic game - a Glass Bead Game, if you will, and I intend the deep allusion - but I wouldn't put too much faith in it teaching you much about the mechanics of compilers. It's one way of decomposing semantics into more simple elements, but it's not the one chosen for almost all practical languages, which after all have to execute on silicon, not in the Lambda calculus.
It doesn't teach anything about parsers, and nor does it exercise much thinking in trees. It does emphasize recursion, but in a way that makes it seem like an absurd roundabout way of doing things, rather than something that more usually simplifies the expression of a program. Above all, it doesn't really demystify how the text of your program changes the coloured lights on your screen. It's a splendidly constructed wonderland, a pyramid of abstraction with nothing but function application at its core, but I don't think it leaves you with a lot more than a sense of having seen something very clever.
(FWIW, nothing in the presentation was new to me, so any residual sense of wonder has faded. Take that into account in my perhaps cynical judgement.)
Holy cow. This could have replaced ~8 weeks of my CS languages/compilers class, and I would have understood the material better at the end of it.
I don't know. I see it as a kind of entertaining academic game - a Glass Bead Game, if you will, and I intend the deep allusion - but I wouldn't put too much faith in it teaching you much about the mechanics of compilers. It's one way of decomposing semantics into more simple elements, but it's not the one chosen for almost all practical languages, which after all have to execute on silicon, not in the Lambda calculu…
I would argue that there's a big difference between "demystify how the text of your program changes the coloured lights on your screen" and "demystify why the text of your program changes the coloured lights on your screen". if you are interested only in the first question, you might be an engineer. if you are also interested in the second question, you might be a computer scientist...
Earlier quoted context omitted.
Yay, I have a new project for this weekend! For those who missed it, he has a github project at ( https://github.com/tomstuart/nothing ) where you can reimplement this yourself, with some tips to help you out. I especially like how he neither uses a fancy academic language which people can dismiss outright for not being practical - like Haskell. But neither do you need ridiculous amounts of boilerplate that obscures…
> a fancy academic language which people can dismiss outright for not being practical - like Haskell Actually that could be a good way to filter your audience. Some of those who would be least likely to appreciate this tutorial (and would be likely to post comments complaining how pointless (no pun intended) it was) would avoid a Haskell article in the first place.
I think this tutorial shows what we really mean about Turing equivalence in languages, about how data structures can be represented as functions, and presents a wider point of view that opens up other possible program designs.