Hacker News new | ask | show | jobs
by xyrouter 2955 days ago
Do other popular languages support a similar construct? C? C++? Perl?

The Java try-with-resources was introduced in Java 7 (2011).

The Python with statement was introduced in Python 2.5 (2006).

The Lisp with-open-file has been in Common Lisp Hyperspec for a long time (1960s?).

Not that it takes anything away from Java. I think all languages are gradually converging to the features of Lisp.

3 comments

Lisp as an idea or language family was around in the 60s, Common Lisp not so much.

Common Lisp The Language was published in 1984, CLtL2 in 1990, and the ANSI standard in 1994. I believe the hyperspec (which is not the spec) was published in 1996 or so.

CL is neither as ahead of its time or of another, past time as you might think.

> Do other popular languages support a similar construct? C? C++? Perl?

C? No, though I don't really think of that as an actively maintained language. C++ and Perl achieve the same thing via RAII.

> Not that it takes anything away from Java. I think all languages are gradually trying to or discovering the approach the features and expressiveness of Lisp.

I think language design converges over time, alternating between expressive-but-unmaintainable and structured-but-too-strict but getting closer to the ideal as we advance. In many ways Lisp isn't a complete language design at all - rather macros are there for the user to finish the language themselves.

> I don't really think of that as an actively maintained language.

Oh, were it only so! It's an actively diddled language.

> C? No, though I don't really think of that as an actively maintained language.

Why would you think that? Work on the C standard is ongoing: http://www.open-std.org/jtc1/sc22/wg14/

Just that I hadn't heard of a new release since 1999, shrug.
C# has the "using" statement, which is effectively the same construct. F# calls it "use".