mini-version of clojure.jar?

239 views
Skip to first unread message

Terje Dahl

unread,
Aug 25, 2011, 4:26:21 AM8/25/11
to Clojure
My company (read: I) develop an web-based educational application (a
language lab) implemented as a Java applet.

I have spendt the summer porting it to Clojure. I am very happy with
the results.

Except: The download (and therefore the download-time) has increased
dramatically, as I now include the clojure.jar as part of the
download.
(Actually, I repackage the content together with my application.)

This, I fear is going to hit alot of the pupils hard, when 20 pupils
at a time attempt to access the applet for the first time over the
mediocre (at best) web-connections at their schools.

Yes, I do manipulate the java applet cache-params.
But There will always be a need for full downloads - both for first-
time-users, and when I update the applet (frequently).

My question:
Is there anyway to reduce the size of the jar - drastically?
Can I somehow remove most of the class-files generated from core.clj
etc, and still have everything working properly?
Tips/hints/suggestions?


(Plug: See my open-source JS-embed code for Java applets:
http://bitbucket.terjedahl.no/terjedahl/appletjs )





Meikel Brandmeyer (kotarak)

unread,
Aug 25, 2011, 4:37:19 AM8/25/11
to clo...@googlegroups.com
Hi,

There is a slim version of the clojure jar. See here for example here: http://repo1.maven.org/maven2/org/clojure/clojure/1.3.0-beta1/

Sincerely
Meikel

David Powell

unread,
Aug 25, 2011, 4:40:04 AM8/25/11
to clo...@googlegroups.com

The slim jar probably won't work in an applet, because it does classloader stuff (unless you have a signed applet).

--
Dave

Terje Dahl

unread,
Aug 25, 2011, 7:14:51 AM8/25/11
to Clojure
Yes. My applet is signed. So that is not a problem.

Any thoughts about difference in performance between "slim" and
"full"?
My applet mostly does swing-stuff, http GETS and POSTS - and audio
playback and recording.

David Powell

unread,
Aug 25, 2011, 7:19:04 AM8/25/11
to clo...@googlegroups.com

The runtime performance should be the same, but the startup time will be slower because it will have to compile the clojure code at load time.

--
Dave

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

Meikel Brandmeyer (kotarak)

unread,
Aug 25, 2011, 7:21:14 AM8/25/11
to clo...@googlegroups.com
Hi,


Am Donnerstag, 25. August 2011 13:14:51 UTC+2 schrieb Terje Dahl:
Any thoughts about difference in performance between "slim" and
"full"?

The slim version has longer startup time, I presume. Otherwise there shouldn't be a difference in performance.

Sincerely
Meikel
 

Stuart Halloway

unread,
Aug 25, 2011, 9:22:27 AM8/25/11
to clo...@googlegroups.com
My company (read: I) develop an web-based educational application (a
language lab) implemented as a Java applet.

I have spendt the summer porting it to Clojure.  I am very happy with
the results.

Except: The download (and therefore the download-time) has increased
dramatically, as I now include the clojure.jar as part of the
download.
(Actually, I repackage the content together with my application.)

This, I fear is going to hit alot of the pupils hard, when 20 pupils
at a time attempt to access the applet for the first time over the
mediocre (at best) web-connections at their schools.

Yes, I do manipulate the java applet cache-params.
But There will always be a need for full downloads - both for first-
time-users, and when I update the applet (frequently).

My question:
Is there anyway to reduce the size of the jar - drastically?
Can I somehow remove most of the class-files generated from core.clj
etc, and still have everything working properly?
Tips/hints/suggestions?

Great question. Post 1.3 we hope to look at a super-slim jar.  The design notes are minimal at this point, but FWIW: http://dev.clojure.org/display/design/Build+Profiles

Stu

Stuart Halloway
Clojure/core
http://clojure.com

Chas Emerick

unread,
Aug 26, 2011, 11:03:58 PM8/26/11
to clo...@googlegroups.com
You might want to give Pack200 a try; it's a Java classfile-aware compression algorithm that can produce jars that are far more compact than e.g. if you were to only gzip applet jars on their way out to your users. Lots of info about it if you feel like googling.

Using a build from the current HEAD of Clojure, this:

pack200 clojure-1.3.0.pack.gz clojure-1.3.0-master-SNAPSHOT.jar

results in decent savings:

-rw-r--r-- 1 chas chas 835K Aug 26 22:57 clojure-1.3.0-master-SNAPSHOT-slim.jar
-rw-r--r-- 1 chas chas 3.2M Aug 26 22:57 clojure-1.3.0-master-SNAPSHOT.jar
-rw-r--r-- 1 chas chas 1.3M Aug 26 22:59 clojure-1.3.0.pack.gz

So, pack200 won't get you down to the slim jar's 835K, but it will shave off ~60%, and shouldn't impact startup time at all. Whether that's a good tradeoff is up to you. :-)

- Chas

Reply all
Reply to author
Forward
0 new messages