LWN.net Logo

What, again?

What, again?

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

This argument has already been disposed of elsewhere. Anyhow, it is not responsive: with-open-file is no help at all when your file descriptor is placed in a data structure returned to a caller, which is the case I described above.

The argument form used here is familiar: "Lisp is Good. Therefore, Lisp lacks nothing important. Therefore either the feature you describe is not important, or Lisp really has it after all. If in fact it is important and Lisp lacks it, let me describe some other feature which it does have, which you must agree is good." Congratulations on skipping over the middle bits. I will happily concede that with-open-file is positively jim-dandy, but not that it is an adequate substitute for the capacity to abstract management of non-memory resources.

There are sound reasons that Lisp, over the course of five decades, has failed to attract significant industrial use. Rather than engaging in apologetics, it would be better to understand industrial needs and design languages to meet those needs. C++ achieved its industrial position precisely this way. A Haskell or ML variant with destructors and without the equivalent of CONS might give C++ a run for its money. However, C++ isn't standing still. C++09 (and G++-4.x, for some small x) will support concepts, which is another fundamental advance.


(Log in to post comments)

What, again?

Posted May 3, 2007 7:28 UTC (Thu) by flewellyn (subscriber, #5047) [Link]

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.

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