On Fri, Nov 20, 2009 at 1:37 PM, Jim Downing <jim.down...@gmail.com> wrote: > Hi Graham > > 2009/11/20 Graham Fawcett <graham.fawc...@gmail.com>: >> Hi folks, >> >> This is somewhat a Java question, but it's in the context of Clojure, >> so here goes. Playing with Leiningen got me thinking about bundling a >> Clojure application as a JAR, which might include a host of classes >> that are loaded but never used. Is it possible to "tree-shake" such a >> jarfile, and eliminate any classes that are not required for the >> main-class' operation? (Assuming the program doesn't need 'eval' with >> access to all of those classes at runtime.) >> >> This might not save a lot of startup time, but where startup time >> matters, maybe it might shave off a meaningful fraction. I'm just >> curious whether there is enough dependency information in a set of >> class files to calculate a tree-shaking plan; and whether there are >> existing tools to do the job. > > I might have misunderstood, but isn't the problem the same as in Java; > you can't know from a static analysis which classes are going to be > loaded?
If it's not possible in Java, then yes, it wouldn't be any different in Clojure. But after an admittedly casual search, I don't know what the specific blockers are to tree-shaking in Java. I know there are dynamic load-class-by-name facilities in the JVM, and of course that would be a barrier for static analysis. I've only ever seen these called with literal strings, though (e.g. in setting a JDBC driver), and that could be statically analyzed. But I should be able to know, through class inspection, whether my 'main' program depends on a class which uses, say, the clojure.zip namespace, and decide whether or not to include it. Or so I am wondering. I suppose a better question might be: would a tree-shaker have a reasonable chance of shaking a typical Clojure jar, or are there too many dynamic obstacles to a good analysis. Just curious, Graham > > Best regards, > > jim > > -- > 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 > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en