GCI: Embedding Parrot into Firefox

Andrew Whitworth wknight8111 at gmail.com
Sat Nov 27 00:47:17 UTC 2010

I set up this little research project as a GCI task to explore the
idea of embedding Parrot into FireFox. An immediate goal would be to
allow JavaScript-on-Parrot to be a potential scripting engine in
FireFox, if only as an academic exercise. Of course, we would also
immediately get the ability to use other languages that run on Parrot
as the client-side script languages.

According to some of the information that Alexander dug up, it doesn't
look like we can do this in a natural way with <script
type="application/parrot-lang-x"></script> tag. If it's possible,
there is very very very little documentation about it. It is looking
like we could use <embed> tag run Parrot apps in (think of how
Silverlight or Flash run in a browser).

Getting Parrot into web browsers is something I want to pursue
personally in the coming year. This is just food for thought.

--Andrew Whitworth

On Fri, Nov 26, 2010 at 4:10 PM, Alexander Moquin <alexmoquin at gmail.com> wrote:
> Hi, I'm a GCI student, and recently wrote this document for one of the
> assignments.
> Embedding the Parrot VM into Mozilla Firefox
>  Placing a new interpreter into Firefox is something that, to me, seems very
> important, but as far as I know has never been attempted before. However, I
> see a very strait forward way of implementing this as a windowed,
> scriptable* plug-in. Why a plug-in? For one, it is much simpler for both the
> developer and the user, because the developer gets to use the API for
> plug-ins (NPAPI),which is well maintained and well documented on the Mozilla
> Developer Network here, while not having to search though the source code,
> edit it, and A. Create a new version of Firefox or B. Try and confince
> enough people at Mozilla to include it. And, for the user, all they have to
> worry about is installing a plug-in. Plus, (a very large, encouraging plus)
> NPAPI is already supported by:
> Epiphany, Google Chrome, Safari, Konqueror, Mozilla project applications,
> Netscape Navigator and Communicator, Opera, and Internet Explorer up to
> 5.5SP2 (so sad that IE can't seem to properly support much anything
> standardized, except maybe hyperlinks...)
> Also good is that that Parrot itself seems to made out of parrot file types
> and C/C++ files to interpret those (at least on the windows port),and the
> NPAPI is C, which should mean only a couple files added to parrot and
> probably some minor edits.
> Now, there are many ways to use a (scriptable) plug-in from a web page, all
> using the <embed> and <object> tags. To activate from a web page, one could
> do some thing like this:
> <embed type="application/x-parrot-perl" id="perlObj"></embed>
> <!--The browser doesn't recognise x-parrot-perl nativly, searchs internally
> for it-->
> <div style="display:none" id="myString">
>    <!--some perl code-->
>    <!--this is should allow for multiline code-->
> </div>
> <script type="application/javascript">
>    var myString = document.getElementById('myString').innerTEXT
>    myString.replace('<br />', '\n');
>    getElementById("perlObj").code(myString)
>    //calls the made-up parrot function code() and passes a string of code to
> it.
> </script>
> If I'm right, because it doesn't know it by default, the browser should look
> internally for a plug-in that accepts this MIME type which shall be, of
> course, parrot. The code function simply and unsurprisingly would take the
> string sent to the plug-in and interpret it as, in this case, Perl.(there
> are different ways to go about the above, but the way I gave seems to be the
> most effective form what I've looked at)
> The plug-in itself another thing indeed. As said in the
> reference/documentation, Mozilla hosts files that give a starting point as
> samples for creating a plug-in here. Although I don't know C, they seems
> very simple to configure and take example from.
> Whatever the parrot community chooses to do, I can't wait.
> *windowed and scriptable simply mean that the plug-in has a space to draw
> onto and that it can be accessed via javascript
> _______________________________________________
> http://lists.parrot.org/mailman/listinfo/parrot-dev

More information about the parrot-dev mailing list