
An Introduction to the Lambda Calculus (2015) - tosh
http://www.learningclojure.com/2015/11/an-introduction-to-lambda-calculus.html
======
anigbrowl
Any 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
Any 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
There 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
No problem. Anyway, thank you.

------
alangpierce
If 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.alangpierc...](https://play.google.com/store/apps/details?id=com.alangpierce.lambdacalculusplayground)

[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.

~~~
urs2102
Just out of curiosity, is there a particular reason why some people refer to
lambda calculus with a definite article?

My professor in CS Theory would refer to it as "the" lambda calculus, but
another professor I had chose not to (I call it "lambda calculus").

This is totally trivial, I'm just wondering if there's a reason why you, or
some people, say "the" lambda calculus.

~~~
wyager
"<x> calculus" without an article is an activity, whereas "the <x> calculus"
is a concept. That's the way I've always parsed it internally. For example,
you would never say to someone "Do you know about SKI Calculus?" because it's
not something people do. You would say "Do you know about _the_ SKI Calculus",
referring to the abstract notion that someone constructed. We often use the
phrase "calculus" for the calculus of derivatives and the calculus of
integrals because it's something people do as an activity very often. Same
with the lambda calculus.

~~~
GeneralMayhem
That may work for your internal parsing, but it's not correct with respect to
any standard of English grammar. Consider that any activity can also be a
topic of knowledge, and it doesn't change article usage: "do you know about
football?"

"The", the definite article, has a couple of purposes in English, but by far
the most common is to refer to an individual member of a set of nouns. The
decision to use it or not in this case depends on how the the words "lambda
calculus" are interpreted:

1\. "Lambda calculus" is a compound noun that describes a unique or
uncountable object or concept. In this case, "lambda calculus" is in effect
the only member of the set to which it belongs, and so "the" is not used.
Compare with any other conceptual noun, e.g. "mathematics".

2\. "Lambda calculus" is a compound noun, but is not unique - that is, there
are multiple things that could be referred to as "lambda calculus". In this
case, "the" is used to select a particular _lambda calculus_. An extended
phrase might be "the lambda calculus introduced by Alonzo Church, as opposed
to the lambda calculus introduced by Joe Shmoe." Note also that in general
parlance, "the" can be used alone to refer to the most common one of
something, as if that member of the set were always considered an antecedent
to current conversation. For example, in certain circles in California, "the
industry" refers to the _entertainment_ industry. Because it's so common to
refer to that particular member of the set of all industries, "the" on its own
is sufficient to select it.

3\. "Lambda calculus" is a generic noun (calculus) with a modifier (lambda)
that makes it unique. In this case, similar to (2), "the" must be used, as it
along with "lambda" serves to select the particular _calculus_ being referred
to. Compare with "the Nile River" \- "Nile River" is unique, but since "Nile"
is a modifier for a generic noun the article is required. (Following the final
point from (2), saying simply "the calculus" would under this interpretation
normally refer to the calculus of derivatives and integrals, since that's by
far the most common.)

4\. Same as (3), but "calculus" is not countable in the same way, and so it
does not make sense to refer to the set of all things known as "calculus". In
this case, "lambda calculus" refers to a portion of the singular concept
"calculus" rather than a member of a set, and so "the" is not used.

I think the most common intentions are (3) and (4) for using or not using
"the", respectively. (4) is more common among non-mathematicians for whom
"calculus" is a singular subject in school, while (3) is more common among
people who are aware that "calculus" is a general term for "form of
calculation", and who might refer to the particular "calculus" taught in high
school as "the calculus of derivatives and integrals". I'm normally partial to
(1), myself (i.e., "lambda calculus" and "integral calculus" are each topics
of knowledge, grammatically identical to "mathematics").

------
mrspeaker
Great 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!

~~~
bogomipz
On 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/)

------
dreeko_
No 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
The 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
Personally I prefer this introduction by Barendregt (his books on Lambda
calculus are really good): ftp://ftp.cs.ru.nl/pub/CompMath.Found/lambda.pdf

------
lomereiter
I highly recommend the book "To mock a mockingbird" for gentle and fun
introduction to combinatorial logic.

------
syncopatience
Does 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?

~~~
tikhonj
I'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
I 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.

------
sguav
At 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.

------
lisper
Factorials in pure lambda calculus:

[http://www.flownet.com/ron/lambda-
calculus.html](http://www.flownet.com/ron/lambda-calculus.html)

------
grzm
(2015)

------
chalkandpaste
So many parens. Much cumbersome.

Why not Haskell?

~~~
cardiffspaceman
This 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).

