Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: Why is GFor...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 27 of 30 Topic 4030 of 4136
Post > Topic >>

Re: Why is GForth-ITC fast?

by Thomas Pornin <pornin@[EMAIL PROTECTED] > May 2, 2008 at 06:11 PM

According to Albert van der Horst  <albert@[EMAIL PROTECTED]
>:
> But with c comes the c compiler, the c libraries etc. If you have to
> call the c-compiler anyway, there is not much charm left in Forth.

Note that I am taking a boringly practical point of view. If we go
aesthetics, then "small is beautiful" and Forth ****nes, no doubt about
that.


Calling the C library does not necessarily mean that you invoke a C
compiler. It means that you call a function which is located in a shared
library and happens to use a C calling convention. Of course, using the
C language and a C compiler is the easy way for that, because if there
is one thing C does well, it is calling C functions. It also somewhat
helps a bit because source compatibility works better than binary
compatibility.

An interesting comparison can be made with JOGL. It is a Java API for
OpenGL; mostly, a quite direct translation of the OpenGL constants and
functions calls in the Java syntax. The good part of it is that they did
it with an automatic translation tool: they ran a kind of C syntax
analyzer which generated the glue code. This tool needs not be run by
every developer; it needs be run only when the OpenGL API changes, which
does not occur every day.

You could envision the same kind of system. Basically, you have a C
library call, say gethostbyname(). It takes as input a pointer to the
host name (a zero-terminated C string) and returns a pointer to a
"struct hostent". What may change between brands of Unix, or between
versions of the same Unix system, is the layout of that structure. A
tool could be made, which explores that layout and outputs the layout
information as a set of constants usable from Forth. It could even
produce Forth words which access the structure. In essence, you are
simply -- and automatically -- translating the C header file into some
data which conveys the same information but in a non-C syntax.

That translation process needs not be repeated often. If you perform it
on a single machine, then the result is usable on all machines which
ensure binary compatibility with that machine (i.e. all installations of
the same version of the system on similar architectures). On other
machines, you can use the translated information to call the
gethostbyname() function, and you need neither gcc, nor the
"development" library (i.e. the header files and static version of the
library).

The most complex part in the whole system is that in order to use a
shared library, you need to produce a dynamically linked binary, which
is somewhat more difficult than producing a static binary. Especially if
you do it without the help of the local linker.


> I tried to statically link a c-program

Static linking is not really sup****ted anymore on modern Unix systems.
The libc developpers got hold of the idea that dynamic linking is the
"normal" model, and thus began to disregard issues related to static
linking. Pretty soon, the libc became too heavy and interrelated to
allow reasonable static linking. This is a trait common to pretty much
all existing Unix-like systems. Some more advanced features are even
available only if you use dynamic linking (e.g. thread-local storage
with the '__thread' extension keyword of gcc).

Which means that if you need to access the functionalities offered by
the libc, then you must get them through the way that libc was meant to
be used, i.e. with dynamic linking. That does not change my point, which
is that the libc does offer interesting functionalities which are not
easily reproduced, namely that it is configured for interaction with the
rest of the system and the network.


> It may be frowned upon, but adapting lina to new versions of OS's is
> probably less effort than gforth keeping up with new version of gcc.

Gforth not only calls the C library, it is also itself written in C,
which is an altogether distinct situation than what we are talking here.


	--Thomas ****in
 




 30 Posts in Topic:
Why is GForth-ITC fast?
brian.fox@[EMAIL PROTECTE  2008-04-30 19:30:05 
Re: Why is GForth-ITC fast?
"winston19842005@[EM  2008-04-30 21:29:44 
Re: Why is GForth-ITC fast?
Robert Spykerman <robe  2008-05-01 01:42:28 
Re: Why is GForth-ITC fast?
anton@[EMAIL PROTECTED]   2008-05-01 10:54:45 
Re: Why is GForth-ITC fast?
Albert van der Horst <  2008-05-01 17:26:57 
Re: Why is GForth-ITC fast?
stephenXXX@[EMAIL PROTECT  2008-05-01 22:22:50 
Re: Why is GForth-ITC fast?
stephenXXX@[EMAIL PROTECT  2008-05-01 09:00:18 
Re: Why is GForth-ITC fast?
Robert Spykerman <robe  2008-05-01 04:43:05 
Re: Why is GForth-ITC fast?
Thomas Pornin <pornin@  2008-05-01 12:45:38 
Re: Why is GForth-ITC fast?
stephenXXX@[EMAIL PROTECT  2008-05-01 12:56:26 
Re: Why is GForth-ITC fast?
Andrew Haley <andrew29  2008-05-01 11:41:05 
Re: Why is GForth-ITC fast?
anton@[EMAIL PROTECTED]   2008-05-01 18:22:56 
Re: Why is GForth-ITC fast?
Bernd Paysan <bernd.pa  2008-05-01 22:01:54 
Re: Why is GForth-ITC fast?
stephenXXX@[EMAIL PROTECT  2008-05-01 22:45:04 
Re: Why is GForth-ITC fast?
Thomas Pornin <pornin@  2008-05-01 23:44:26 
Re: Why is GForth-ITC fast?
Andrew Haley <andrew29  2008-05-02 04:27:59 
Re: Why is GForth-ITC fast?
Thomas Pornin <pornin@  2008-05-01 12:31:12 
Re: Why is GForth-ITC fast?
Albert van der Horst <  2008-05-01 16:33:12 
Re: Why is GForth-ITC fast?
brian.fox@[EMAIL PROTECTE  2008-05-01 17:12:16 
Re: Why is GForth-ITC fast?
mhx@[EMAIL PROTECTED] (M  2008-05-02 02:53:47 
Re: Why is GForth-ITC fast?
brian.fox@[EMAIL PROTECTE  2008-05-01 19:44:40 
Re: Why is GForth-ITC fast?
brian.fox@[EMAIL PROTECTE  2008-05-01 17:16:42 
Re: Why is GForth-ITC fast?
Robert Spykerman <robe  2008-05-01 20:17:47 
Re: Why is GForth-ITC fast?
Robert Spykerman <robe  2008-05-01 21:06:05 
Re: Why is GForth-ITC fast?
Thomas Pornin <pornin@  2008-05-02 13:00:46 
Re: Why is GForth-ITC fast?
Albert van der Horst <  2008-05-02 16:46:32 
Re: Why is GForth-ITC fast?
Thomas Pornin <pornin@  2008-05-02 18:11:41 
Re: Why is GForth-ITC fast?
Robert Spykerman <robe  2008-05-02 06:12:42 
Re: Why is GForth-ITC fast?
Robert Spykerman <robe  2008-05-02 17:40:35 
Re: Why is GForth-ITC fast?
Albert van der Horst <  2008-05-03 10:12:44 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 6:06:07 CDT 2008.