I wanted to say thanks to Stuart & Stephen for taking this on. I think
it'll make the point of entry into Clojure that much easier ("Just
call the jar -- to get the REPL, to run a script, etc.") & I'm looking
forward to it.

Something that came up on another thread was what kind of AOT
compilation to support, namely, if it'd be useful to enable file
compilation in addition to compilation of a namespace. I initally
thought "of course!" with the use-case of quick scripts in mind, but
I've thought again. In case this is something that's still on the
table, below are some reasons against its utility.

1) What would be the compiled class for a script or file? Clojure's
namespaces as the analogue to Java classes (at least in bytecote)
seems to me to work really well -- all one has to do to get launch-
from-a-jar-file Java interop is define a garden-variety Clojure
function "main" (as opposed to the gen-and-save-class Camel-casing
with hyphen prefixes). But with a compiled file that's made up of
forms in the user namespace, or in no namespace (which, I just
checked, would default to clojure.core), what would get compiled down
-- a generated namespace, the user namespace, etc? The question might
be answerable, but it would require defining new behavior for
compilation, & it's not obvious what it'd be.

2) If 1) were worked out, we still wouldn't have what I'd want for the
script use-case; that is, we still don't have a file we can make
executable & put in our path (like we can with the new shebang support
in non-compiled scripts). We'd have to wrap a call to Java, specifying
the appropriate classpath, the compiled class, etc. This is stuff we
all handle in our clj script & have access to therefore w/ the
shebang, but with compiled files it seems to me we'd have to reproduce
it each time we wanted a new script.

3) How much benefit can we expect from AOT compilation on scripts?
It's hard to generalize, but for the kinds of things people use, say,
system scripts for, most of the execution time will be spent waiting
for the JVM to fire up; so I wouldn't think we could expect much
practical performance benefit.

All of which is to say I'm happy keeping my Clojure scripts as source
with a shebang. I'd be interested to hear if anyone else has a use
case in which file compilation would be a win.

But, given namespaces as the unit of compilation, a nice feature
(mentioned elsewhere, too, IIRC) of the java -jar clojure.jar main
would be to wrap the compiled namespace up in a jar. There's an
example of doing this in Groovy, with all of Groovy wrapped inside the
jar as well (http://bit.ly/aeeW); it uses what looks to be a handy
Groovy wrapper around Ant (the AntBuilder class), so a Clojure port
would probably require a few more LOC.

--
Or, actually, now that I look at it, it would require the Ant classes
on the classpath, which might require too much system-dependent
coordination...


Perry Trolard


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to