top | item 453319

Hello World Executable Sizes in 18 Languages

13 points| mqt | 17 years ago |mbishop.esoteriq.org | reply

13 comments

order
[+] Zak|17 years ago|reply
In some of these cases, I suspect the main difference is related to how the language's runtime libraries are linked to the executable. Chicken, for example produces a 15k executable. Running that executable requires the presence of a much larger dynamically linked libchicken.

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)
[+] jwr|17 years ago|reply
This is a very silly comparison. What is an executable? Do you consider dynamic libraries that it uses a part of it? Do you consider the language runtime a part of it?

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?

[+] gertburger|17 years ago|reply
It seem like the author does not differentiate between compiled (To machine code) and (To intermediate/byte code). Does that mean the pyc(114 bytes on my machine) generated by python for 'print "Hello world"' can be compared to the others?

It is still interesting though.

[+] aniketh|17 years ago|reply
don't forget you would have to add a shebang line to make it truly executable
[+] jws|17 years ago|reply
It would be interesting to also see how much RAM was used to run Hello World, but then I'd want to also know how much was shared with other programs, shared between instances of this program, and not shared... it would probably get out of hand.
[+] huhtenberg|17 years ago|reply
The size of D executable - 230K - is a quite big surprise.
[+] statictype|17 years ago|reply
> Common Lisp - 25MB

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.

[+] mqt|17 years ago|reply
lispm, from reddit:

    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...
[+] jwr|17 years ago|reply
This means the original author is clueless. Executable for my small CL program is 44K for the FASL file and a one-liner shell script to run it. This is very similar to the java numbers.

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.

[+] TrevorJ|17 years ago|reply
I'd like to see the code for "Hello World" for biological systems.
[+] smcdow|17 years ago|reply
It can be done in 8 bytes.