A Review of “Mastering Algorithms with Perl”

[SomeDudeSays.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.]

This is another hit from O’Relly for learning Perl. The Perl Cookbook is good, but it focuses on the language and how to accomplish specific tasks, but not why we use certain methods rather than others. Let’s dive straight into the book.

About the Book

This book has a lot of math, but most of it is accessible with college calculus and a strong resolve. A lot of the algorithms can be used (and mostly understood) without the math as well. The book doesn’t really cover Big O notation at all (it’s literally not even in the index), but it does use it for efficiency.

Mastering Algorithms with Perl covers both algorithms and data structures. A lot of the type of data structures you’d learn about for Java and C aren’t covered too heavily in this book. They’re trivial to implement in Perl. This book shows you how, explains why they matter, and what they’re used for, but it moves through them fast (two chapters for what most books cover in 200 pages or more).

The book expects some degree of familiarity with the subject, but is also approachable for a beginner (intermediate programmer new to the study of algorithms). This was my first real algorithms book outside of the odd off section in a textbook style programming book. I ended up jumping around the book a lot as it gets a bit hard to follow at certain parts unless you have a use case for the specific algorithm family.

How It’s Organized

That brings me to the next point, the organization. Each chapter is self-contained for the most part. It expects some basic familiarity for some of the early chapters or at least the material they contain, but there’s no sense of constant building. Don’t get me wrong, the book builds on itself a lot, since each topic is introduced in a self-contained way and branches out. There is growth and development, the further in, the more familiar you have to be with other portions to get past the survey level introduction.

When I first read it, I ended up skipping from the basic data structures chapter to the basic sorting chapter without incident. Obviously, the advanced data structures chapter is going to require familiarity with the basic data structures, but most of the sections build off of the basics only and grow from there.

If you find yourself struggling after the beginning of a chapter, consider skipping it and going back later. Some of the topics just won’t be applicable to you in the beginning either. This book definitely takes the “mastering” part of the title seriously.

Pros

The organization is a pro for this book (and a con, but we’ll get to that soon). The fact that each section past the beginning parts is relatively self-contained makes this book much more accessible if you need it to really get going. I feel this book is a contender for the classic Introductions to Algorithms book suggested to pretty much anyone who expresses an interest in algorithms or data structures. The difference is you see everything in real code rather than trying to adapt it from the pseudocode it used to have or the abstract Java it has now.

The code resembles real life Perl you’ll actually encounter for better and for worse. At least a few of the authors do not appear to be fans of the “strict” keyword. As long as you follow best practices with Perl, this is an easy fix for basically all of the examples. Most of the code examples are basically strict without explicit variable declarations.

This book is not afraid to use real life modules either. Examples can be applied to your project in a scalable fashion without every single unit reinventing the wheel. This is useful for beginners and more advanced learners. Intermediate learners trying to take things apart and tinker more can still work around this by understanding the base algorithm.

Cons

The organization is one of the book’s pros, but also one of its cons. If you’re jumping to this book on shaky ground, the organization can potentially be a hindrance. You have to be topically familiar to know whether something builds off of something or not. You also have to be able to tell when the book gets conceptually out of your depth and be willing to move on at that point.

The style lacks the strict keyword. This doesn’t sound like a huge deal, but can be argued to not be best practice with current Perl. This book was written before this became commonplace best practices however.

Using This Book

I would strongly recommend using this book in conjunction with another resource unless you’re buying this explicitly to learn how to do each algorithm in Perl. The previously mentioned Introduction to Algorithms book is a great resource. I learn best from a book, but in this day and age, Wikipedia or Google will help you round out the topics for the most part.

Read up on Big O notation and other concerns for algorithms before starting this book. It does take certain fundamentals for granted, so be prepared. Most everything requires some level of math to really master. There are bits and pieces from set theory, number theory, geometry, statistics, differential equations, etc. You don’t strictly need the math to understand how to accomplish the individual task, but it is essential to actually understand what is going on. This is true of basically any in depth algorithms book though.

Conclusion

The book covers algorithms, data structures, and how to apply them in Perl. This book is essential reading for anyone getting serious with the language who hasn’t had a formal education with computer science. It makes a great refresher on the subject and is great for those just looking to apply this knowledge to Perl.

I read this book in conjunction with Introduction to Algorithms and it pushed me way further than I thought it would. I could never have started coding professionally without this book. Mastering Algorithms with Perl really made the abstract concepts of what an algorithm did make sense in the context of a real programming language. It also made me learn to really think like a real programmer and to become one.

Get it here.