Channels ▼
RSS

JVM Languages

Why I Use Perl...and Will Continue to Do So


Arrays

The ability to manipulate arrays in Perl is just beautiful. You can dynamically add/remove elements from the end of the array using PUSH/POP, and dynamically move elements into the front of the array using UNSHIFT/SHIFT. Arrays can be indexed positively from the beginning of the array, or with negative indices from the end of the array. Building FIFOs, LIFOs, queues, and stacks is easy. Split and join are two built-in functions that allow for the creation and collapsing of arrays. Splice gives us the power to remove and add elements within the array. Sort and reverse sort allow for sorting in both directions.

Beginning programmers can easily be turned off by Perl's lack of support for multi-dimensional arrays. But the better way to create complex structures including multi-dimensional arrays is to use references (and you cannot fully exploit the power of any language without the use of references).

Smart, High Level Language with Great Built-In Functions

Perl is a high level language. It is a smart language. It simplifies its variable types to scalar, array, and hash.

We never have to worry about variable types. Perl knows when to interpret a value as an integer or a string. The right-hand side knows whether the left-hand operand is asking for an array or single-value. And using "wantarray," you can write your own subroutine modules with similar smartness. And arrays, hashes, and structures can grow and shrink dynamically — Perl takes care of it automagically.

It also supports a large number of great built-in functions. Take a look at the Schwartzian transform to see the power of sorting complex structures using the Map function. And I love the ability to look at a variable and determine whether it is of type $scalar, @array, or %hash by the prefix.

Full Programming Language

Perl is more than a scripting language. It is a general-purpose language. It supports threads and recursion. In one application, I have 16 threads running diagnostics in parallel on a chassis in factory. Perl supports object-oriented programming, and the new Moose library automates and simplifies much of the work. And, finally, GUI support is made possible by using Perl/Tk.

CPAN, Community, and Books

Perl is an open-source language with a strong community. The Perl Comprehensive Perl Archive Network (CPAN) is a repository with more than 25,000 modules. My use of Perl today would be very limited without the ability to use modules like DBI, Excel, Telnet, FTP, Ping, and Win32:Serial Communications to name a few of the modules critical to my field of work.

Learning Perl is made easy by the many free tutorials on the web. Simply start with www.perl.org to begin the discovery and learning process. In addition, Learning Perl, Intermediate Perl, and Programming Perl are three essential books for mastering the language. In this past year, new editions of these books were released to reflect language changes. Other good books worth mentioning are Effective Perl Programming and Perl Best Practices.

Active State

ActiveState deserves special mention here. For a small fee, you can purchase a compiler that creates a pseudo executable. In deploying applications to remote sites, Active State's PDK allows programmers to compile an application into an executable. Simply drop an executable at one of the numerous factory test stations and you are done. You only need to maintain Perl Libraries at your development workstation. There is no need to worry about loading the latest libraries at every test station.

Other Languages

The aforementioned strengths noted for Perl may well be the strengths of other competing languages. I am not in a position to compare Perl to Python or other similar languages.

The power of Perl as outlined here relates to several domains of work related to data, tools, and automation. My experience is testimony to Perl creator, Larry Wall's statement that Perl is a language for "making simple things easy and difficult things possible." And for that reason, I hope that Mr. Binstock is wrong in his contention that Perl is in a tailspin; it's a wonderful language!


Sammy Esmail is a data, tools, and automation developer.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video