Preface

Welcome to the art of computer programming and to the new Perl 6 language. This will probably be the first published book 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 of 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 Edition.2 I had read an earlier edition of that book and fully supported the idea of translating it.3 As it turned out, I ended up being a co-translator and the technical editor of the French translation of that book.4

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 my own, 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.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.

Tip

This element signifies a tip or suggestion.

Note

This element signifies a general note.

Caution

This element indicates a warning or caution.

Using Code Examples

Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/LaurentRosenfeld/thinkperl6/.

This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Think Perl 6 by Laurent Rosenfeld with Allen B. Downey (O’Reilly). Copyright 2017 Allen Downey, Laurent Rosenfeld, 978-1-491-98055-2.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

O’Reilly Safari

Note

Safari (formerly Safari Books Online) is a membership-based training and reference platform for enterprise, government, educators, and individuals.

Members have access to thousands of books, training videos, Learning Paths, interactive tutorials, and curated playlists from over 250 publishers, including O’Reilly Media, Harvard Business Review, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Adobe, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, and Course Technology, among others.

For more information, please visit http://oreilly.com/safari.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

  • O’Reilly Media, Inc.
  • 1005 Gravenstein Highway North
  • Sebastopol, CA 95472
  • 800-998-9938 (in the United States or Canada)
  • 707-829-0515 (international or local)
  • 707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://bit.ly/thinkPerl6.

To comment or ask technical questions about this book, send email to .

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments

I just don’t know how I could thank Larry Wall to the level of gratitude 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 you to all of you who took part in 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 into what I was putting in 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. I also want to thank Kristen Brown for her helpful comments and work on publishing this book, and Charles Roumeliotis and Molly Ives Brower for their constructive review and edits.

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

If you see anything that needs to be corrected or that could be improved, please kindly send your comments to .

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.

1 See, for example, http://perl.developpez.com/cours/#TutorielsPerl6.

2 See http://greenteapress.com/wp/think-python-2e/.

3 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.

4 See http://allen-downey.developpez.com/livres/python/pensez-python/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset