Re: Interaction between languages in Parrot
by InfiniteSilence (Curate) on Dec 19, 2005 at 19:29 UTC
|
The vision for Perl 6 is more than simply a rewrite of Perl 5. By sepa
+rating the parsing from the compilation and the runtime, we're openin
+g the doors for multiple languages to cooperate. You'll be able to wr
+ite your program in Perl 6, Perl 5, TCL, Python, or any other languag
+e that there's a parser written for. Interchangable runtime engines l
+et you interpret your bytecode or convert it to something else (e.g.,
+ Java, C, or even back to Perl).
Celebrate Intellectual Diversity
| [reply] [d/l] |
|
|
But... If java.lang.String is a Java Class, and I create a subclass of it in Perl6, will it be possible to use the My::String::Subclass as an argument to methods defined in Java Classes?
Maybe it's just written in the statement you quote, but I couldn't be sure just by reading it (which I made before posting here in the first time)...
| [reply] |
|
|
| [reply] |
|
|
|
|
Re: Interaction between languages in Parrot
by snoopy (Curate) on Dec 20, 2005 at 02:24 UTC
|
Parrot objects aim to be language inpendendant. The Parrot Primer states:
"In theory, you will be able to write a class in Perl, subclass it in Python and then instantiate and use that subclass in a Tcl program."
However there's a fair bit of impedence between core Parrot PMC's (strings, arrays, hashes, etc) and Java datatypes (4 types of integer!).
BTW, Cola is interesting as a native Parrot language that borrows heavily from Java/C++/C#.
| [reply] |
|
|
However there's a fair bit of impedence between core Parrot PMC's (strings, arrays, hashes, etc) and Java datatypes (4 types of integer!).
This should (in theory) not make any difference. The compiler will determine which Parrot PMC is most appropriate to each Java datatype and assign them accordingly. It is also possible (and very likely) to write new Parrot PMCs which will map more directly to the Java datatypes.
It is important to think of Parrot as a toolbox for compilers, and not so much for programmers.
| [reply] |
|
|
class MyPerlClass
method foo {...};
method bar {...};
...then to extend the class in Java
class MyJavaClass extends MyPerlClass {
public void output() {System.out.println(foo() + bar());}
}
Add or concatonate?
The programmer still needs additional interfacing definitions, or castings or something. It doesn't look seamless. | [reply] [d/l] [select] |
|
|
Re: Interaction between languages in Parrot
by qq (Hermit) on Dec 19, 2005 at 22:29 UTC
|
Will it be possible to, inside a Perl6 code, invoke a Python class, or a Java class?
Yes, but if you want details you should ask on p6i. See this recent thread on namespaces for a start..
Being more optimistic, will it be possible to subclass a Java class in Perl6 and then use it as a method argument to another Java class?
I'd guess no. I hope you ask of p6i, I'll be watching for the replies.
| [reply] |
Re: Interaction between languages in Parrot
by chromatic (Archbishop) on Dec 20, 2005 at 07:39 UTC
|
Being more optimistic, will it be possible to subclass a Java class in Perl6 and then use it as a method argument to another Java class?
I don't see why not, as long as the method you call doesn't totally suck with regards to the introspection it performs on the object it receives.
(Nit: Perl 6, with the space please.)
| [reply] |
|
|
| [reply] |
Re: Interaction between languages in Parrot
by mattr (Curate) on Dec 20, 2005 at 09:09 UTC
|
Along the same lines as the OP, I came across a new language called Io the other day (as opposed to an older concept of a language called Io that was implemented under a different name). There is also an OS based on it too.
I was wondering the other day if Io could be built with Parrot. It would be quite cool. For one thing its vector ops are blazingly fast, also it has a number of neat things that probably the P6 people and other language weeniese like, and it allows dynamic typing like Perl. Perl+Io would be a really cool mix I thought. There are numerous examples of Io running OpenGL commands.
Anyway, the two problems that pop into my head, even though I am totally unqualified to analyze the problem, are that Io doesn't use classes (Io site says it is more powerful than mere classes and can implement classes in Io) and of course that it is really fast, especially it seems on PPC hardware in vector ops, but messing with parrot sounds like it could slow that down.
So my question is, could parrot make perl+io a reality and could it be imaginable that Io libraries running at current speed, along with Io language features, could be accessible from Perl via parrot magic?
Oh, and incidentally Question 2: Io talks about being good for embedded. Though I don't know if they mean what I mean when I say embedded, i.e. devices. Anyway with Parrot I also wonder if perl might make its way onto embedded devices in a minimal form, or even have its modules accessible from an embedded Io+parrot. I suppose this is a bit extreme..
Thanks,
Matt | [reply] |
|
|
Anyway, the two problems that pop into my head, even though I am totally unqualified to analyze the problem, are that Io doesn't use classes (Io site says it is more powerful than mere classes and can implement classes in Io)
The fact that Io doesn't use classes is largely irrelevant, the Io->Parrot compiler will decide what it needs to represent Io structures in, which will likely be Parrot PMCs of some kind, but Io doesn't need to care either way. There is no need for there to be a one-to-one mapping of language level "things" to VM level "things". I can't seem to find any docs on Io's VM instruction table, but I imagine it is quite small. The YARV (Yet Another Ruby VM) instruction table is a good example of this. The first ~50 instructions are all that are needed to run Ruby, all other instructions after that are just optimizations.
Oh, and incidentally Question 2: Io talks about being good for embedded.
In this context they mean embedding Io into your own (C/C++/etc) application, for use as a scripting language. However, there is nothing to stop you from running that application on an embedded platform (PDA, cell phone, etc). In fact, Io is ideally suited for just this type of application since it has such a small footprint.
| [reply] |
|
|
Thank you very much for an interesting reply on Io and Parrot. I'm looking forward to Parrot and meanwhile think I may tinker with Io a little too!
| [reply] |