Search code examples
schemeracketexecutablechicken-scheme

Can executable size be optimized?


I have created executable of following code in Racket (choosing Racket and not GRacket):

#lang racket
(print "Hello World!")

It creates a tgz of 3.6 mb with an executable of 6.2 mb. This seems very large for this simplest program. Executable created by Chicken Scheme with same code (print "Hello World!") is of size 16984 bytes (16.6 kb) only.

I think I am missing something (possibly some optimization setting) while creating executable in Racket. How can this executable be made smaller?


Solution

  • The documentation for raco exe recommends using as small a base language as possible. In this case, replace #lang racket with #lang racket/base. On my machine (Linux, Racket 6.8) that drops the executable size from 6.6M to 988K.

    I was able to further reduce the size of the executable by running the demodularizer first. I saved the program as hello.rkt and ran

    $ raco demod hello.rkt
    $ raco exe -o hello hello_rkt_merged.zo
    

    That produces an executable of 277K.