For Programmers: Free Programming Magazines  


Home > Archive > Prolog > May 2006 > Why Not Prolog in Prolog ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Why Not Prolog in Prolog ?
newser.bbs@bbs.ee.ncu.edu.tw

2006-04-28, 10:01 pm

Prolog can do anything that C or C++ can do.
But for the 2 outstanding prolog systems , SWI- and GNU prolog ,
the source codes are not written in prolog .
Why not ?
If only it was in prolog !
Really if only !!

A..L.

2006-04-29, 8:01 am

On 28 Apr 2006 18:27:44 -0700, newser.bbs@bbs.ee.ncu.edu.tw wrote:

>Prolog can do anything that C or C++ can do.
>But for the 2 outstanding prolog systems , SWI- and GNU prolog ,
>the source codes are not written in prolog .
>Why not ?


Do this yourself.

A.L.
Duncan Patton

2006-04-30, 7:05 pm

On 28 Apr 2006 18:27:44 -0700
newser.bbs@bbs.ee.ncu.edu.tw wrote:

> Prolog can do anything that C or C++ can do.
> But for the 2 outstanding prolog systems , SWI- and GNU prolog ,
> the source codes are not written in prolog .
> Why not ?
> If only it was in prolog !
> Really if only !!
>


Bootstrap/portability. And if you watch when you build Gprolog,
you will notice a lot of it _is_ written in prolog.

Dhu

--
???????????????????????????????????????

Open Systems Integration

Contact Fubar the Hack: fubar AT neotext.ca

Area code seven eight zero, Exchange four six six, Local zero one zero nine

Highland terms, Canadian workmanship.

All persons named herein are purely fictional victims
of the Canidian Bagle Breeder's Association.

Save the Bagle!

Sun Dhu


???????????????????????????????????????

newser.bbs@bbs.ee.ncu.edu.tw

2006-05-01, 4:07 am

Duncan Patton wrote:
> Bootstrap/portability. And if you watch when you build Gprolog,


I don't think bootstrap or portability prevents Prolog from written in
prolog.
It is a common sense that Forth language gets its portability mainly
via
metacompilation. Why not prolog in the same way ? Prolog is not a
language
inferior to Forth. Writing a metacompiler must be a small cake.

I don't think written in C/C++ really gives prolog portability. Eg.
SWI-prolog
was said to be compiled with Visual C/C++. But I have only BC 4.5 in my

PC. Do you really think that SWI-prolog can be bootstrapped from the
source
codes in my PC ?

> you will notice a lot of it _is_ written in prolog.


Duncan Patton

2006-05-01, 4:07 am


ovis sshd[45386]: reverse mapping checking getaddrinfo for 225-244-210 static-13.uline.com.tw failed - POSSIBLE BREAKIN ATTEMPT!

Is someone trying to get my attention?

Dhu

On 28 Apr 2006 18:27:44 -0700
newser.bbs@bbs.ee.ncu.edu.tw wrote:

> Prolog can do anything that C or C++ can do.
> But for the 2 outstanding prolog systems , SWI- and GNU prolog ,
> the source codes are not written in prolog .
> Why not ?
> If only it was in prolog !
> Really if only !!
>



--
???????????????????????????????????????

Open Systems Integration

Contact Fubar the Hack: fubar AT neotext.ca

Area code seven eight zero, Exchange four six six, Local zero one zero nine

Highland terms, Canadian workmanship.

All persons named herein are purely fictional victims
of the Canidian Bagle Breeder's Association.

Save the Bagle!

Sun Dhu


???????????????????????????????????????

A..L.

2006-05-01, 8:01 am

On 30 Apr 2006 22:22:12 -0700, newser.bbs@bbs.ee.ncu.edu.tw wrote:

>Duncan Patton wrote:
>
>I don't think bootstrap or portability prevents Prolog from written in
>prolog.
>It is a common sense that Forth language gets its portability mainly
>via
>metacompilation. Why not prolog in the same way ? Prolog is not a
>language
>inferior to Forth. Writing a metacompiler must be a small cake.


Somebody told you already: read books.

A.L>
newser.bbs@bbs.ee.ncu.edu.tw

2006-05-01, 8:01 am


A..L. wrote:

> On 30 Apr 2006 22:22:12 -0700, newser.bbs@bbs.ee.ncu.edu.tw wrote:
>
>
> Somebody told you already: read books.
>
> A.L>


OK, please tell me the name of the books that explain and demonstrate
metacompilation of prolog in FORTH's way. Please tell me the name of
the books that contain the codes that use prolog only to port prolog to

other machines or OS .

Or , in fact there is no such single book , thus you can tell me
nothing ?

Cesar Rabak

2006-05-01, 7:03 pm

newser.bbs@bbs.ee.ncu.edu.tw escreveu:
> A..L. wrote:
>
>
>
>
> OK, please tell me the name of the books that explain and demonstrate
> metacompilation of prolog in FORTH's way. Please tell me the name of
> the books that contain the codes that use prolog only to port prolog to
> other machines or OS .


You want to teach us how to do a Prolog system written in Prolog a la
"FORTH's way" or are you _wishing_ such a thing existed?

>
> Or , in fact there is no such single book , thus you can tell me
> nothing ?
>


There lots of books which collectively will give you the knowledge to
get where you want.

Did you research? Did you, for start, read the FAQ of this NG?
AL.

2006-05-01, 7:03 pm

On 1 May 2006 06:28:55 -0700, newser.bbs@bbs.ee.ncu.edu.tw wrote:

>
>
>OK, please tell me the name of the books that explain and demonstrate
>metacompilation of prolog in FORTH's way.


I dont't know what this means "FORTH way". Maybe you should ask on
Forth group?

A.L.
AL.

2006-05-01, 7:03 pm

On 1 May 2006 06:28:55 -0700, newser.bbs@bbs.ee.ncu.edu.tw wrote:


>OK, please tell me the name of the books that explain and demonstrate
>metacompilation of prolog in FORTH's way. Please tell me the name of
>the books that contain the codes that use prolog only to port prolog to
>
>other machines or OS .
>
>Or , in fact there is no such single book , thus you can tell me
>nothing ?



Start from here

http://ktiml.mff.cuni.cz/~bartak/pr..._interpret.html

A.L.
newser.bbs@bbs.ee.ncu.edu.tw

2006-05-01, 7:03 pm


AL. wrote:
> Start from here
>
> http://ktiml.mff.cuni.cz/~bartak/pr..._interpret.html


Oh, let me say thank you to you . Yes , it is start , the very
start, but nothing else. Too far away from boostraping in other
machine or OS. Thus you confirmed the truth that there is no
such a book .

AL.

2006-05-01, 7:03 pm

On 1 May 2006 09:45:41 -0700, newser.bbs@bbs.ee.ncu.edu.tw wrote:

>
>AL. wrote:
>
>Oh, let me say thank you to you . Yes , it is start , the very
>start, but nothing else. Too far away from boostraping in other
>machine or OS. Thus you confirmed the truth that there is no
>such a book .


OK, what you exactly want? If you bootrstrap Pascal or Forth, you
cannot start from just plain Pascal or Forth. You have to write a
mimimal runtime environment that will be able to process the first
layer of bootstraping. In case of Pascal, this is Pascal virtual
machine. Then you have Pascal compiler compiled to VM (on other
nachine) that is the first step in bootstraping. In Prolog, you have
WAM. Yes, there is a book about WAM, and this book is free

http://www.vanx.org/archive/wam/wam.html

This is first thing to implement if you want to bootstrap Prolog.

A.L.
fox@ultratechnology.com

2006-05-01, 7:03 pm

AL. wrote:
> Start from here
>
> http://ktiml.mff.cuni.cz/~bartak/pr..._interpret.html


That was helpful. I still am not clear whether it is like a
metacompiler in Forth. Forth has a command interpreter
and one can compile a new command interperter on top
of the old command interpreter and extend the functionality
of the Forth. This sounds a little like the examples of
adding a meta-interpeter to prolog to put a new interpeter
with a new feature on top of the old one.

Metacompilation in Forth is something else. In
metacompilation a systemcompiles a new system. When
the application compiled by a Forth system is a new and
seperate Forth system it is called metacompilation. The
result is a new Forth that is not part of the Forth that created
it. It is a little more complicated than just compiling regular
applications because their will be lots of name conflicts to
resovle between the two systems.

It is like compiling a copy of GCC with GCC. When you are
done you have a second, and new and different copy of GCC.
You don't get a different GCC command interpreter added
to the one you already had.

I think the original question was if Prolog is used to generate
each new version of the language in Prolog or does it get
written in something else like C? The OP stated that Prolog
should be able to do whatever C can.

In 'the Forth way' the source code to everything may be
written in Forth in an integrated way so that the OS, the
compiler, the command interpreter, and an editor need
a couple dozen KB of source and with a little bit more can
compile a new OS, compiler, interpeter, and editor for
a new and different computer in a single pass that might
take from a few microsends to a few milliseconds. It
does not require other languages and operating systems
to metacompile a completely new Forth environment
including applications for a completely new computer.

C does something similar but needs lots of external stuff
and multiple passes and a lot more code and lot more time.
With C you can use GCC to compile a new OS, new GCC and
new application for GCC for a new computer. It is never going
to happen in a microsecond but at least C can do it.

So I think the OP wanted to know if anyone did something like that
in Prolog. In C the OS is usually in C and the source code to the
C compiler and the source code to your app is in C and C can
compile everything and create a whole new environment for a new
machine in C. Other than an assembler everything can be C.
In Forth everything can be in Forth and it can be smaller and
compile faster. Are people doing that with Prolog? If not why not?

If I tried to answer the question I would just be guessing as
would the op.

newser.bbs@bbs.ee.ncu.edu.tw

2006-05-01, 7:03 pm

Cesar Rabak wrote:
> You want to teach us how to do a Prolog system written in Prolog a la
> "FORTH's way" or are you _wishing_ such a thing existed?


I think such a thing exists . Prolog is a very powerful tool . I have
seen
a compiler of another language written in Turbo prolog with about 600
lines
of codes . Thus I think such a thing exists. But I can't find that
after I have
tried my best efforts. Thus I ask if any of you seen such a thing .

> There lots of books which collectively will give you the knowledge to
> get where you want.


My question is if such a thing exists , where is it ?
You didn't seem to have the answer.

> Did you research? Did you, for start, read the FAQ of this NG?


I have ever thought over this problem. The assembler of the target
machine has to be written first with prolog . Then , the other part
of the codes can be based on the assembler. Of course some
tricks are necessary . Eg , we have to find a way to decide the branch
adress in the target machine.

AL.

2006-05-01, 7:03 pm

On 1 May 2006 09:45:41 -0700, newser.bbs@bbs.ee.ncu.edu.tw wrote:

>
>AL. wrote:
>
>Oh, let me say thank you to you . Yes , it is start , the very
>start, but nothing else. Too far away from boostraping in other
>machine or OS. Thus you confirmed the truth that there is no
>such a book .



How to bootstrap Prolog to Java using WAM see here

http://www.binnetcorp.com/OpenCode/free_prolog.html

A.L.
fox@ultratechnology.com

2006-05-01, 7:03 pm

Thanks, I think that answered the original question. It looks like
metacompilation to me. Prolog compiling Prolog in Prolog.

newser.bbs@bbs.ee.ncu.edu.tw

2006-05-01, 7:03 pm

Thank you , I'll read that.

newser.bbs@bbs.ee.ncu.edu.tw

2006-05-01, 7:03 pm

Thanks for understanding me so much .
Thanks again .

John Doty

2006-05-01, 7:03 pm

newser.bbs@bbs.ee.ncu.edu.tw wrote:
> Duncan Patton wrote:
>
>
>
> I don't think bootstrap or portability prevents Prolog from written in
> prolog.
> It is a common sense that Forth language gets its portability mainly
> via
> metacompilation.


Some Forths do, others don't. Some Forths *are* written in C. Somehow
you need to get down to the hardware, so somebody needs to code up some
way to generate machine code for the machine in question. C can function
as a "portable assembly language" for this purpose, allowing you to
leverage the work the C community has put into portability. Whether this
is good or bad depends on your application requirements.

> Why not prolog in the same way ? Prolog is not a
> language
> inferior to Forth. Writing a metacompiler must be a small cake.


Why? What application requirement would this serve?

--
---
John Doty, Noqsi Aerospace, Ltd.
---
His diagnosis of the hostility ... reflects the willful blindness of the
invader who assures himself that the natives are only made unfriendly by
some other provocation than his own. -Barbara W. Tuchman
Cesar Rabak

2006-05-01, 7:03 pm

fox@ultratechnology.com escreveu:
> AL. wrote:
>
>
>
> That was helpful. I still am not clear whether it is like a
> metacompiler in Forth. Forth has a command interpreter
> and one can compile a new command interperter on top
> of the old command interpreter and extend the functionality
> of the Forth. This sounds a little like the examples of
> adding a meta-interpeter to prolog to put a new interpeter
> with a new feature on top of the old one.
>


I think you folks who have this doubt (and undertand why it is valuable
to have it) have to peruse the docs and arrive at a conclusion on that.

[snippped]

> So I think the OP wanted to know if anyone did something like that
> in Prolog. In C the OS is usually in C and the source code to the
> C compiler and the source code to your app is in C and C can
> compile everything and create a whole new environment for a new
> machine in C. Other than an assembler everything can be C.
> In Forth everything can be in Forth and it can be smaller and
> compile faster. Are people doing that with Prolog? If not why not?


What you describe seems similar on what GNU Prolog makes possible via
the generation (compiling) a new top-level. For a discussion on this,
pls refer to the part 3.4.5 of the GNU Prolog Manual.

HTH

--
Cesar Rabak
Cesar Rabak

2006-05-01, 7:03 pm

newser.bbs@bbs.ee.ncu.edu.tw escreveu:
> Cesar Rabak wrote:
>
>
>
> I think such a thing exists . Prolog is a very powerful tool . I have
> seen
> a compiler of another language written in Turbo prolog with about 600
> lines
> of codes . Thus I think such a thing exists. But I can't find that
> after I have
> tried my best efforts. Thus I ask if any of you seen such a thing .
>
>
>
>
> My question is if such a thing exists , where is it ?
> You didn't seem to have the answer.


Your search efforts doesn't seem to convince too many people. Look in
the Net for EZY Prolog and see how it was built.

>
>
>
>
> I have ever thought over this problem. The assembler of the target
> machine has to be written first with prolog . Then , the other part
> of the codes can be based on the assembler. Of course some
> tricks are necessary . Eg , we have to find a way to decide the branch
> adress in the target machine.
>


This repply seems to be written by a bot and not an intelligent
person... Did you already did the research on the subject as we suggested?
felipemonteiro.carvalho@gmail.com

2006-05-01, 7:03 pm

Actually this depends on the compiler.

Free Pascal compiler is very capable of cross-compiling easely, so no
Virtual Machine is needed for bootstraping.

You just need to implement a new Runtime library for the new target,
cross-compile the compiler for the target and that's it =)

Now the newly produced compiler can compile itself and other pascal
projects.

newser.bbs@bbs.ee.ncu.edu.tw

2006-05-01, 7:03 pm

felipemonteiro.carvalho@gmail.com =E5=AF=AB=E9=81=93=EF=BC=9A

> Actually this depends on the compiler.
>
> Free Pascal compiler is very capable of cross-compiling easely, so no
> Virtual Machine is needed for bootstraping.


No , no needed. Nor is Warren's Abstract Machine needed for building
prolog. An elegant example is seen in Paul Graham's out standing book
<<On Lisp>> ( http://www.paulgraham.com/lib/paulgraham/onlisp.pdf).

>
> You just need to implement a new Runtime library for the new target,


Yes, as John Doty said : "Somehow you need to get down to the
hardware, so somebody needs to code up some way to generate
machine code for the machine in question ."
And this "somehow" needs not to be C/C++. For pascal , it can be
pascal . For prolog , it should be possible to be prolog.

> cross-compile the compiler for the target and that's it =3D)
>
> Now the newly produced compiler can compile itself and other pascal
> projects.


newser.bbs@bbs.ee.ncu.edu.tw

2006-05-01, 7:03 pm

fox@ultratechnology.com wrote:
>
> So I think the OP wanted to know if anyone did something like that
> in Prolog. In C the OS is usually in C and the source code to the
> C compiler and the source code to your app is in C and C can
> compile everything and create a whole new environment for a new
> machine in C. Other than an assembler everything can be C.
> In Forth everything can be in Forth and it can be smaller and
> compile faster. Are people doing that with Prolog? If not why not?
>

Jeff ( if I mistake you for Jeff fox , whom I respect very much , I
say sorry to you), thank you for understanding me and explaining
my question so detailly and thoroghly.

Duncan Patton

2006-05-01, 10:01 pm

On 1 May 2006 16:11:02 -0700
newser.bbs@bbs.ee.ncu.edu.tw wrote:

> And this "somehow" needs not to be C/C++. For pascal , it can be
> pascal . For prolog , it should be possible to be prolog.
>


Umn, why? At the machine layer there's not gonna be much
difference, so once someone goes thru the trouble in C, there's
not much real value in "pure" X, Y or Z.

Dhu


--
???????????????????????????????????????

Open Systems Integration

Contact Fubar the Hack: fubar AT neotext.ca

Area code seven eight zero, Exchange four six six, Local zero one zero nine

Highland terms, Canadian workmanship.

All persons named herein are purely fictional victims
of the Canidian Bagle Breeder's Association.

Save the Bagle!

Sun Dhu


???????????????????????????????????????

Duane Rettig

2006-05-02, 4:02 am

Duncan Patton <campbell@neotext.ca> writes:

> On 1 May 2006 16:11:02 -0700
> newser.bbs@bbs.ee.ncu.edu.tw wrote:
>
>
> Umn, why? At the machine layer there's not gonna be much
> difference, so once someone goes thru the trouble in C, there's
> not much real value in "pure" X, Y or Z.


I was hoping to stay out of this, especially since it is crossposted.
I don't know particulars about prolog-in-prolog implementation (we
do have a prolog, very fast, implemented in Allegro CL, but that's
another story). But though Prolog may not have special needs not
easily satisfied by C, Lisp, and especially Common Lisp, certainly
does. I wrote about it many years ago on c.l.l and I present it
here for your consideration. It should answer your question "why?"
(as in "why bother implementing language-X in language-X?").

http://groups.google.com/group/comp...6d32a463068044e

You can look at the whole thread by selecting the "show options"
link and selecting "View Thread".

--
Duane Rettig duane@franz.com Franz Inc. http://www.franz.com/
555 12th St., Suite 1450 http://www.555citycenter.com/
Oakland, Ca. 94607 Phone: (510) 452-2000; Fax: (510) 452-0182
Duncan Patton

2006-05-02, 4:02 am

On Mon, 01 May 2006 23:46:54 -0700
Duane Rettig <duane@franz.com> wrote:

> Duncan Patton <campbell@neotext.ca> writes:
>
>
> I was hoping to stay out of this, especially since it is crossposted.
> I don't know particulars about prolog-in-prolog implementation (we
> do have a prolog, very fast, implemented in Allegro CL, but that's
> another story). But though Prolog may not have special needs not
> easily satisfied by C, Lisp, and especially Common Lisp, certainly
> does. I wrote about it many years ago on c.l.l and I present it
> here for your consideration. It should answer your question "why?"
> (as in "why bother implementing language-X in language-X?").
>


Thanks. The question wasn't entirely rhetorical. There's another
answer that you might be aware of. I read/hear an anecdote of
John McCarthy's once (can't find it now) where he recalled one
of the comments brought up in his original lisp dissertation(?).
Somebody stood up and said, "Yah, but I could have done that
all in assembler". McCarthy says he came up with the _right_
answer some hours too late: "Yah, but you didn't."

Dhu (I probably got some of it wrong... would be nearly thirty ybp I read it).


> http://groups.google.com/group/comp...6d32a463068044e
>
> You can look at the whole thread by selecting the "show options"
> link and selecting "View Thread".
>
> --
> Duane Rettig duane@franz.com Franz Inc. http://www.franz.com/
> 555 12th St., Suite 1450 http://www.555citycenter.com/
> Oakland, Ca. 94607 Phone: (510) 452-2000; Fax: (510) 452-0182



--
???????????????????????????????????????

Open Systems Integration

Contact Fubar the Hack: fubar AT neotext.ca

Area code seven eight zero, Exchange four six six, Local zero one zero nine

Highland terms, Canadian workmanship.

All persons named herein are purely fictional victims
of the Canidian Bagle Breeder's Association.

Save the Bagle!

Sun Dhu


???????????????????????????????????????

Bernd Paysan

2006-05-02, 8:02 am

John Doty wrote:
>
> Why? What application requirement would this serve?


What about size and speed? Prolog usually is translated into a virtual
machine, developed in the early days of Prolog (google for "Warren's
Abstract Machine"). This virtual machine provides primitives for
backtracking and such things special to Prolog, and ordinary operations
(not special to Prolog). The typical way to write a Prolog system then is
to write an interpreter for the WAM, and let a Prolog compiler transform
the source to WAM binaries.

Now, that means most of the "Prolog metacompiler" job is already done - the
only thing *not* written in Prolog is the WAM interpreter. Now, if you
think a bit further, you can easily see that the WAM code can be compiled
instead of interpreted, and writing a compiler backend is in fact a small
cake in Prolog. So what do you get? A faster, smaller, more difficult to
port Prolog (since now the work for targetting the host is the Prolog
system developer's work).

--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/
Duane Rettig

2006-05-02, 7:04 pm

Duncan Patton <campbell@neotext.ca> writes:

> On Mon, 01 May 2006 23:46:54 -0700
> Duane Rettig <duane@franz.com> wrote:
>
>
> Thanks. The question wasn't entirely rhetorical.


That's why I answered it. I didn't view it as rhetorical at all.

> There's another
> answer that you might be aware of. I read/hear an anecdote of
> John McCarthy's once (can't find it now) where he recalled one
> of the comments brought up in his original lisp dissertation(?).
> Somebody stood up and said, "Yah, but I could have done that
> all in assembler". McCarthy says he came up with the _right_
> answer some hours too late: "Yah, but you didn't."


Don't remember seeing that, but it was likely just before the guy
actually implemented it...

The present attitude/memory of McCarthy, according to many of the recent
talks he's given at "ILC" (International Lisp Conference) events is that
he had originally intended Lisp not to be implemented at all; he thought
of it more as a mathematical calculus rather than a programming language
per se.

And yes, over the years, Lisp has been implemented in many different
languages. But that it it turing complete should be proof enough that
it can generate the streams of bits that make up a compiled program,
native or byte in nature. And once one writes a native assembler in
Lisp for the target architecture, it actually becomes more maintainable
than relying on underlying languages over which one has little or no
control, since the process is controlled all the way down to the bit
level, without the need for a linker, by the lisp itself.

--
Duane Rettig duane@franz.com Franz Inc. http://www.franz.com/
555 12th St., Suite 1450 http://www.555citycenter.com/
Oakland, Ca. 94607 Phone: (510) 452-2000; Fax: (510) 452-0182
John Doty

2006-05-02, 7:04 pm

Bernd Paysan wrote:

> John Doty wrote:
>
>
>
> What about size and speed?


Sure. Is that the OP's requirement? He mentioned "portability"...

> ...
> So what do you get? A faster, smaller, more difficult to
> port Prolog (since now the work for targetting the host is the Prolog
> system developer's work).


Sure, that's the tradeoff. But what does the OP's application need?
While requirements are troublesome when in direct control of an
engineering process, they can be very useful as tools to provoke
thought. It's like the difference between driving and navigation.

--
---
John Doty, Noqsi Aerospace, Ltd.
---
His diagnosis of the hostility ... reflects the willful blindness of the
invader who assures himself that the natives are only made unfriendly by
some other provocation than his own. -Barbara W. Tuchman
Albert van der Horst

2006-05-02, 7:04 pm

In article <1146525695.054513.277180@y43g2000cwc.googlegroups.com>,
<newser.bbs@bbs.ee.ncu.edu.tw> wrote:[color=darkred]
>fox@ultratechnology.com wrote:

Whoever thinks that (s)he can write a compiler, without knowing
about the underlying processor is wrong. The best you can come
up with in portable c is a c-interpreter with an added level
of overhead. Same for Forth, same for Prolog.

Meta-compilers, which is forthism for forth compilers written
in forth, always have an assembler within them, to cope
with the machine dependancies. (Whereas some c-compilers
generate machine code directly, without an intermediate assembler,
Turbo C, e.g.)

Groetjes Albert

--
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
albert@spenarnc.xs4all.nl http://home.hccnet.nl/a.w.m.van.der.horst
Anton Ertl

2006-05-02, 7:04 pm

Albert van der Horst <albert@spenarnc.xs4all.nl> writes:
>Whoever thinks that (s)he can write a compiler, without knowing
>about the underlying processor is wrong.


You are wrong about that. Read up on it in

@Article{collberg02,
author = {Christian S. Collberg},
title = {Automatic derivation of compiler machine
descriptions},
journal = toplas,
year = {2002},
volume = {24},
number = {4},
pages = {369--408},
month = jul,
annote = {Journal version of \cite{collberg97}. Extracts a
machine description (for an assembler-generating
code generator) out of a working C compiler by
compiling various test programs to assembly
language, and analysing the resulting
output. Presents various innovative techniques for
achieving this result.}
}

Ok, someone once had to know about the machine to write the first
compiler, but once that's done, other compilers can just extract the
machine knowledge from the first compiler (if the programming language
of the first compiler allows it).

BTW, a good part of the source of Collberg's prototype
(http://www.cs.arizona.edu/~collberg...ting/index.html)
is written in Prolog.

Collberg still went through an assembler, but you can vary his ideas
to work on binary code. A part of this was done in

@InProceedings{ertl&gregg04pact,
author = {M. Anton Ertl and David Gregg},
title = {Retargeting {JIT} compilers by using {C}-compiler
generated executable code},
crossref = {pact04},
pages = {41--50},
URL = {http://www.complang.tuwien.ac.at/pa...egg04pact.ps.gz},
abstract = {JIT compilers produce fast code, whereas
interpreters are easy to port between
architectures. We propose to combine the advantages
of these language implementation techniques as
follows: we generate native code by concatenating
and patching machine code fragments taken from
interpreter-derived code (generated by a C
compiler); we completely eliminate the interpreter
dispatch overhead and accesses to the interpreted
code by patching jump target addresses and other
constants into the fragments. In this paper we
present the basic idea, discuss some issues in more
detail, and present results from a proof-of-concept
implementation, providing speedups of up to 1.87
over the fastest previous interpreter-based
technique, and performance comparable to simple
native-code compilers. The effort required for
retargeting our implementation from the 386 to the
PPC architecture was less than a person-day.}
}

@Proceedings{pact04,
title = {Parallel Architecture and Compilation Techniques (PACT' 04)},
booktitle = {Parallel Architecture and Compilation Techniques (PACT' 04)},
year = {2004},
key = {PACT '04},
OPTpublisher = {IEEE}
}

And to be relevant to the other newsgroup this is posted in, this idea
was demonstrated in a Forth system.

Concerning Prolog in Prolog, this has been done. E.g., the first
implementation of the VAM_1P compiler was written in Prolog, and I
think that Van Roy's Prolog compiler (Aquarius?) was also written in
Prolog, and probably lots of others (my memory is getting dim).

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.complang.tuwien.ac.at/fo.../forth200x.html
Cesar Rabak

2006-05-02, 7:04 pm

Anton Ertl escreveu:
> Albert van der Horst <albert@spenarnc.xs4all.nl> writes:
>
>
>
> You are wrong about that. Read up on it in
>

[snipped]

>
> Ok, someone once had to know about the machine to write the first
> compiler, but once that's done, other compilers can just extract the
> machine knowledge from the first compiler (if the programming language
> of the first compiler allows it).


So in essence you reinforce Albert's post. The fact there are now
possiblity to acquire the knowledge automatically is a technological detail.
Albert van der Horst

2006-05-02, 7:04 pm

In article <2006May2.233733@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>Albert van der Horst <albert@spenarnc.xs4all.nl> writes:
>
>You are wrong about that. Read up on it in
>
>@Article{collberg02,
> author = {Christian S. Collberg},
> title = {Automatic derivation of compiler machine
> descriptions},
> journal = toplas,
> year = {2002},
> volume = {24},
> number = {4},
> pages = {369--408},
> month = jul,
> annote = {Journal version of \cite{collberg97}. Extracts a
> machine description (for an assembler-generating
> code generator) out of a working C compiler by
> compiling various test programs to assembly
> language, and analysing the resulting
> output. Presents various innovative techniques for
> achieving this result.}
>}


The underlying processor here is the c-virtual machine.
So my conclusion still stands.
Knowing a c-compiler and knowing an
AMD processor is equivalent.
That for most processors a c-compiler is available should not
be taken as relevant in a fundamental discussion like here.

Nevertheless, these are some interesting articles, and
I hope to find time to study them.

>--
>M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html


Groetjes Albert

--
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
albert@spenarnc.xs4all.nl http://home.hccnet.nl/a.w.m.van.der.horst
Bart Demoen

2006-05-08, 7:09 pm

Duane Rettig wrote:

> I don't know particulars about prolog-in-prolog implementation (we
> do have a prolog, very fast, implemented in Allegro CL


Since you deem it worth mentioning ... what is "very fast" ?

Cheers

Bart Demoen
Duane Rettig

2006-05-08, 7:09 pm

Bart Demoen <bmd@cs.kuleuven.be> writes:

> Duane Rettig wrote:
>
>
> Since you deem it worth mentioning ... what is "very fast" ?


I asked our prolog expert, and he said that there are things that we
optimize and things that we don't - it is perhaps a few tens of percent
faster than SWI Prolog on the "Zebra Puzzle", and there are probably
things that SWI Prolog does faster than ours.

My main reason for mentioning it was to tie the more general topic
of the thread with its title, and to note that Lisp is good for
implementing other languages efficiently as well as itself - a
revolutionary concept in a C-centered society where the concept is
that C is the only language that gets down to the metal...

You can try benchmarks yourself by getting the Trial Version of Allegro CL
(http://www.franz.com/downloads)

and trying it yourself. The zebra benchmark is at the end of the prolog
documentation:

http://www.franz.com/support/docume...doc/prolog.html

--
Duane Rettig duane@franz.com Franz Inc. http://www.franz.com/
555 12th St., Suite 1450 http://www.555citycenter.com/
Oakland, Ca. 94607 Phone: (510) 452-2000; Fax: (510) 452-0182
AL.

2006-05-08, 7:09 pm

On Mon, 08 May 2006 15:13:25 -0700, Duane Rettig <duane@franz.com>
wrote:

>Bart Demoen <bmd@cs.kuleuven.be> writes:
>
>
>I asked our prolog expert, and he said that there are things that we
>optimize and things that we don't - it is perhaps a few tens of percent
>faster than SWI Prolog on the "Zebra Puzzle", and there are probably
>things that SWI Prolog does faster than ours.
>
>My main reason for mentioning it was to tie the more general topic
>of the thread with its title, and to note that Lisp is good for
>implementing other languages efficiently as well as itself - a
>revolutionary concept in a C-centered society where the concept is
>that C is the only language that gets down to the metal...


If we talk about ancient history, I remember huge algebraic
manipulation system named Forprep/Almap implemented in Fotran IV,
Fortran IV implemenetd in Fortran IV and system for industrial control
with a lot of interfacing to bare metal implemented in Fortran IV by
using COMMON and EQUIVALENCE in very creative way. I also remember
Prolog implemented in Fortran IV....

But then, so what?... Who cares?... Both are dead corpses.

A.L.
Pierpaolo BERNARDI

2006-05-11, 4:05 am

On Tue, 09 May 2006 00:13:25 +0200, Duane Rettig <duane@franz.com> wrote:

> Bart Demoen <bmd@cs.kuleuven.be> writes:
>
>
> I asked our prolog expert, and he said that there are things that we
> optimize and things that we don't - it is perhaps a few tens of percent
> faster than SWI Prolog on the "Zebra Puzzle", and there are probably
> things that SWI Prolog does faster than ours.


I can confirm it's slightly faster than swi on a predicate
taken from a program of mine:

3 ?- time((ohm:fa_rete([1,2,3,4,5,6,7,8,9,10]
,A,B),fail)).
% 13,246,792 inferences, 6.23 CPU in 7.19 seconds (87% CPU, 2124799 Lips)

CL-USER(47): (time (?- (fa-rete (1 2 3 4 5 6 7 8 9 10) ?a ?b) (fail)))
No.
; cpu time (non-gc) 5,581 msec user, 16 msec system
; cpu time (gc) 716 msec user, 0 msec system
; cpu time (total) 6,297 msec user, 16 msec system
; real time 8,265 msec
; space allocation:
; 10,197 cons cells, 277,056,448 other bytes, 0 static bytes


The predicate tested is:

fa_rete(L,R,V) :-
append(L1,L2,L),
L1 \= [],
L2 \= [],
fa_rete(L1,R1,V1),
fa_rete(L2,R2,V2),
( R = ser(R1,R2),
V is V1+V2
; R = par(R1,R2),
V is (V1*V2)/(V1+V2)
).
fa_rete([Q],Q,Q).


(<-- (fa-rete ?l ?r ?v)
(append ?l1 ?l2 ?l)
(not (= ?l1 ()))
(not (= ?l2 ()))
(fa-rete ?l1 ?r1 ?v1)
(fa-rete ?l2 ?r2 ?v2)
(or (and (= ?r (ser ?r1 ?r2))
(is ?v (+ ?v1 ?v2)))
(and (= ?r (par ?r1 ?r2))
(is ?v (/ (+ (/ ?v1) (/ ?v2)))))))
(<- (fa-rete (?q) ?q ?q))


> My main reason for mentioning it was to tie the more general topic
> of the thread with its title, and to note that Lisp is good for
> implementing other languages efficiently as well as itself - a
> revolutionary concept in a C-centered society where the concept is
> that C is the only language that gets down to the metal...


I tested this predicate when your prolog was announced and I found
it was about half the speed of swi. The timings above, made today,
are with an up to date acl 7.0 trial on windows/x86, and latest swi.
Nice job (I know other prologs are much faster than swi, but still).

P.

Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
Pierpaolo BERNARDI

2006-05-11, 4:05 am

On Thu, 11 May 2006 07:22:47 +0200, Pierpaolo BERNARDI <pierpaolo@secondbox.net> wrote:

> On Tue, 09 May 2006 00:13:25 +0200, Duane Rettig <duane@franz.com> wrote:
>
>
> I can confirm it's slightly faster than swi on a predicate
> taken from a program of mine:


oops. I used floats for swi and rationals for franz.
And I looked at total time for franz instead or real time...

Anyway, using floats in both cases makes the two use about the same time:

5 ?- time((ohm:fa_rete([1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0],A,B),fail)).
% 13,246,754 inferences, 6.11 CPU in 7.03 seconds (87% CPU, 2168267 Lips)

CL-USER(51): (time (?- (fa-rete (1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0) ?a ?b) (fail)))
No.
; cpu time (non-gc) 4,454 msec user, 16 msec system
; cpu time (gc) 874 msec user, 0 msec system
; cpu time (total) 5,328 msec user, 16 msec system
; real time 7,437 msec
; space allocation:
; 10,191 cons cells, 313,925,120 other bytes, 0 static bytes


Cheers
P.

Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com