Hacker News new | ask | show | jobs
by crazygringo 4734 days ago
I think the down-votes are because you're attacking JavaScript without basis, and not constructively. This "memory leak" has nothing to do with the distinction between languages you make. And indeed, this kind of behavior in closures is by design (as I understand it), and not by evolution at all.
1 comments

Fair point, but I disagree with you - fulled specced out designed languages generally specify how exactly the implementation should handle these cases. How references should be retained, when references fall out of scope, etc.

eg:

http://clang.llvm.org/docs/Block-ABI-Apple.html

http://download.oracle.com/otndocs/jcp/lambda-0_5_1-edr2-spe...

http://www.microsoft.com/en-us/download/details.aspx?id=7029

etc etc. I also don't believe I'm attacking javascript here, merely repeating what people have always known about evolved languages. Evolved languages have a lot of pros (mainly speed of new features and practical application), and they have cons too. What I'm saying is very simple: this type of bug in javascript should not be a surprise - it should be expected. There will be more.

EDIT: Laughably enough, while the ObjC and Java specifications both specifically address this issue, the C# specification actually formalizes this exact bug into the language specification. So I concede your point, C# - a designed language - simply designed the exact same bug into the language itself. See section 7.15.5.1 Captured outer variables.

Feel free to downvote this post - I now concede that designed languages are just as likely to design stupid bugs into the language as evolved languages are to create them by mistake. ;)

This is going to come across as incredibly condescending but I honestly don't mean it as such.

When you have some more experience and a greater breath of knowledge programming you will see this kind of thing happens all the time. Whether by design, by accident, by omission, by not quite being explicit, by implicitness, it happens in every spec, in every language and in every protocol.

You can find something like this in them all.