Hello World Executable Sizes in 18 Languages
mbishop.esoteriq.org
mbishop.esoteriq.org
As mentioned in the article, an executable SBCL core includes all of SBCL. Considering that Java and .NET produce "executables" that are actually executed by their respective runtimes, I think it might be more fair to SBCL to compare the size of a FASL. It's 828 bytes for a FASL compiled from
(print "Hello, world!")
(sb-ext:quit)As an example, 12K for java is a ridiculous number. What's the size of the runtime required to run it? I bet it is larger than the 25MB for Common Lisp, but it doesn't get counted -- why?
And if you're there, you need to define what your base runtime is -- is it the OS kernel? OS kernel + a set of base dynamic libraries? If so, which ones? Is glibc standard? glib? zlib?
It is still interesting though.
$ echo 'echo $0' > 'Hello, world!' $ chmod +x 'Hello, world!' $ 'Hello, world!' Hello, world! $ wc 'Hello, World!' 1 2 8 Hello, world!
8 bytes. I think that's probably as small as you can get.
Double-You Tee Eff.
What, does Common Lisp not have an incremental linker or something? Even Delphi executables are never that big.
>Lisp has the largest executable file (because to create an executable, you have to dump a "core image") at 25MB
Can someone explain what this means? I'm clueless.
There are different strategies to create CL applications.
- save an executable image. This will mostly dump the Lisp system and
when you start it up, you have mostly everything back. The size
of the dumped image depends on the size of your Lisp system. SBCL
is already large and does not have any special features to make
it smaller. CLISP for example writes much smaller images than
SBCL. Clozure CL is also smaller. Here also is important with how
much debug information the original Lisp image was created. The
saved image typically will include all that. Corman CL on Windows
compresses the Lisp data to save space.
- deliver an application. That's for example what LispWorks and
Allegro CL can do. They allow functionality and
information (debug info, documentation strings, arglists, source
locations, symbols, caches, ...) to be removed (for example by
treeshaking, or by removing whole functionality groups). The size
of the generated application will depend on what you leave out
and which delivery level you are choosing. Stuff that might not
be needed: compiler, debugger, disassembler, editor, inspector,
REPL, ...
- deliver a static application. I don't know which currently
maintained CL implementation does that. There were several Common
Lisp implementations that generate 'small' and static C code from
Lisp. CLICC, Ibuki's CONS, WCL, Lisp-to-C, ThinLisp were in that
league. They were used for application delivery, where the
application might be really small and does not have any large
runtime or development environment.
There are also some other options. Probably ABCL could generate a
JAR file that could be started with an installed JVM. Often Lisp
compilers can compile code to native code compiled files (fasls)
and even can append several fasls into one. Then one does need
only to ship the fasl file, given that the user has the a Lisp
installed that can load the fasl.
http://www.reddit.com/r/programming/comments/7swzs/hello_wor...The original author chose to dump the entire development environment including the compiler, into one single executable -- this is sometimes interesting, but I don't see why he did that. He doesn't seem to do it for Java or Python.