[racket] #lang racket vs. racket/base

From: Manfred Lotz (manfred.lotz at arcor.de)
Date: Wed Feb 12 08:59:01 EST 2014

On Wed, 12 Feb 2014 06:07:17 -0700
Matthew Flatt <mflatt at cs.utah.edu> wrote:

> At Wed, 12 Feb 2014 06:02:30 +0100, Manfred Lotz wrote:
> > I just read Neil van Dyke's statement:
> > 
> > < "#lang racket" is for demos, IMHO; I *always* use "#lang
> > racket/base" < for any code that's not a demo.
> > 
> > Question: What are the advantages of doing requires explicitly?
> > 
> > In a program of mine I changed #lang racket to #lang racket/base and
> > added:
> > 
> > (require racket/cmdline)
> > (require racket/string)
> > (require racket/format)
> > (require racket/port)
> > (require racket/path)
> > (require racket/list)
> > 
> > 
> > The resulting executable (created by raco exe...) had the same size.
> 
> I'm surprised that they were the same size, assuming that you didn't
> import other libraries that have more dependencies.
> 
> With these two files:
> 
>  r.rkt
>  -----
>  #lang racket
> 
> 

My system is a 64 bit Fedora 20.

Size here is: 5045135

>  b.rkt
>  -----
>  #lang racket/base
>  (require racket/cmdline
>           racket/string
>           racket/format
>           racket/port
>           racket/path
>           racket/list)
> 
> on my machine, `raco exe b.rkt` produces a 2.4 MB executable, while
> `raco exe r.rkt` produces a 5.2MB executable.
> 

Hm, ok you are right. This one has size: 2123527

I had to add more stuff:

racket/date which makes it much larger: 4029753


(require openssl)
(require openssl/sha1)

which makes a size of: 4511202


In my source I found a mistake. I had a require for a file.rkt
which still had racket instead of racket/base. Changing this saved me 1
MB compared to the initial 5602007 bytes size. 


> There's a similarly significant difference in startup times for me:
> 
>  laptop% time racket -l racket/base
>  0.030u 0.013s 0:00.04 100.0%	0+0k 0+0io 0pf+0w
>  laptop% time racket -l racket/base -l racket/string -l
> racket/cmdline \ -l racket/format -l racket/port -l racket/path -l
> racket/list 0.103u 0.029s 0:00.13 92.3%	0+0k 0+0io 0pf+0w
>  laptop% time racket -l racket
>  0.155u 0.041s 0:00.19 100.0%	0+0k 0+0io 0pf+0w
> 

These times are similar on my system.



-- 
Manfred



Posted on the users mailing list.