Getting Started: Developing for Perl 6

Three weeks ago, I started a Google Summer of Code project working on a linker for Perl 6 user programs. Getting started on a new project with a new group of people is always hard, primarily because it can be hard to figure out where to start or who to reach out to. This GSoC project has been no exception. That being said, the Perl 6 community is one of the kindest, most helpful online communities I've run into and appears to have no qualms assisting a new contributor in getting up to speed.

So far, the biggest challenges I've run into have been figuring out what I didn't know about how to get started, figuring out IRC, and getting my development environment set up.

Figuring out what I didn't know

Perl 6 is a big language. Prior to this summer, I had very little exposure to Perl, Perl 6, or interpreted languages in general. Thankfully, Perl 6 has pretty substantial documentation, and the source code is pretty well commented too. Information on linkers is harder to come by but I found a couple really helpful resources for that as well.

These are some of the major resources I've used to get started:
  • Rakudo & NQP Internals Course - This is super super helpful if you're going to be doing anything touching the compiler. It's a bit old, but the slides are really easy to read through, the exercises are helpful, and all around it helps provide a really good starting point for how things are working under the hood.
  • Perl 6 Intro - I previously had little to no experience with Perl 6. I wanted to at least get some hands on experience with the language, even though I won't be writing much in it, so I used this as a guide while working through last year's Advent of Code challenges. The actual docs for Perl 6 were also very helpful for figuring out how to do things.
  • Linkers & Loaders - This book is absolutely necessary if you're working on linkers. It has just about all the information you could ever want to know about linkers and how they work, and even though it's a little dated, the facts haven't really changed enough for that to matter. Another nifty thing about the book is that has a project, with exercises at the end of every chapter, that walk you through how to build a linker. The author has some sample solutions for a couple of the exercises on his website.
  • Learning Linux Binary Analysis - The first three chapters of this book give a nice overview of ELF and the tools available to manipulate ELF files with. Not an absolutely necessary book, since its primary focus is on virus analysis and related topics, but it is really interesting and the first couple chapters provide some useful information for better understanding ELF.
  • Ian Lance Taylor's Blog  - If you aren't up for reading through Linkers & Loaders, this is a pretty good substitute. It doesn't go quite as in depth, and doesn't have practice exercises, but he wrote about 20 entries describing the inner workings of linkers. It was written a bit more recently than Linkers & Loaders and has a bunch of useful explanations.
  • Asking questions on IRC! When I've run into issues I couldn't find documented elsewhere or things I didn't understand (for example, there are a whole ton of acronyms, most of which are documented here but not all), I asked on the IRC channel and always got a helpful response that at the very least told me where to start looking.

Getting used to IRC

At least for me, communicating via IRC has been pretty funky to get used to and was definitely one of the biggest hurdles to overcome to start working with the Perl 6 community. In a nutshell, IRC (Internet Relay Chat) is one of the older forms of instant messaging. You can access the various Perl 6 channels through your browser, but for me, since I check them every day, it was a lot easier for me to download an IRC client. I use HexChat since it was one of the free, recommended ones for Windows. There is a way that you can connect to IRC via Discord, but I haven't tried it.

All of the main Perl 6 channels are hosted on freenode. The channels I most frequently have up are #moarvm, #perl6-dev, and #perl6. When you connect to a channel, you also have to pick a handle to go by. A lot of people in the Perl 6 community tend to pick handles based on their names, but not everyone (for example, Perl's creator Larry Wall goes by TimToady). One of the hard to adjust to characteristics of IRC is that when you connect, you can't scroll back to see recent conversations. Instead, each of the channels has a link to the chat history which you can click on to view all the chat logs. MoarVM's is herePerl6-dev's is here, and Perl6's is here.

For the most part, it's like just about any instant messaging service. People tend to try to keep their messages on the shorter side, and have one main thought per message. This site was helpful for me when trying to figure out IRC commands, which you can use to privately message someone or change your nickname, among other things. If you're talking publicly and directly to someone, you can indicate that by writing "their_handle: Do you know where to find blah?" On the Perl channels, there are a couple of non-words that get used, like \o or o/ (which is a little person waving hello), and BBL (be back later).

IRC was incredibly intimidating for me because I wasn't really sure what the social norms were, and I didn't want to come across as rude or ignorant. But again, the Perl 6 community seems to be extremely welcoming of newcomers and people are happy to answer questions, so don't be afraid to reach out. As long as you aren't actively trying to make people upset, you aren't likely to step on any toes.

Setting up your development environment

*** This section was updated on July 3rd, 2019. ***

There are a whole ton of different tutorials out there for what you need to get started contributing to Perl 6. I found and followed the instructions for a couple of these before finally winding up with everything set up in a way that worked. Unfortunately, some of the guides floating around are out of date, and contain incorrect information about what you need or how to set things up. If you're planning on messing around with Rakudo and not touching the MoarVM at all, following the official Getting Started instructions will work. But, if you'll be touching MoarVM, like me, you should follow the following instructions if you're working in a Linux environment:
  1. Clone the MoarVMNQP, and Rakudo into the directory of your choice. Mine all live in $HOME/sandbox/perl6. Configure and install MoarVM in a local directory.
  2. Configure and install MoarVM. To do this, cd into the MoarVM repository and run the following command:
          perl --prefix=<directory> --optimize=0 --debug=3; make install
    The optimize and debug flags aren't strictly necessary, but help provide more useful information when you're debugging and tracing through a call using GDB
  3. Configure and install NQP. To do this, cd into the NQP repository and run the following command:
          perl --prefix=<directory> --backends=moar; make install
  4. Configure and install Rakudo. To do this, again, cd into the Rakudo repository and run the following command:
          perl --prefix=<directory>; make install
Important Note: Do not use the '~' in the path for the directory that you're using as your prefix. It will not work as you expect. During the make install step, the command used to make the bin, include, lib, and share directories will interpret '~' as the name of a directory, which it will then create and put everything inside of. Instead, use $HOME or write out the whole, absolute address of your prefix directory.

Once you've done all that, you should wind up with a directory that looks something like this:
The bits you'll likely be messing around with and using are in ./MoarVM (MoarVM's source code), ./nqp (NQP's source code), ./rakudo (Rakudo's source code), and ./bin (executables for your version of MoarVM, NQP, and Perl 6).

You are now officially set up! If you make any changes to MoarVM, NQP, or Rakudo, do a make inside the appropriate directory to recompile them. Another useful make option is make fullclean, which does a deep clean of the generated objects in the directory its used in.

This entry got a little long so I'm going to be posting again a bit later to specifically talk about the linker and my progress on it so far. I hope that this is helpful for others starting on a linker project or contributing to Perl 6!


Popular posts from this blog

Flags and Syscalls and Modules, Oh My!

Building an ELF File