My teenage memories and the Parrot Virtual Machine
I am on vacation and visited the Planetarium in Budapest with my son. After so many years it was nice to be there again even though we saw a program about stars and not the a laser show. Back when I was 16, I used to "work" there writing a slide-show program in assembly for the ZX Spectrum. That was fun time, I really enjoyed programming in assembly. I thought about this earlier too, but I think visiting there was the last straw: I am going to learn Parrot.
I knew a bit about Parrot, but I hardly understand what all the words PIR, PASM, HLL, etc. mean so I started to read the Introduction to Parrot which is the first document linked from documentation of Parrot
After a short overview it quickly lead me to the first example in PIR (Parrot Intermediate Representation) - which if I understand correctly is the highest assembly language Parrot can understand. The first example was printing hello world - what else could be. I reached for my favorite editor and tried to create a file a file with pir extension. It crashed. A short fight with it and I found out that Padre was mostly OK, just the Parrot plug-in that is used for the syntax highlighting of the PIR files used the old API. As it is written in Perl and I happened to know a bit of the particular code, I could fix the plug-in and could resume learning Parrot and PIR.
Once I managed to write my first example I wanted to run it using the "Run/Run Script F5" menu option but it told me there is no execution mode for this kind of file. Sure, apparently I have not implemented that part yet. So back to editing Padre::Plugin::Parrot. I had to implement the get_command method in the Padre::Document::PIR class that should contain the various PIR specific features of Padre.
Once that was done I could already run my PIR script, right from within my editor.
As I made some further progress in learning PIR I found out that not all the keywords I am using are colored so I had to patch the syntax highlighter which is too in Padre::Document::PIR.
I moved along, created a few example pir scripts, partially based on the examples from the Parrot web site, partially just the standard examples like the Fibonacci and added them to the Parrot plug-in. They should be installed now and with the next version I might even add a menu option to the Parrot plug-in to make it easy for the users to open these sample scripts.
The last thing I added to the plug-in was a menu option to generate a PBC file (Parrot Byte Code) from the pir file. Unfortunately it does not give you any feedback on success or failure yet but at least it is out on CPAN already.