4 ms·
There are other languages you could make it small in, but those languages probably aren't among them. Haskell: Hugs 98 is 723K, but it depends on /usr/lib/hugs
by kragen 17y ago
There are other languages you could make it small in, but those languages probably aren't among them.
Haskell: Hugs 98 is 723K, but it depends on /usr/lib/hugs, which is 7.3M. GHC can almost do it; I compiled a "hello, world" program with GHC and it "only" came out to 366K, which is 84K bigger than μTorrent's reported size. With UPX, however, it packs to 130k. (ocamlopt's tax is in the same range.) Maybe Haskell would be an option? Or does it bloat up when you include the libraries you'd need for this?
Erlang: My Erlang install is 97M. I don't know how much of that is minimally necessary to run things, but /usr/lib/erlang/erts-5.6.3 is 3.6M, 12 times the size of μTorrent. Stand Alone Erlang (http://www.sics.se/~joe/sae.html http://www.sics.se/~joe/sae.html) is 1.5MB compressed.
Common Lisp: All the Common Lisp implementations are pretty big (SBCL, say, is 53M, of which 25M is the image sbcl.core), and they can't produce a standalone executable without including most of the environment. So you're starting at 25M.
Java: The JRE on my system is 98 megabytes, so a Java application to run on Win32 will be 98 megabytes plus the application code. Even if you compile your app with GCJ, libgcj is 33 megabytes.
Now, you could argue that the size of this stuff isn't relevant because it isn't specific to your hypothetical Common Lisp implementation of BitTorrent, but could also be used by whatever other Common Lisp programs the user has installed. But you would be treating a very-low-probability event as if it were normal.
Languages — or rather, language implementations — that could make a 300k runnable BitTorrent client include not just C and C++, but also Forth, assembly, Pascal, Eiffel, and any number of other fatally flawed niche languages that don't require hundreds of kilobytes of libraries just to initialize a process and exit. There are probably also Scheme implementations that would work.
Just about anything that has a reasonably small bytecode interpreter and lets you package the rest of your program as bytecode would probably win. x86 code is pretty grossly bloated by comparison to a good compact bytecode. (But compressible. See comment above about UPX.)
The only other practical alternative I know of would be Lua, which only costs you about half of your space budget for the interpreter itself. Lua's "bytecode" is actually wordcode, but presumably UPX or something similar would squeeze it down to a reasonable size.
It's my understanding that μTorrent does not need to ship with any shared libraries to run; the <300k of the executable alone is sufficient. You may think this is unimportant but I think that is an unconcern based in unusual wealth: you probably own your own computer to install software on persistently, probably several of them, you probably have several hundred kilobits per second of bandwidth to download software with, so you probably don't care how long it takes to download something or how much of a 256MB USB pendrive it takes up.
It's certainly true that there are any number of languages you could write a BitTorrent client in that would be just as fast.
- jrockway 17y agoBut let's face it -- micro-optimizing the space of the image on disk is a completely useless optimization these days. You are also not including the shared libraries that the binary uses. When making my argument in the grandparent post, I did not even consider the size aspect to be worth discussing. If this is somehow important to you, then my argument does not apply.
- ilyak 17y agoWhy would you need a tiny bittorent image when the first it would download would cover the fattest image, ten to one? Come on, bittorent is for flacs and movies.
- sb 17y agoI am usually the last one to even read language flame wars, let alone participate in them, but how exactly are Eiffel, Forth and Pascal fatally flawed?
- ido 17y ago>Java: The JRE on my system is 98 megabytes, so a Java application to run on Win32 will be 98 megabytes plus the application code. Even if you compile your app with GCJ, libgcj is 33 megabytes. > Now, you could argue that the size of this stuff isn't relevant because it isn't specific to your hypothetical Common Lisp implementation of BitTorrent, but could also be used by whatever other Common Lisp programs the user has installed. But you would be treating a very-low-probability event as if it were normal. I am pretty sure the vast majority of users already have the JRE installed, and if they don't it's a download that's around 15mb.