Ask HN: How do you explain closures?

https://news.ycombinator.com/item?id=926077
by dstorrs • 17 years ago
69 64 17 years ago

In the past year or two, I've had to explain closures--what they are and why they are interesting--several times. Usually, at the end of my explanation, the person doesn't get it, and they go back to doing whatever they are familiar with.

So, I ask HN to put yourselves in this scenario and tell me what your answer would be:

Joe is a talented but inexperienced developer. He's got a year or two of experience, maybe as much as 5, but he programs for a job, not for fun. Also, for whatever reason he's never encountered closures--most likely he's only worked in languages that don't really support them.

You want to explain to him (a) what they are and (b) why he would want to use them. You have about 10 seconds to get his interest before he starts thinking about his WoW raid tonight, and about 5 minutes for the whole explanation.

What do you say?

Related Stories

Loading related stories...

Source preview

news.ycombinator.com