LWN.net Logo

Advertisement

Front, Kernel, Security, Distributions, Development. See your byline here on LWN.net.

Advertise here

FOSDEM 2009

What, again?

What, again?

Posted May 3, 2007 7:28 UTC (Thu) by flewellyn (subscriber, #5047)
In reply to: What, again? by ncm
Parent article: The Rise of Functional Languages (Linux Journal)

Okay, fair enough. So I slightly misunderstood your point.

Your point, it seems, is "If I do X which breaks the automatic tools we have to manage resources,
then I have to manually manage the resources! This is bad!"

My response is: so don't do that, then.

But aside from that, you've spent a lot of time saying "current languages don't offer a way to
manage resources the Right Way." What is this Right Way?

Rather than engaging in polemics, it would be better to help us understand just what it is you're
looking for in a functional language that doesn't do what you want.


(Log in to post comments)

What, again?

Posted May 9, 2007 6:13 UTC (Wed) by ncm (subscriber, #165) [Link]

"My response is: so don't do that, then."

I.e., don't try to write industrial code in Lisp. And I don't. Which is to say, you didn't slightly misunderstand my point; you entirely missed it.

Functional or not functional is irrelevant to the discussion. It would not be especially difficult to invent a new language with a strong type system, and destructors, as powerful as C++ but about a tenth the size. Functional semantics might make it easier to specify, and to optimize. For destructors to help, it would need to be non-garbage-collected, or it would need to offer some way to indicate that an allocation is meant to be GC'd, and prevent anything with a destructor from being allocated that way.

Block scope is the most powerful organizational method we have in programming. "With-foo" macros correctly tie object lifetime to a scope. However, they tie it to the wrong scope. Frequently the correct lifetime matches the block of some caller up the chain from the function that claimed the resource. Just a little less frequently, it's some other block entirely. Lisp offers no mechanism to express this, and neither can any other language that lacks destructors.

The consequence for exception handling is a little harder to explain, but just as large in its effect on programs. In a well-constructed C++ program, cleanup code is almost all in destructors, and exercised routinely in the course of running the program. There are no "finally" clauses, and very few "catch" clauses. In other words, in a "throw", very little code is executed that would not be run anyway. Exceptions are routed to just a few easily tested collection points. Omit destructors, and cleanup code has to be put in "finally" clauses scattered throughout the program, typically difficult or even impossible to test.

What, again?

Posted May 9, 2007 6:44 UTC (Wed) by flewellyn (subscriber, #5047) [Link]

No, I did not mean "don't write industrial code in Lisp".

I meant "don't go out of your way to break your tools".

Honestly, I think I agree with the commenter who said that you present a prejudice, not an
argument.

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds