Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compiling to Parrot

5 views
Skip to first unread message

K Stol

unread,
Jan 21, 2003, 3:17:56 AM1/21/03
to perl6-i...@perl.org
Hi there,

A few weeks ago I posted something about a Tcl->parrot compiler, but Will Coleda already was working on such a project. It would be a as a final project for my bachelor's. But because such already exists, I'm looking for something else.
I think parrot is a cool target for compiling, and I'd like to do some sort of a compiler project. However, I don't know which language to compile. My knowledge is basic, so any OO language would take too much time.
Has anybody any suggestions for me? (maybe modula2?)

Regards.

Klaas-Jan Stol

Simon Wistow

unread,
Jan 21, 2003, 3:41:47 AM1/21/03
to K Stol, perl6-i...@perl.org


PHP?
Similar enough to Perl to make it interesting, nice clean design and an
available grammar. People have already done some work IIRC.

Lua?
Similar-ish to TCL and liked by the games industry. It is procedural but
provides meta mechanisms for implementing classes and inheritance.

Speaking of games, it would be interesting to see Parrot be used in that
direction. A lot of games currently are pretty much developed along the
lines of 'custom scripting language interfaced to custom game engine'

# game scripting in Python
http://www.gamasutra.com/features/20020821/dawson_pfv.htm

# Postmortem of Jak and Daxter which was scripted in Lisp
http://www.gamasutra.com/features/20020710/white_01.htm

Parrot seems to be ideal for this, especially since you could easily
have seperate scripting languages for, say, the world logic and the AI
for NPCs, both of which could compile to Parrot and interact with each
other.

Simon


--
I'm full of borrowed ideas that I have no intention of returning

Leon Brocard

unread,
Jan 21, 2003, 4:58:08 AM1/21/03
to perl6-i...@perl.org
K Stol sent the following bits through the ether:

> A few weeks ago I posted something about a Tcl->parrot compiler, but
> Will Coleda already was working on such a project. It would be a as a
> final project for my bachelor's. But because such already exists, I'm
> looking for something else.

An interesting project to do would be to do a Java->Parrot compiler.
Basing it on an existing Java compiler such as Jikes is probably the
best way to do this:
http://oss.software.ibm.com/developerworks/opensource/jikes/
You'd also probably use GNU Classpath:
http://www.gnu.org/software/classpath/classpath.html

HTH, Leon
--
Leon Brocard.............................http://www.astray.com/
scribot.................................http://www.scribot.com/

... Hmm... How *did* they finally kill Frosty?

K Stol

unread,
Jan 21, 2003, 6:14:29 AM1/21/03
to Simon Wistow, perl6-i...@perl.org
PHP is especially used in web pages. Would there be any advantage to have a
PHP->Parrot compiler?

LUA seems to be a very nice language, but how is this language to be used?
Is it in combination with a C program one would write? Or could it be used
as a stand alone application? In that case, it seems to me it would be
interesting to have a LUA->Parrot (with IMCC in between) compiler.

Regards.
Klaas-Jan Stol

Simon Wistow

unread,
Jan 21, 2003, 7:16:15 AM1/21/03
to perl6-i...@perl.org
On Tue, Jan 21, 2003 at 12:14:29PM +0100, K Stol said:
> PHP is especially used in web pages. Would there be any advantage to have a
> PHP->Parrot compiler?

Depends what you mean by 'advantage'.

Currently, as far as I know, PHP runs on a virtual machine, just like
Perl so it's a good candidate for porting. It is also relatively feature
comparable whilst being easier to parse.

Doing a PHP->Parrot compiler would have these advantages :

* demonstrate your understanding of a inplementing the
compiler for a featureful language
* allow interaction between Perl6 and PHP scripts/modules
* tap into the PHP community's tuits whcih would mean Parrot'd be likely
to get stuff like the Zend optimiser and a generic mod_* backend so
that all languages implemented on top of Parrot would have a
mod_(php/perl) Apache hook automagically.
* really push Parrot with a real-world, non toy language.


> LUA seems to be a very nice language, but how is this language to be used?
> Is it in combination with a C program one would write? Or could it be used
> as a stand alone application? In that case, it seems to me it would be
> interesting to have a LUA->Parrot (with IMCC in between) compiler.

As I said, I only know it from a games context where it's used as the
basis for the scripting engine. AIUI it can be used a a standalone
language as well.

From what I know it's specifically designed to be a portable, fast,
lightweight platform for extending platforms and providing a framework
for implementing domain specific languages.

So, basically, a perfect fit for Parrot.

In fact, if you take

http://www.lua.org/about.html

and s/Lua/Parrot/ it still makes sense :)

Simon

Dan Sugalski

unread,
Jan 21, 2003, 10:40:57 AM1/21/03
to K Stol, perl6-i...@perl.org
At 9:17 AM +0100 1/21/03, K Stol wrote:
>Hi there,
>
>A few weeks ago I posted something about a Tcl->parrot compiler, but
>Will Coleda already was working on such a project. It would be a as
>a final project for my bachelor's. But because such already exists,
>I'm looking for something else.

If you're interested in doing a Tcl compiler, by all means, go
ahead--I wouldn't let the fact that someone else is doing it stop
you. The point of doing it is for the experience, which you'll get
regardless of any other implementation. It's also distinctly possible
that neither you nor Will will finish a full implementation (as it's
likely a rather large undertaking for one person) but you'll each
have part of it that can be merged together.
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

K Stol

unread,
Jan 21, 2003, 10:46:45 AM1/21/03
to Dan Sugalski, perl6-i...@perl.org
Well, I'd do it as a project for my Bachelor's, so I won't get permission to
do such a project, if it already exists.
Klaas-Jan

----- Original Message -----
From: "Dan Sugalski" <d...@sidhe.org>
To: "K Stol" <k_s...@hotmail.com>; <perl6-i...@perl.org>
Sent: Tuesday, January 21, 2003 4:40 PM
Subject: Re: Compiling to Parrot

Gopal V

unread,
Jan 21, 2003, 10:34:51 AM1/21/03
to Leon Brocard, perl6-i...@perl.org
If memory serves me right, Leon Brocard wrote:
> An interesting project to do would be to do a Java->Parrot compiler.

Hmm... I think with the current Parrot setup that might be a bit difficult.
We need object instructions for that , also I need to be able to define
classes,interfaces and all the Java thingys there ...

> Basing it on an existing Java compiler such as Jikes is probably the
> best way to do this:

Yikes ! (in a thick foreign accent)...

My bachelor's project is a Java compiler for DotGNU ... and I had a look
over of Jikes (and Kjc) for retargetting ... Eventhough I was planning on
building a stack bytecode , I found it quite something to hack on...
(in short, my attempts broke it...)

Kjc is a bit more decent though it's quite OO and might take some redesign
to pass back the result register (instead of "assuming" that the value is
in the stack top) ...

I've decided to base it on the Portable.net codegen... (I've got it into
parsing now...) ... This is a Java -> IL compiler from Java source ...

But once the C# -> Parrot compiler works , you might even have a Java ->
Parrot compiler ... (because I'm re-using almost all the C# AST nodes
for my compiler, the PMCodegen should generate correct Parrot as well).

Hopefully all this will work out for me... :)

Gopal
--
The difference between insanity and genius is measured by success

Dan Sugalski

unread,
Jan 21, 2003, 10:58:52 AM1/21/03
to K Stol, perl6-i...@perl.org
At 4:46 PM +0100 1/21/03, K Stol wrote:
>Well, I'd do it as a project for my Bachelor's, so I won't get permission to
>do such a project, if it already exists.

Ah, that could be a problem. Will it be a problem if you start a
project that someone else later also starts?

K Stol

unread,
Jan 21, 2003, 11:01:04 AM1/21/03
to Dan Sugalski, perl6-i...@perl.org
well, I think not, then I can't help it. What do you think about compiling
Lua to parrot (IMCC)?
Klaas-Jan

----- Original Message -----
From: "Dan Sugalski" <d...@sidhe.org>
To: "K Stol" <k_s...@hotmail.com>; <perl6-i...@perl.org>
Sent: Tuesday, January 21, 2003 4:58 PM
Subject: Re: Compiling to Parrot

Dan Sugalski

unread,
Jan 21, 2003, 11:05:25 AM1/21/03
to K Stol, perl6-i...@perl.org
At 5:01 PM +0100 1/21/03, K Stol wrote:
>well, I think not, then I can't help it. What do you think about compiling
>Lua to parrot (IMCC)?

I like the idea, and I don't think you'll see anyone else tackle it
for a while. (And if that falls through, there's always LISP... :)

K Stol

unread,
Jan 21, 2003, 11:13:51 AM1/21/03
to Dan Sugalski, perl6-i...@perl.org
Only thing I need to know before I can start is: what would the purpose be
of a Lua to Parrot compiler? Lua is originally an embedded language for
easy-scripting, as far as I understand. How could it be used when targeted
to parrot? Would it be possible to call functions written in Lua (and which
are then compiled to parrot) from (for example) a python script? (So: python
script calls function writtenin Lua and compiled to parrot).

Klaas-Jan

----- Original Message -----
From: "Dan Sugalski" <d...@sidhe.org>
To: "K Stol" <k_s...@hotmail.com>; <perl6-i...@perl.org>
Sent: Tuesday, January 21, 2003 5:05 PM
Subject: Re: Compiling to Parrot

Dan Sugalski

unread,
Jan 21, 2003, 11:20:56 AM1/21/03
to K Stol, perl6-i...@perl.org
At 5:13 PM +0100 1/21/03, K Stol wrote:
>Only thing I need to know before I can start is: what would the purpose be
>of a Lua to Parrot compiler? Lua is originally an embedded language for
>easy-scripting, as far as I understand. How could it be used when targeted
>to parrot? Would it be possible to call functions written in Lua (and which
>are then compiled to parrot) from (for example) a python script? (So: python
>script calls function writtenin Lua and compiled to parrot).

If you follow the calling conventions, then yes you'll be able to
call python/ruby/perl/befunge routines from Lua code, and vice versa.

K Stol

unread,
Jan 21, 2003, 11:48:04 AM1/21/03
to Dan Sugalski, perl6-i...@perl.org
Is it possible for parrot-code to call functions in other parrot files?
(which implies there is some program which consists of multiple files)

Klaas-Jan

----- Original Message -----
From: "Dan Sugalski" <d...@sidhe.org>
To: "K Stol" <k_s...@hotmail.com>; <perl6-i...@perl.org>
Sent: Tuesday, January 21, 2003 5:20 PM
Subject: Re: Compiling to Parrot

Jerome Quelin

unread,
Jan 21, 2003, 12:35:00 PM1/21/03
to Dan Sugalski, K Stol, perl6-i...@perl.org
Dan Sugalski wrote:
> If you follow the calling conventions, then yes you'll be able to
> call python/ruby/perl/befunge routines from Lua code, and vice versa.

No, you won't be able to call befunge routines from Lua, because:
- befunge does not know how to define subroutines (at least befunge-93
and befunge-98... maybe befunge-103?). Well, to be honest, maybe I'll
introduce the hack I'm using in Inline::Befunge in order to have named
subroutines.
- befunge, because of its nature, _can't_ be compiled and is only
interpreted. So, in order to call befunge subs, you'll have to embed a
Befunge interpreter in your code.

Jerome
--
jqu...@mongueurs.net

Christopher Armstrong

unread,
Jan 21, 2003, 8:54:10 AM1/21/03
to perl6-i...@perl.org
On Tue, Jan 21, 2003 at 08:41:47AM +0000, Simon Wistow wrote:
> Speaking of games, it would be interesting to see Parrot be used in that
> direction. A lot of games currently are pretty much developed along the
> lines of 'custom scripting language interfaced to custom game engine'

One of the reasons I'm interested in Parrot -- I'm hoping that it's
going to have some secure execution facilities built-in from the
ground up (to facilitate user-code on virtual world servers) :-)

--
Twisted | Christopher Armstrong: International Man of Twistery
Radix | Release Manager, Twisted Project
---------+ http://twistedmatrix.com/users/radix.twistd/

Paul Du Bois

unread,
Jan 22, 2003, 2:43:09 AM1/22/03
to K Stol, Dan Sugalski, perl6-i...@perl.org
The advantage of Lua (at least for my project, which is a game) is that it
is quite easy to embed, and quite easy to customize. The C API is small and
easily understandable (at the expense of being a little bit of a pain to
use), and the internals are simple and quite malleable. The language itself
is pretty ugly IMHO.

So... I can't think of a good purpose of Lua/Parrot myself. I'm not trying
to discourage you by any means! If I were to embed a Parrot interpreter for
our next game (!) I'd happily leave Lua behind.

p

Dan Sugalski

unread,
Jan 22, 2003, 2:52:20 AM1/22/03
to Christopher Armstrong, perl6-i...@perl.org
At 8:54 AM -0500 1/21/03, Christopher Armstrong wrote:
>On Tue, Jan 21, 2003 at 08:41:47AM +0000, Simon Wistow wrote:
>> Speaking of games, it would be interesting to see Parrot be used in that
>> direction. A lot of games currently are pretty much developed along the
>> lines of 'custom scripting language interfaced to custom game engine'
>
>One of the reasons I'm interested in Parrot -- I'm hoping that it's
>going to have some secure execution facilities built-in from the
>ground up (to facilitate user-code on virtual world servers) :-)

Yep. I've not spec'd them out as I've been trying to deal with other
things, but secure execution is something I've been thinking of since
the beginning. Perl 5's model has some rather significant flaws, as
does Java's sandboxing, albeit fewer of them.

Dan Sugalski

unread,
Jan 22, 2003, 2:57:31 AM1/22/03
to K Stol, perl6-i...@perl.org
At 5:48 PM +0100 1/21/03, K Stol wrote:
>Is it possible for parrot-code to call functions in other parrot files?
>(which implies there is some program which consists of multiple files)

Oh, absolutely.

What one generally does is load in other bytecode files. Those files,
on loading, will install a variety of symbols into the interpreter's
global pool, at which point you can use them as you need to.

This is, generally speaking, a dynamic linking scheme, rather than
the more traditional static link that resolves symbols and such, as
we're dealing with a much more dynamic environment.

Dan Sugalski

unread,
Jan 22, 2003, 3:02:44 AM1/22/03
to Paul Du Bois, K Stol, perl6-i...@perl.org
At 11:43 PM -0800 1/21/03, Paul Du Bois wrote:
>The advantage of Lua (at least for my project, which is a game) is that it
>is quite easy to embed, and quite easy to customize. The C API is small and
>easily understandable (at the expense of being a little bit of a pain to
>use), and the internals are simple and quite malleable. The language itself
>is pretty ugly IMHO.
>
>So... I can't think of a good purpose of Lua/Parrot myself. I'm not trying
>to discourage you by any means! If I were to embed a Parrot interpreter for
>our next game (!) I'd happily leave Lua behind.

Well, then, let's see what we can do to make parrot suitable for your needs. :)

> > Only thing I need to know before I can start is: what would the purpose be
> > of a Lua to Parrot compiler? Lua is originally an embedded language for
>> easy-scripting, as far as I understand. How could it be used when targeted
>> to parrot? Would it be possible to call functions written in Lua
>> (and which
>> are then compiled to parrot) from (for example) a python script?
>> (So: python
>> script calls function writtenin Lua and compiled to parrot).
>>
>> Klaas-Jan

Chad Fowler

unread,
Jan 22, 2003, 7:07:19 AM1/22/03
to Paul Du Bois, K Stol, Dan Sugalski, perl6-i...@perl.org
I lost the original mail asking for suggestions, so there is no quoted
text here, but have you looked at Joy
(http://www.latrobe.edu.au/philosophy/phimvt/joy.html). Looks to be quite
clean and simple. I haven't had the time to delve into it, but when I was
reminded of it on the Ruby list, I thought I would suggest it here.

Chad

Matt Fowles

unread,
Jan 27, 2003, 11:50:50 PM1/27/03
to K Stol, perl6-i...@perl.org
All~

It occurs to me that no one has mentioned ML. ML would be a pretty good
language to compile to parrot, and has reasonably strong usage in academic
circle...

Matt

K Stol

unread,
Jan 28, 2003, 7:15:04 AM1/28/03
to Dan Sugalski, perl6-i...@perl.org
Hi there,

didn't have time to reply earlier, had to do some research on Lua and had to
get approval for the project, so couldn't let you know earlier. sorry about
that.
But now, I have it (the approval, that is) so I'll be implementing a
compiler for Lua->parrot (most probably IMCC in between).

thanks to the people who suggested/replied on my posting.

Regards
Klaas-Jan


----- Original Message -----
From: "Dan Sugalski" <d...@sidhe.org>
To: "K Stol" <k_s...@hotmail.com>; <perl6-i...@perl.org>
Sent: Tuesday, January 21, 2003 5:05 PM
Subject: Re: Compiling to Parrot

Dan Sugalski

unread,
Jan 29, 2003, 10:45:54 AM1/29/03
to K Stol, perl6-i...@perl.org
At 1:15 PM +0100 1/28/03, K Stol wrote:
>Hi there,
>
>didn't have time to reply earlier, had to do some research on Lua and had to
>get approval for the project, so couldn't let you know earlier. sorry about
>that.
>But now, I have it (the approval, that is) so I'll be implementing a
>compiler for Lua->parrot (most probably IMCC in between).

Cool. Go for it, good luck, and nudge us on any parrot features (or
misfeatures) that are getting in the way--we're not 1.0 yet, so
there's plenty of room for change where needed.

0 new messages