* Why is ocaml so big?
@ 2008-01-11 12:39 Giles Constant
2008-01-11 15:24 ` [Caml-list] " Florent Monnier
2008-01-11 20:32 ` Lukasz Stafiniak
0 siblings, 2 replies; 8+ messages in thread
From: Giles Constant @ 2008-01-11 12:39 UTC (permalink / raw)
To: caml-list
Hiya,
I'm gradually falling in love with Ocaml, but my main hobby is writing demos,
mainly in the 64k category. Ocaml is a great way of writing small code, alas
it comes with a zonking great lump of baggage :-)
"Hello world" written in ocaml and compiled with ocamlopt is 81K on my 32 bit
linux box, which instantly rules it out. (running it through upx packer, it
comes out at 37k, which is still too high).
Are there any options which can strip this down to the bare minimum? I'm
guessing that much of the code in there is part of the garbage collection
code, in which case, I'll have to give up, but it would be nice to use
ocaml :-)
Thanks,
Giles
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Why is ocaml so big?
2008-01-11 12:39 Why is ocaml so big? Giles Constant
@ 2008-01-11 15:24 ` Florent Monnier
2008-01-11 20:32 ` Lukasz Stafiniak
1 sibling, 0 replies; 8+ messages in thread
From: Florent Monnier @ 2008-01-11 15:24 UTC (permalink / raw)
To: caml-list; +Cc: Giles Constant
Hi Giles,
I understand your problem, I don't know if it is possible to make a custom
version of ocamlopt, but one thing you could do would be to switch from
native code to bytecode.
A "hello world" compiled with ocamlc gives a result of 12K.
--
Regards
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Why is ocaml so big?
2008-01-11 12:39 Why is ocaml so big? Giles Constant
2008-01-11 15:24 ` [Caml-list] " Florent Monnier
@ 2008-01-11 20:32 ` Lukasz Stafiniak
2008-01-13 2:23 ` Joel Reymont
1 sibling, 1 reply; 8+ messages in thread
From: Lukasz Stafiniak @ 2008-01-11 20:32 UTC (permalink / raw)
To: Giles Constant; +Cc: caml-list
For a starter, try 3.10.1 with -nopervasives:
- PR#4174 ocamlopt: fixed ocamlopt -nopervasives
On Jan 11, 2008 1:39 PM, Giles Constant <giles@spacepigs.com> wrote:
> Hiya,
>
> I'm gradually falling in love with Ocaml, but my main hobby is writing demos,
> mainly in the 64k category. Ocaml is a great way of writing small code, alas
> it comes with a zonking great lump of baggage :-)
>
> "Hello world" written in ocaml and compiled with ocamlopt is 81K on my 32 bit
> linux box, which instantly rules it out. (running it through upx packer, it
> comes out at 37k, which is still too high).
>
> Are there any options which can strip this down to the bare minimum? I'm
> guessing that much of the code in there is part of the garbage collection
> code, in which case, I'll have to give up, but it would be nice to use
> ocaml :-)
>
> Thanks,
>
> Giles
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Why is ocaml so big?
2008-01-11 20:32 ` Lukasz Stafiniak
@ 2008-01-13 2:23 ` Joel Reymont
2008-01-13 9:24 ` Dominique Martinet
0 siblings, 1 reply; 8+ messages in thread
From: Joel Reymont @ 2008-01-13 2:23 UTC (permalink / raw)
To: Lukasz Stafiniak; +Cc: Giles Constant, caml-list
On Jan 11, 2008, at 8:32 PM, Lukasz Stafiniak wrote:
> For a starter, try 3.10.1 with -nopervasives:
> - PR#4174 ocamlopt: fixed ocamlopt -nopervasives
Is it possible to see a small example of how this works?
This doesn't work for me:
ocamlopt -nostdlib -nopervasives -o hello pervasives.cmx hello.ml
File "hello.ml", line 1, characters 0-23:
Unbound value Pervasives.print_string
Thanks, Joel
--
http://wagerlabs.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Why is ocaml so big?
2008-01-13 2:23 ` Joel Reymont
@ 2008-01-13 9:24 ` Dominique Martinet
2008-01-13 11:30 ` Lukasz Stafiniak
0 siblings, 1 reply; 8+ messages in thread
From: Dominique Martinet @ 2008-01-13 9:24 UTC (permalink / raw)
To: Joel Reymont; +Cc: Lukasz Stafiniak, caml-list, Giles Constant
The -nopervasive switch simply does not load the Pervasive module
which is integrated in any executable ocaml normally produce... And
you're here using print_string which is in this module :)
Well, all the ways I know to output strings or whatever use Pervasive,
so I can't help you to replace it (I think even stdout is defined in
Pervasive~), but if you only want to get a small executable (let's say
you don't mind to return the int 42, instead of printing it), this
could help.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Why is ocaml so big?
2008-01-13 9:24 ` Dominique Martinet
@ 2008-01-13 11:30 ` Lukasz Stafiniak
2008-01-13 11:46 ` Paolo Donadeo
0 siblings, 1 reply; 8+ messages in thread
From: Lukasz Stafiniak @ 2008-01-13 11:30 UTC (permalink / raw)
To: caml-list, Giles Constant
On Jan 13, 2008 10:24 AM, Dominique Martinet <asmadeus77@gmail.com> wrote:
>
> Well, all the ways I know to output strings or whatever use Pervasive,
> so I can't help you to replace it (I think even stdout is defined in
> Pervasive~), but if you only want to get a small executable (let's say
> you don't mind to return the int 42, instead of printing it), this
> could help.
>
You need to write your own tailored version of "Pervasives".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Why is ocaml so big?
2008-01-13 11:30 ` Lukasz Stafiniak
@ 2008-01-13 11:46 ` Paolo Donadeo
2008-01-14 2:04 ` Stefan Monnier
0 siblings, 1 reply; 8+ messages in thread
From: Paolo Donadeo @ 2008-01-13 11:46 UTC (permalink / raw)
To: Lukasz Stafiniak; +Cc: caml-list
> You need to write your own tailored version of "Pervasives".
A simple question: is OCaml the right tool for a 64K demo? I don't think so...
--
Paolo
Paolo Donadeo, Senior Software Engineer
Studio Associato 4Sigma
Email: p.donadeo@4sigma.it
~
~
:wq
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why is ocaml so big?
2008-01-13 11:46 ` Paolo Donadeo
@ 2008-01-14 2:04 ` Stefan Monnier
0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2008-01-14 2:04 UTC (permalink / raw)
To: caml-list
>> You need to write your own tailored version of "Pervasives".
> A simple question: is OCaml the right tool for a 64K demo? I don't think so...
Depends on how you define "64KB" (especially, how do you count shared
libraries and interpreters). Compiling with the byte-compiler should
result in reasonably compact code.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-01-14 2:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-11 12:39 Why is ocaml so big? Giles Constant
2008-01-11 15:24 ` [Caml-list] " Florent Monnier
2008-01-11 20:32 ` Lukasz Stafiniak
2008-01-13 2:23 ` Joel Reymont
2008-01-13 9:24 ` Dominique Martinet
2008-01-13 11:30 ` Lukasz Stafiniak
2008-01-13 11:46 ` Paolo Donadeo
2008-01-14 2:04 ` Stefan Monnier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox