So, why do I like lambda calculus? Actually, that's probably kind of a hard question to answer, and if I went through the trouble I'm not sure that the process would really be beneficial for anyone. I like it because I do? Whatever.

Why might lambda calculus be useful?

First thing first. In lambda calculus nothing comes from nowhere. This is actually true in other logics as well, although the effect isn't as pronounced. For example, in natural deduction you have axioms, which are propositions which are just assumed to be true. They're stated with no proofs. They seem to be coming from nowhere. However, that's not really what a natural deduction proof means when you encounter an axiom. What it actually means is that if you happen to be loitering around in the world and you encounter a proposition A and an inference rule A -> B, then you can assume the proposition B. The axioms aren't things that come from nowhere, it's more like a pattern matching transformer. You see this stuff you can get that stuff.

As far as I can tell, with most logics you don't care about the internal structures of your axioms. So it's easier to pretend that they come from nowhere and get on with the proof. However, with lambda calculus you do have to care somewhat about the structure of the parameters of your functions. If you misuse a parameter, your computation could yield a totally worthless value or it might not even be possible to finish your computation.

This should mean that lambda calculus is a good medium to use in order to think about and understand causality and causal machines. So, for example, computers are causal machines. Does someone want you to do something with a computer? Well does it seem like it would be possible with lambda calculus? Then it should be possible with a computer.

More pragmatically, if you really like lambda calculus, then you won't use singletons unless it's actually happens to be a good idea for your situation.

Secondly, lambda calculus can only have immutable data structures. This is similar to the previous point. If you're in a language that allows mutable data structures and references ( ie most of them and all industry languages) then a mutable data structure can be used as a hidden communication channel. And maybe there's some situations where you want to be able to enact change to another part of your program without actually going over there and enacting change. But most of the time this leads to difficult or impossible to understand code and bugs. If you really like lambda calculus then you won't tend to use hidden channels of communication.

Of course you have to be careful with how you try to apply lambda calculus to programming. Lambda calculus is turing complete (in fact it was turing complete before it was cool). This means that you can compute any function, it does not mean you can implement any algorithm. For example, lambda calculus doesn't have IO. Which means you can never communicate with anything. If you have a problem which requires you to monitor the state of some external device, lambda calculus is probably not the best tool for the job. If your environment doesn't have garbage collection, maybe you should pass on lambda calculus.

Overall though, today's boring industry jobs are favoring more and more environments that are garbage collected and provide first class anonymous functions. Best practices are starting to converge on immutable data structures, pass by value semantics, and favors some type of dependency injection over some types of singletons. I think this meshes close enough to lambda calculus to make it a useful tool at the hands of developers.

## No comments:

## Post a Comment