Java 7 : The new try-with-resources statement
baptiste-wicht.com
baptiste-wicht.com
Watching Java programmers is like having a tribal shaman for a next-door neighbor. You know it's none of your business, and you respect his beliefs, but it's still unsettling to see him do one of those "hot knife in nose" and "pull stubborn goat with nipple fish-hook" rituals.
Come to think of it, that last trick must be what Guy Steele did to drag C++ programmers "halfway to Lisp".
> Watching Java programmers is like having a tribal shaman for a next-door neighbor.
This coming from the guys still harping on about the resplendent days of unbridled hacker ecstasy in the Garden of Genera.
Pot. Kettle. Black.
With respect to Java, there is only one real solution provider, and the cottage industry is in the punditry that begs and supplicates to this sole provider on behalf of various users and their respective interests. So Java is more like the political lobbyists and lawyers.
Regarding Genera, dropping the G-word just marks one as long out of shape, Lisp-wise. Lately, the fuss is all about JVM, CLR, multicore, large scale distribution, packaging, semantic web, machine learning, mobile and application platforms. You can even grow a beard and find nirvana on the JVM:
It may be well true that there are more competing implementations of Lisp. (Though that is also open to debate; after all, what is Android if not Java on a new VM? What of OpenJDK?) And in any case, the great majority of Lisp implementations are toy languages that lack the stability and features to be used in any serious environment.
Your other points:
* If armed bear isn't dead, it definitely smells funny -- at least the last time I checked (~1.5 years ago).
* Clojure is cool in large part because it has access to the thousands of Java libraries written by those shamen-like programmers you get such a kick out of mocking.
My point is that a programming language is just a tool to get something done. Those that mock supposedly inferior languages miss the point that there are aspects to those languages or environments that make them appealing for the job at hand. If I want to do a web site, I'd use PHP with WordPress, because I most likely won't have to write any code at all. If I want to write a web app, I might use Ruby or Python. If I'm a real-time market trading platform, I'll use Java because there's so much reliable, mature code out there and it's really fast. If I want to write a music application or plugin, then I'm going to need to use C++ to communicate with ASIO and VST.
And, finally, if I want to write a Lisp interpreter, I'll use Lisp ;)
My opinions are backed by code. I implemented this new Java feature in ~30 lines of CL, there was no committee involved:
http://mahmud.arablug.org/java-try-with-resource-in-lisp.htm...
Something has to be said for expressiveness when one guy with an spare hour can implement what might be considered a major language feature like this. Makes you wonder what else is being made difficult by the language; how much time and money, not to mention sanity, are being wasted trying to cut wood with a dull knife?
(with-open [fis (FileInputStream. source)
fos (FileOutputStream. target)]
(do-stuff fis fos))
I wish they would spend less time adding stuff to the Java language (especially features present in other JVM languages), and more time fixing the core API and improving the JVM feature set. Continuations would be nice.Facepalm... (There has to be an easier way...)
http://mahmud.arablug.org/java-try-with-resource-in-lisp.htm...
All we need to do this is duck typing and closures I believe.
Sure, one may or may not like Java, but if you're going to add this construct, using an interface like that is the proper way.
This article actually made me realize Java is good if you have obsessive-compulsive disorder. Now you can go through your code base and replace all try/catch blocks with this pattern and neatly label your classes with another interface/category. Then everything is in order again - you haven't gained in productivity, but you have introduced more "system" into your world.