On Fri, 03 Dec 2010 00:03:09 -0500, Lew wrote:
> ClassCastException wrote:
>> Another case where Clojure comes to the rescue:
>>
>> (Clojure is the greatest **** since sliced bread)
>>
>> It even has (really groovy ****).
>>
>> As you can see, Clojure also (excels at saving the universe)
>>
>> and indeed it's easy to make (everything beautiful) in general. It's
>> like having C++'s RAII back, only without the icky rest of C++.
Since you wrote the parenthesized expressions above, I take it you're a
convert?
> Personally, I call "RAII" "RRID".
"Resource Release Is Destruction"?
> My personal "rescue" is just to type the extra lines of code. What, I'm
> going to sprain my finger? At least I don't tar roofs for a living.
> That's an honorable profession - those guys actually work for a living.
One principle of sound software engineering is to try to specify each
fact in exactly one place -- cuts down on copy-paste errors and things
getting out of sync, not to mention saving typing, making code shorter
and more readable, and avoiding forgetting something the nth time you
reinvent wheel X.
Java lets you go pretty far with that with method and object
abstractions, but without macros and first-class functions it can not
quite get all the way there. Hence the repeated boilerplate Java code is
rife with, specifying over and over again how to "grab a stream, process
it, and then close it in an exception-safe manner" or "iterate over a
list removing some elements".
The with-open macro in Clojure addresses the former, however, and higher-
order functions combined with first-class functions and anonymous lambdas
take care of the latter. (The expression (remove #(= 0 %) foo) for
example returns a list that's a copy of foo with all the zeros removed;
if foo was (0 3 7 0

it gives (3 7

as its output. Clojure encourages
copying-with-modification in preference to in-place modification and
other thread-safe practices, though there are ways to do in-place
modification and you can even use the mutable java.util collections if
you really want to.)
As for how Java it is, it runs on the JVM, compiling to bytecodes; and
can use everything in Java's class library (except, IIRC, annotations,
support for which is forthcoming); so one might argue it's 2/3 Java.
(Others might argue that it's Java++.

)