8 ms·
An Introduction to the Lambda Calculus (2015)
- dreeko_ 10y agoNo word wrap, horizontal scroll is hijacked and the content goes off screen (Chrome on Android) the topic sounds interesting but the post is unreadable
- jaybosamiya 10y agoThe Wikipedia page [1] for Lambda calculus is also a great read (even for those who don't know anything about it before). [1] https://en.wikipedia.org/wiki/Lambda_calculus https://en.wikipedia.org/wiki/Lambda_calculus
- solidangle 10y agoPersonally I prefer this introduction by Barendregt (his books on Lambda calculus are really good): ftp://ftp.cs.ru.nl/pub/CompMath.Found/lambda.pdf
- mrspeaker 10y agoGreat read - I worked through it in JavaScript in the console. Writing Scheme-ish code in JS is so much nicer with ES6 than it was with ES5! const iterativeImprove = (guess, improve, goodEnough) => goodEnough(guess) ? guess : iterativeImprove(improve(guess), improve, goodEnough); I think the example used (and the intermediate functions) come straight from SICP. I always intend to do the exercises in this book, but never have... This post actually got me to do it, so hat's off to you!
- throwaway7645 10y agoYea I immediately thought this is from SICP
- bogomipz 10y agoOn that note(SICP in Clojure) there is also this which has been mentioned here on HN before: http://www.sicpdistilled.com/ http://www.sicpdistilled.com/
- alangpierce 10y agoIf you have an Android phone/tablet and want to play around with the lambda calculus, I made an app that lets you build and evaluate expressions using a touch interface: https://play.google.com/store/apps/details?id=com.alangpierce.lambdacalculusplayground https://play.google.com/store/apps/details?id=com.alangpierc... https://www.youtube.com/watch?v=0OzpqDDniDs https://www.youtube.com/watch?v=0OzpqDDniDs It's lower-level than the stuff in the post (you need to build booleans and math yourself) and doesn't have any instructional content built-in at the moment, but I think it's a nice way to see how far you can get using only lambda expressions. The most complicated thing I've done with it is used the Y combinator (among other things) to compute 6! = 720, which is a fun exercise.
- futtetennista 10y agoVery cool idea! Is it open source or are you thinking about it?
- alangpierce 10y agoYep, it's on GitHub: https://github.com/alangpierce/lambdacalculusplayground https://github.com/alangpierce/lambdacalculusplayground I actually got mostly done porting it to React Native, but never totally finished it, so the GitHub repo is React Native and has some bugs. But you can go back in the git history to find the native Android SDK version that's currently on the Play Store.
- diyseguy 10y agoDid I find the right point in the history? https://github.com/alangpierce/LambdaCalculusPlayground/tree/e3f939c8e8c18813407b354f8a4612ce5a050211 https://github.com/alangpierce/LambdaCalculusPlayground/tree...
- alangpierce 10y agoYep, that should work. Two commits earlier is the actual 1.1.0 release, before some restructuring to make room for the React Native stuff, so that may be a little better to work with. https://github.com/alangpierce/LambdaCalculusPlayground/commit/9073725d6825cb3dd50a28e4038d2743d3d941fa https://github.com/alangpierce/LambdaCalculusPlayground/comm...
- syncopatience 10y agoDoes learning about the Lambda calculus have any take-aways for programming in modern languages, or is it more of a cool toy/mostly of interest for language designers and academics?
- Tarean 10y agoIt gives a pretty facinating point of view onto computation in general. You only the ability to define and call functions. Functions can only recombine their input. And somehow it is still as powerful as, say, python! Don't need some built in math , invent numbers using function definitions. Don't need built in recursion, just implement it using functions as the y-combinator! There are also some practical usages of the whole implement-data-as-functions idea. There are some libraries in haskell that do this, for instance, which means that the compiler can optimize dsl's.
- tikhonj 10y agoI've found understanding the lambda calculus goes a long way to understanding functional programming—in particular, it does a wonderful job demonstrating just how simple the core ideas underlying languages like Haskell are, contrary to their reputations. It's also a great way to get a deeper understanding of computation and how it relates to logic. The lambda calculus is special for being an incredibly minimal model of computation that's still expressive enough to write programs (albeit a little awkwardly). Expressing something you care about in lambda calculus is way easier than using a Turing machine directly or even programming in assembly!
- cousin_it 10y agoI think lambda calculus encodes computable functions, but not algorithms, because changing evaluation order can make you go from O(n) to O(n^2) etc. To define time and space complexity, you need to assume something like Haskell's graph reduction. That's more complicated than starting with assembly and counting steps.
- rbonvall 10y agoThe lambda calculus teaches you how to build computation from a very simple evaluation rule called "beta reduction" which is just a fancy name for "search and replace" with function parameters. If you can find a system that can rewrite terms in such a fashion, you can compute whatever you want using the tricks you learn in lambda calculus. For example, C++ templates were not meant to be Turing-complete, but they work by rewriting terms [1], so you can encode lambda calculus in it, and run arbitrary programs at compile time. Philip Wadler does a better job than me at getting excited by lambda calculus. He calls it "the omniversal programming language", and claims that aliens will probably have discovered it [2]. [1]: http://matt.might.net/articles/c++-template-meta-programming-with-lambda-calculus/ http://matt.might.net/articles/c++-template-meta-programming... [2]: https://www.youtube.com/watch?v=IOiZatlZtGU https://www.youtube.com/watch?v=IOiZatlZtGU
- lomereiter 10y agoI highly recommend the book "To mock a mockingbird" for gentle and fun introduction to combinatorial logic.
- lisper 10y agoFactorials in pure lambda calculus: http://www.flownet.com/ron/lambda-calculus.html http://www.flownet.com/ron/lambda-calculus.html
- anigbrowl 10y agoAny introduction to anything should start with a clear statement of what it is and why you might want to use it. I find this a particular problem with computer language topics; I don't know yet why The Author find This Thing so useful so tell me up front a few benefits I might get from investing my time in learning it. Unfortunately, the people who are best at using something are not always the best at communicating it. This is particularly important for audiences like teenagers, who already have multiple private and public actors competing for their attention and future economic potential.
- 0x54MUR41 10y agoAny example like what you said? I agree with you. So, I want to know examples out there that have a great explanation about something.
- anigbrowl 10y agoThere was a thread a day or two about about a book called The Scientist's and Engineer's guide to digital Signal Processing which I think is the best-written technical book I've ever encountered. The other one that springs to mind is C: How to Program by Deitel and Deitel. They've done multiple programming cooks but that's the only one I've owned.
- 0x54MUR41 10y agoNo problem. Anyway, thank you.
- lowken10 10y agoI try to use the Why, What, How, What If framework.. Why - Why should you care about this, why does this matter. What - What is it. How - How does it work. What If - Here is the thing you can do right now to get started...
- lowken10 10y agoI try to use the Why, What, How, What If framework.. Why - Why should you care about this, why does this matter. What - What is it. How - How does it work. What If - Here is the thing you can do right now to get started...
- chalkandpaste 10y agoSo many parens. Much cumbersome. Why not Haskell?
- cardiffspaceman 10y agoThis is my opinion as to why not Haskell. I do on the whole prefer lazy languages where the parens are not mandatory, but let's be honest about the drawbacks. So in Haskell you have "name1 name2 name3 name4 name5;" which is the application of some function to some arguments, of course, so this seems like a win compared to having to parenthesize the same thing. But when you have name1 name2 name3 + name4 name5, you had better want (name1 name2 name3) + (name4 name5) because that's the precedence. I think in some scenarios you can throw $ at the expression to get a more advantageous interpretation. And for fun you can do name1 name2 `name3` name4 name5 which will make things interesting. And then there's name1 name2 . name3 name4 name5 which in some contexts might mean the coder is using point-free style, which is NOT named after a lack of periods. But point-free style is considered cool by some Haskellers. Some LISPers like the long row of closing parens on the last line of a definition, so one man's meat, right? There's no such thing as free syntax. (I invite technical corrections, I'm still learning Haskell).
- grzm 10y ago(2015)
- sguav 10y agoAt the end, when talking about number notations: > Mathematicians worry about that sort of thing. Engineers don't. Sometimes aeroplanes crash. Mostly they don't. I would argue this statement which (to me) wrongly blames the intrinsic lack of exactness in applied science, otherwise a good read.