The Artima Developer Community
Sponsored Link

Heron-Centric: Ruminations of a Language Designer
Closures and Anonymous Functions
by Christopher Diggins
August 22, 2006
Summary
There is a debate raging at the Lambda-the-Ultimate.com site about closures in Java. Here's my two cents on the subject.

Advertisement

The debate at http://lambda-the-ultimate.org/node/1684 is essentially whether closures are needed in Java or not. I have an issue with the debate: a lot of people are arguing for anonymous function, not closures.

While I completely agree that anonymous functions are very useful for certain styles of programming, closures have a very clear downside: they increase code coupling. Passing a single closure can extend the lifetime of massive numbers of objects, leading to a huge performance hit.

Closures are a very powerful feature, but dangerously so. They are arguably too easily abused. A language designer has the responsibility to force a programmer to be explicit about dangerous things.

I am not saying that there is any single right answer for all cases, but I do think that people need to make a clear case why closures are important to have versus anonymous functions.

Talk Back!

Have an opinion? Readers have already posted 54 comments about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Christopher Diggins adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

Christopher Diggins is a software developer and freelance writer. Christopher loves programming, but is eternally frustrated by the shortcomings of modern programming languages. As would any reasonable person in his shoes, he decided to quit his day job to write his own ( www.heron-language.com ). Christopher is the co-author of the C++ Cookbook from O'Reilly. Christopher can be reached through his home page at www.cdiggins.com.

This weblog entry is Copyright © 2006 Christopher Diggins. All rights reserved.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use