Up Next

This HTML version of Think Perl 6 is provided for convenience, but it is not the best format of the book. You might prefer to read the PDF version.

Chapter 0  Preface

Welcome to the art of computer programming and to the new Perl 6 language. This will probably be the first published books using Perl 6 (or one of the first), a powerful, expressive, malleable and highly extensible programming language. But this book is less about Perl 6, and more about learning how to write programs for computers.

This book is intended for beginners and does not require any prior programming knowledge, but it is my hope that even those of you with programming experience will benefit from reading it.

The Aim of this Book

This aim of this book is not primarily to teach Perl 6, but instead to teach the art of programming, using the Perl 6 language. After having completed this book, you should hopefully be able to write programs to solve relatively difficult problems in Perl 6, but my main aim is to teach computer science, software programming, and problem solving rather than solely to teach the Perl 6 language itself.

This means that I will not cover every aspect of Perl 6, but only a (relatively large, but yet incomplete) subset of it. By no means is this book intended to be a reference on the language.

It is not possible to learn programming or to learn a new programming language by just reading a book; practicing is essential. This book contains a lot of exercises. You are strongly encouraged to make a real effort to do them. And, whether successful or not in solving the exercises, you should take a look at the solutions in the Appendix, as, very often, several solutions are suggested with further discussion on the subject and the issues involved. Sometimes, the solution section of the Appendix also introduces examples of topics that will be covered in the next chapter–and sometimes even things that are not covered elsewhere in the book. So, to get the most out the book, I suggest you try to solve the exercises as well as review the solutions and attempt them.

There are more than one thousand code examples in this book; study them, make sure to understand them, and run them. When possible, try to change them and see what happens. You’re likely to learn a lot from this process.

The History of this Book

In the course of the last three to four years, I have translated or adapted to French a number of tutorials and articles on Perl 6, and I’ve also written a few entirely new ones in French. 1 Together, these documents represented by the end of 2015 somewhere between 250 and 300 pages of material on Perl 6. By that time, I had probably made public more material on Perl 6 in French than all other authors taken together.

In late 2015, I began to feel that a Perl 6 document for beginners was something missing that I was willing to undertake. I looked around and found that it did not seem to exist in English either. I came to the idea that, after all, it might be more useful to write such a document initially in English, to give it a broader audience. I started contemplating writing a beginner introduction to Perl 6 programming. My idea at the time was something like a 50- to 70-page tutorial and I started to gather material and ideas in this direction.

Then, something happened that changed my plans.

In December 2015, friends of mine were contemplating translating into French Allen B. Downey’s Think Python, Second Edition2. I had read an earlier edition of that book and fully supported the idea of translating it3. As it turned out, I ended up being a co-translator and the technical editor of the French translation of that book4.

While working on the French translation of Allen’s Python book, the idea came to me that, rather than writing a tutorial on Perl 6, it might be more useful to make a “Perl 6 translation” of Think Python. Since I was in contact with Allen in the context of the French translation, I suggested this to Allen, who warmly welcomed the idea. This is how I started to write this book late January 2016, just after having completed the work on the French translation of his Python book.

This book is thus largely derived on Allen’s Think Python, but adapted to Perl 6. As it happened, it is also much more than just a “Perl 6 translation” of Allen’s book: with quite a lot of new material, it has become a brand new book, largely indebted to Allen’s book, but yet a new book for which I take all responsibility. Any errors are mine, not Allen’s.

My hope is that this will be useful to the Perl 6 community, and more broadly to the open source and general computer programming communities. In an interview with LinuxVoice (July 2015), Larry Wall, the creator of Perl 6, said: “We do think that Perl 6 will be learnable as a first language.” Hopefully this book will contribute to making this happen.


I just don’t know how I could thank Larry Wall to the level of gratitude that he deserves for having created Perl in the first place, and Perl 6 more recently. Be blessed for eternity, Larry, for all of that.

And thank to you all of you who took part to this adventure (in no particular order), Tom, Damian, chromatic, Nathan, brian, Jan, Jarkko, John, Johan, Randall, Mark Jason, Ovid, Nick, Tim, Andy, Chip, Matt, Michael, Tatsuhiko, Dave, Rafael, Chris, Stevan, Saraty, Malcolm, Graham, Leon, Ricardo, Gurusamy, Scott and too many others to name.

All my thanks also to those who believed in this Perl 6 project and made it happen, including those who quit at one point or another but contributed for some time; I know that this wasn’t always easy.

Many thanks to Allen Downey, who very kindly supported my idea of adapting his book to Perl 6 and helped me in many respects, but also refrained from interfering in what I was putting into this new book.

I very warmly thank the people at O’Reilly who accepted the idea of this book and suggested many corrections or improvements. I want to thank especially Dawn Schanafelt, my editor at O’Reilly, whose advice has truly contributed to making this a better book. Many thanks also to Charles Roumeliotis, the copy editor, and Kristen Brown, the production editor, who fixed many typographical problems and spelling mistakes.

Thanks a lot in advance to readers who will offer comments or submit suggestions or corrections, as well as encouragements.

If you see anything that needs to be corrected or that could be improved, please kindly send your comments to think.perl6 (at) gmail.com.

Contributor List

I would like to thank especially Moritz Lenz and Elizabeth Mattijsen, who reviewed in detail drafts of this book and suggested quite a number of improvements and corrections. Liz spent a lot of time on a detailed review of the full content of this book and I am especially grateful to her for her numerous and very useful comments. Thanks also to Timo Paulssen and ryanschoppe who also reviewed early drafts and provided some useful suggestions. Many thanks also to Uri Guttman, who reviewed this book and suggested a number of small corrections and improvements shortly before publication. Kamimura submitted a couple of corrections in the errata list on the O’Reilly web site.

I know, it’s about Python, not Perl. But I don’t believe in engaging in “language wars” and think that we all have to learn from other languages; to me, Perl’s motto, “there is more than one way to do it,” also means that doing it in Python (or some other language) is truly an acceptable possibility.

Are you using one of our books in a class?

We'd like to know about it. Please consider filling out this short survey.

Think DSP

Think Java

Think Bayes

Think Python 2e

Think Stats 2e

Think Complexity

Up Next