From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA30056; Thu, 13 Nov 2003 21:37:22 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA29882 for ; Thu, 13 Nov 2003 21:37:20 +0100 (MET) Received: from moby.atcorp.com (moby.atcorp.com [204.72.172.2]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hADKbJ128853 for ; Thu, 13 Nov 2003 21:37:19 +0100 (MET) Received: from atcorp.com (seahorse.atcorp.com [204.72.172.13]) by moby.atcorp.com (8.11.6/8.11.2) with ESMTP id hADKdoZ30594; Thu, 13 Nov 2003 14:39:51 -0600 Message-ID: <3FB3EB57.8070305@atcorp.com> Date: Thu, 13 Nov 2003 14:36:39 -0600 From: Eric Dahlman User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 To: John J Lee CC: caml-list@inria.fr Subject: Re: [Caml-list] Executable size? References: <3FB2B050.8050901@atcorp.com> <3FB3A6A6.8010108@atcorp.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 gcc:01 libgcc:01 runtime:01 runtime:01 statically:01 o'caml's:01 c's:01 envelope:99 language's:01 model:01 gcc:01 libgcc:01 dependencies:01 linked:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk John J Lee wrote: >>the setting up the initial environment. In the case of gcc this is >>captured in three files which a linked with each C program. They are >> >>crtbegin.o 1.6k >>crtend.o 1.2k >>libgcc.a 46.3k >> >>So it would be reasonable to say that the C runtime is 49k. >> >>Now in the case of O'Caml I don't know what the exact numbers are but >>the ZINC interpreter is on the order of 75k and that includes the ocaml >>runtime. So they are really similar, really the only big difference in >>runtime requirements for OCaml is the garbage collector. > > [...] > > OK. Getting back to the original question again (how to reduce data to be > transferred over the network), both O'Caml and C statically link this > runtime stuff, right? So, why is O'Caml's "hello world" (compressed) 45k, > to C's 1 or 2k? Is that 43k the garbage collector? Or is it mostly that > O'Caml, in contrast to C, is linking in a bunch of stuff from its standard > library that isn't strictly required for "hello world"? Or something else > again?? I can't say off hand and I don't have the time to research it. My back of the envelope guess is that it is just not worth the effort to throw more stuff away in ocaml. On a high level you can think of the language's runtime as providing the features of the hardware that it needs but are not present. So if you were to port ocaml to run on an old Symbolics Lisp machine you could rely on the hardware GC and leave that out of your runtime. This is where C has its first "advantage" in that it generally is a close match to the hardware model it is running on so there is less for the runtime to implement. If you want to get an idea of what is in such a runtime the documentation for the one GCC uses is here: http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc Now the second advantage that C has is that it is easier for the linker to identify which functions could never be called and strip them out of the resulting binary. That is why in the case of a simple hello world program you can get down to basically having none of the runtime code left. In the old days this was very important and I have used old Unix machines that only had static linking. Those machines also had tiny disk drives so there was significant pressure when C was developing to make sure you could strip everything down as much as possible. The basic problem with getting a language like ocaml down that small is that there is really no need or desire to do so and even then payoff is really small. You can only leave out the parts you don't use but then again if you want to do something cool you will be using those parts. You will only win if you are writing primitive C style programs in ocaml (not that C programs are primitive but a fancy C program would also pull in library dependencies). So I would say that it is totally possible to "enhance" a language like ocaml to generate tiny hello world executables, but I would much rather have the bright people working on O'Caml write something of more value. I know that my definition of value is probably at odds with yours in this case. ;-) -Eric ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners