Parrot is more than just PIR and PASM. I’m not talking about the ability to use languages like Rakudo written for the Parrot virtual machine. I am also not talking about the ability to write your own language. Both of those are quite nifty, of course. It is fair to say that those two items are probably why you are experimenting with Parrot in the first place. However, the Parrot distribution also ships with an extra language: NQP.
NQP - Not Quite Perl - is an implementation of a small subset of Perl 6 that can be used as a higher level Parrot language than PIR. It is especially useful in defining the grammars for your Parrot languages.
Getting NQP
You already have NQP if you have a fresh installation of Parrot. You can find directions for installing in parrot-babysteps-01-getting-started if you do not yet have Parrot installed.
Example
Let’s just do a quick NQP example.
We see that NQP variables look a little like Perl variables, and familiar control structures like if
and while
are supported. Another bit of niftiness is that inline PIR is supported.
Mind you, NQP is not really great for casual scripting. It’s intended to be a higher level bootstrap language that makes it easier to define grammars. I wouldn’t go complaining to anybody that it’s missing Feature X. Unless you know how to implement it. Maybe. If you want Feature X, it might be better to use Rakudo or implement it in your own Parrot language.
You could even use NQP to implement it. Is my logic circular enough for you?
Learning NQP
There is a good overview of NQP available at wikibooks.
Backlinks
Added to vault 2024-01-15. Updated on 2024-04-03