Libraries, libraries everywhere
Sep. 12th, 2008 03:06 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
So on the one hand, I notice that the WAR file for CommYou is now 12,345 K in size. The numbers geek in me find this pointlessly entertaining.
OTOH -- 12 *Meg*?!? Jeez, it is easy for an app to bulk up these days. I mean, IIRC that's something like twice the code size of Thief, a project that consumed many programmers for many years.
Of course, the actual code for CommYou is only a tiny, tiny fraction of that. The rest is all libraries. We're currently including, what? -- a cursory inventory finds 38 libraries so far, ranging from a few dozen K to the better part of a Meg. Libraries for XMPP, for XML, for logging, for JSP, for DB, for all *their* dependencies, and so on. Indeed, I'd be surprised if we're even calling 5% of the code that's included here, since in most cases I'm only using a small chunk of a big library.
It's not really a big deal, of course, but the old-fashioned programmer in me is kind of appalled. (And uploading the bloody WAR does take a fair while.) Here's a question for those more hip to Java development than I -- is there any sort of mechanism for trimming all this bulk down? In the old C++ days, the linker would trim away the paths that were never called. (Indeed, occasionally causing me problems in doing so.) Is there anything comparable now, or does everyone just live with library bloat?
OTOH -- 12 *Meg*?!? Jeez, it is easy for an app to bulk up these days. I mean, IIRC that's something like twice the code size of Thief, a project that consumed many programmers for many years.
Of course, the actual code for CommYou is only a tiny, tiny fraction of that. The rest is all libraries. We're currently including, what? -- a cursory inventory finds 38 libraries so far, ranging from a few dozen K to the better part of a Meg. Libraries for XMPP, for XML, for logging, for JSP, for DB, for all *their* dependencies, and so on. Indeed, I'd be surprised if we're even calling 5% of the code that's included here, since in most cases I'm only using a small chunk of a big library.
It's not really a big deal, of course, but the old-fashioned programmer in me is kind of appalled. (And uploading the bloody WAR does take a fair while.) Here's a question for those more hip to Java development than I -- is there any sort of mechanism for trimming all this bulk down? In the old C++ days, the linker would trim away the paths that were never called. (Indeed, occasionally causing me problems in doing so.) Is there anything comparable now, or does everyone just live with library bloat?
(no subject)
Date: 2008-09-12 07:50 pm (UTC)It looks like IBM AlphaWorks used to have a tool (http://www.alphaworks.ibm.com/tech/jax) to do just that, but they seem to have incorporated it into WebSphere and then made it impossible to find out anything about it, and messed up their website so that most of the links from the original page inexplicably take you to a page about their "Lotus Expeditor" customer care application. Sigh.
This tool (http://www.zelix.com/klassmaster/index.html) appears to have a 'trim' function that claims to do that, as does this one. (http://www.retrologic.com/retroguard-main.html) Apparently the only tools that include this function are code obfuscators.
(no subject)
Date: 2008-09-12 10:44 pm (UTC)I guess one explanation is dynamic class loading. That isn't super-common, but it's certainly not hard to do in Java, and would interact extremely badly with such a tool. Since there's always a danger that your constituent JAR files might contain dynamic loading, the tool can't be used safely enough to be worth it...
(no subject)
Date: 2008-09-15 04:52 am (UTC)Yeah, for web applications, the WAR is a definite unit and includes some configuration, but for standalone Java applications, packaging as a JAR is just an optional convenience. The only real drawback is upload/download time, and while that's a pain for you if it's in the development cycle, it's a one-time thing for a user downloading an application, and not even that for a user of a webapp. So it becomes much more of a specialized tool than a traditional linker.
(no subject)
Date: 2008-09-12 08:20 pm (UTC)(no subject)
Date: 2008-09-12 10:28 pm (UTC)Upload times
Date: 2008-09-12 08:24 pm (UTC)Dumb question: Can you upload just your own jarfile and build the WAR on the server? (I haven't done any J2EE.)
Re: Upload times
Date: 2008-09-12 10:27 pm (UTC)To just upload my own JAR would require that the libraries get shipped up as a separate matter, and automating that reliably so that it doesn't require too much manual intervention and updates probably when versions change -- well, it would almost certainly take much longer than the time I'm going to spend waiting for the WARs to upload in the next year...
Re: Upload times
Date: 2008-09-13 12:07 pm (UTC)Personally, I'd go that way, rather than trusting a tool to strip out just the right bits.
Re: Upload times
Date: 2008-09-13 02:58 pm (UTC)But it's a possibility, at least eventually. For the time being, though, it would still be a pretty considerable deployment rewrite, and I have bigger fish to fry...
Re: Upload times
Date: 2008-09-15 04:39 am (UTC)(no subject)
Date: 2008-09-12 10:35 pm (UTC)http://www.retrologic.com/rg-docs-trim.html
Now, they do have a free GPL'd library, but the commercial version is slightly pricey.