Re: tcc

Adrian von Bidder <[email protected]>
Newsgroups gmane.linux.debian.curiosa
Message-ID <[email protected]>
Yodel!

On Friday 13 March 2009 10:28:08 Giacomo A. Catenazzi wrote:
> Adam Borowski wrote:
> > On Wed, Mar 11, 2009 at 11:21:08PM +0100, Stefano Zacchiroli wrote:

> >> A C source file by itself cannot be run
> >> without having been compiled
> > 
> > I guess you haven't seen the Real Men's only true scripting language.
> > 
> > apt-get install tcc
...
> It is not real C  ;-)
> 
> few assumptions on compiled language doesn't allow you to
> interpret a compiled language (and usually also the contrary).
> Few programs use such assumptions, but anyway...

While I agree that modern (dynamically typed etc.) scripting languages 
cannot easily be compiled (note that this is only a practical difference, 
not a theoretical one), I fail to see the difficulty with executing C from 
an interpreter.  In fact C makes quite few assumptions about the runtime 
environment and doesn't expect much/any behind the scenes magic to happen.  
I bet a C interpreter could even be written so that it only uses memory when 
the C source also would allocate memory (entering a stack frame and malloc)
[1], so while the interpreted program would probably hit OOM earlier then 
the compiled one, it would still do so only at the same places that a 
compiled program might hit OOM.

[1] One obvious way is to parse a whole function on entering it.  Given the 
low complexity of plain C code, it can then be executed without allocating 
further memory by just jumping around in the parse tree.

cheers
-- vbi


-- 
featured product: Debian GNU/Linux - http://debian.org
signature.asc (application/pgp-signature, 254 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: get my key from http://fortytwo.ch/gpg/92082481

iEYEABECAAYFAkm6UdYACgkQKqpm2L3fmXoazwCgm20CilvMoOKWAli2hnPoxxC1
+DAAnj416ouxUO9f+SwMT8gTTI+j9HlU
=4e50
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.