Thu, 12 Aug 2010
What is "Modern Perl"?
These days you often hear term Modern Perl, as something new(ish), and much improved over the old ways.
But what is it exactly? Well, there's no proper definition, but here is what that term means to me:
It's a set of tools, ideas and attitudes that help you to write better Perl programs, and allows you to have more fun while writing them.
Here are some aspects of Modern Perl
- Testing: Most modern Perl modules have extensive test suites, that make development sane and robust
- Some built-ins now come with safer forms: the three-argument form of open() allows you to open files safely with arbitrary characters in them, without any extra precautions. Lexical file handles make things safer and easier too.
use strict; use warnings;
- Proper OO: with Perl 6 and with Moose in Perl 5, we have good object systems, that require less low-level fiddling than the standard Perl 5 object system
- Following Best Practices
- (For open source projects) Liberally handing out commit privileges. The source is stored in a version control system anyway, so low-quality changes or vandalism can simply be reverted (but that doesn't happen often in practice).
- Caring about marketing: do tell people that you built something cool and useful
- Small handy modules such as List::Util and Try::Tiny
- Development tools such as Devel::Cover and Devel::NYTProf
- (update) perlbrew and local::lib to help maintain your own perl installation and locally installed modules.
All of these techniques help to write scalable Perl programs by making proper encapsulation much easier, or by avoiding common errors, identifying performance bottlenecks etc.
Update: after watching some discussions about this post in various media, I should add a few more tools that I forgot about earlier: