Live data from Hacker News

I Finally Understand Closures

iode.co.uk

1–10 of 22 posts

Re: I Finally Understand Closures

#2
Why are there so many of these "I finally understand [cloures | pointers | misc CS concept]" posts? I mean these are pretty fundamental concepts that any first year CS student should be able to grasp pretty quickly.

Re: I Finally Understand Closures

#3
post #2

Why are there so many of these "I finally understand [cloures | pointers | misc CS concept]" posts? I mean these are pretty fundamental concepts that any first year CS student should be able to grasp pretty quickly.

I don't think it's so much "I finally understand X", but more of "I finally have found an application for X".

I think it's interesting to see how other people solve problems.

Re: I Finally Understand Closures

#4
This example demands that you understand some domain-specific needs (of a text editor), so it's a little annoying.

But, the main idea is right on the mark. The point is that the natural structure of the code (that uses closures) is completely impossible to achieve without closures.

Great stuff! I think the author gets it. :-)

Re: I Finally Understand Closures

#5
post #2

Why are there so many of these "I finally understand [cloures | pointers | misc CS concept]" posts? I mean these are pretty fundamental concepts that any first year CS student should be able to grasp pretty quickly.

I think the problem arises when people hear about a concept and try to understand it without knowing the foundation required to really understand it.

Pointers are easy if you understand the basics of how a computer works and know a language like C.

Likewise, closures are easy when you know a little about functional programming and understand first class functions.

Re: I Finally Understand Closures

#6
post #2

Why are there so many of these "I finally understand [cloures | pointers | misc CS concept]" posts? I mean these are pretty fundamental concepts that any first year CS student should be able to grasp pretty quickly.

Speaking of which, I don't know why someone hasn't hooked a closure system into html. Think of it, you can bind links to an instance of the website on archive.org -- if eventually it goes down, you can at least recover what the author meant to point to.

Re: I Finally Understand Closures

#7
post #2

Why are there so many of these "I finally understand [cloures | pointers | misc CS concept]" posts? I mean these are pretty fundamental concepts that any first year CS student should be able to grasp pretty quickly.

I think the problem arises when people hear about a concept and try to understand it without knowing the foundation required to really understand it. Pointers are easy if you understand the basics of how a computer works and know a language like C. Likewise, closures are easy when you know a little about functional programming and understand first class functions.

Monads are another high-theoretical concept that needs a real-world metaphor. So far, the best one I've heard is the "nuclear waste" one. I've been trying to grok monads for about two years now.

Re: I Finally Understand Closures

#8
Maybe now he also understands why objects are often preferable. Closures are liked handicapped objects. Names are resolved when the closures is created, not when it is called. This is not nearly as flexible as an object, where names are resolved when the function is called.

Re: I Finally Understand Closures

#9

Maybe now he also understands why objects are often preferable. Closures are liked handicapped objects. Names are resolved when the closures is created, not when it is called. This is not nearly as flexible as an object, where names are resolved when the function is called.

OK, have fun implementing an interface just to manipulate a collection when a one-liner would have sufficed.

Re: I Finally Understand Closures

#10
To be honest, I still don't get it. He says, "Such and such will help you understand closures" and then a few lines of python, then suddenly, "because start_pos is a closure".

Which, really, still doesn't explain what he means. That and for the love of god, I hate things such as Clojure. Call me a stick in the mud, but I like languages in which I don't have to mentally expand 80% of words.

Post reply on HN