Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: TPF and Pugs

by tphyahoo (Vicar)
on Dec 09, 2005 at 10:14 UTC ( [id://515497]=note: print w/replies, xml ) Need Help??


in reply to Re^2: TPF and Pugs
in thread The Perl Foundation Wants to Hear From You

As for Parrot and Pugs, there is no competition. Though related, they're actually in different problem spaces.

A while ago, I attempted to get a better grasp of what the respective problem spaces actually are, from A Plan for Pugs. I found the article to be a lot of fun, and inspiring, but kind of difficult to understand, probably because it deals with concepts that are a little beyond me. But at any rate, the money quote from Autrijus, or at any rate one money quote:

Autrijus: Actually, I think Pugs and Parrot will meet in the middle. W +here Pugs AST meets Parrot AST and the compiler is written in Perl 6 +that can then be run on Parrot. chromatic: I thought Pugs would get rewritten in C for Parrot? Autrijus: No, in Perl 6. chromatic: Can GHC retarget a different AST then? Autrijus: It can, but that's not the easier plan. chromatic: It's easy for me. I don't plan to do it. Autrijus: The easier plan is simply for Pugs to have a Compile.hs that + emits Parrot AST. Which, I'm happy to discover yesterday, is painles +s to write. (Ingy and I did a KwidAST->HtmlAST compiler in an hour, t +ogether with parser and AST.)
Another money quote apropos this theme:
chromatic: Are you compiling it to native code now? I remember that be +ing a suggestion a few days ago. Autrijus: Pugs itself is compiled to native code; it is still evaluati +ng Perl 6 AST, though. chromatic: It's like Perl 5 in that sense then. Autrijus: Yes, it's exactly like Perl 5. Have you read PA01? chromatic: I have. Autrijus: Cool. So yeah, it's like Perl 5 now. The difference is B::* +is trivial to write in Pugs chromatic: Except maintainable. Autrijus: And yeah, there's the maintainable bit. Pugs is <4k lines of + code. I think porting Pugs to Perl 6 will take about the same number + of lines, too.
Now, if only I understood better what these guys were talking about... someday.....

Replies are listed 'Best First'.
Re^4: TPF and Pugs
by chromatic (Archbishop) on Dec 12, 2005 at 01:57 UTC

    In the first quote, we discussed how Pugs and Parrot could interact. There are lots of ways to run code on Parrot -- emit pure bytecode, emit source code that a language running atop Parrot can compile, manipulate Parrot data structures directly, or use the AST interface. An Abstract Syntax Tree is a more-or-less canonical representation of a program derived from parsing and, sometimes, optimizing its source code. If you use B::Concise you can get a sort of textual view of the not-quite-abstract syntax tree that Perl 5 uses.

    Pugs builds up an AST when it parses Perl 6 code. The plan there is to transform that into the same sort of AST that Parrot uses.

    An alternate approach would be to use GHC, the Haskell compiler that Pugs targets, to write a native code executable that handles Perl 6 code. Sometimes that works well for Haskell programs. Because of the way Pugs works, though, it's doubtful that this will give good speed. (The implementation uses a lot of monads, which are useful for getting some things done in Haskell, but they can be very difficult to optimize, having to give up a lot of the things that make pure functional lazy languages easy to optimize.)

    My question was if there was a plan or even an idea of telling GHC to emit Parrot AST code instead of C code... but that's not the plan.

    The second quote explains things more fully. Pugs itself isn't interpreted Haskell code, it's a native binary. However, that doesn't mean that the Perl 6 code it runs is native -- it interprets it in the same sense that perl interprets Perl 5 code.

    However, it's a lot more maintainable, at least if you know Haskell.

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://515497]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-25 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found