Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Google   


Introduction to Perl for Unix System Administrators

(Perl without OO and excessive complexity)

by Dr Nikolai Bezroukov


1.3. Perl History

 PL/1 as a precursor for Perl

For historic reasons Perl's syntax resembles C-shell and it has a superset of AWK repertoire of built-in function. That means that those who know shell programming feel that they can adapt to Perl without major problems. That's why many UNIX users find Perl (deceptively) easy to learn. In reality Perl is a very complex language with a complex semantic. The slogan of Perl...."There's always more than one way to do it."  is essentially the same idea that inspire the designers on PL/1 and it would definitely find home in hearts of designers of MS Office ;-).  Different Perl programmers may use different approaches even for simple problem. In this sense Perl can be considered an anti-Unix (countercultural) development ;-). And Larry Wall agree with this:

But Perl was actually much more countercultural than you might think. It was intended to subvert the Unix philosophy. More specifically, it was intended to subvert that part of Unix philosophy that said that every tool should do only one thing and do that one thing well.

The problem with that philosophy is that many of the tools available under Unix did not, in fact, do things very well. They had arbitrary limits. They were slow. They were non-portable. They were difficult to integrate via the shell because they had different ideas of data formats. They worked okay as long as you did what was expected, but if you wanted to do something slightly different, you had to write your own tool from scratch.

So that's what I did. Perl is just another tool in the Unix toolbox. Perl does one thing, and it does it well: it gets out of your face.

But it is very interesting to note that Perl has one very unlikely precursor (I do not know whether Larry Wall ever worked on mainframes). When I first encountered Perl I was surprised how many of underling ideas of Perl are close to PL/1 -- the language that served as one of the inspirations for the C and despite being a mainframe language historically related to the Unix culture via its Multix roots. PL/1 was innovative language that was too far ahead of its time to survive. It was the first language that contained good string handling, exception handling, rudimentary multitasking.  It was and probably still is one of the most interesting algorithmic languages in existence, although it's popularity (similar to popularity of many other interesting IBM products with VM/CMS and OS/2 and examples) that suffered blows from IBM itself and in 70th from religious fanatics in the days of structured programming and verification.  What is most interesting that despite its age PL/1 has probably the best optimizing and debugging compilers for any language of similar complexity in existence.  IBM optimizing and debugging compilers for PL/1 on system 360/370 remain an unsurpassed masterpiece of software engineering. They will always be remembered along with FORTRAN H and PL/C compilers.

Probably the major killing factor was that compiler for PL/1 was too complex for many organizations to reimplement (it is probably close to similar to C++ compilers in complexity). No free compiler existed although Cornell University managed to implemented PL/C -- a pretty full teaching subset of PL/1 and successfully use it for a number of years. Even later simplified version called PL/M was not able to withstand the competition with free C compilers.  I wonder what would happen to PL/1 if IBM released the compiler under some king of  open source license. BTW currently the quality of Perl interpreter is much less that PL/1 debugging compiler. 

Paradoxically, PL/1 compilers were used as open source free products in Eastern Europe and the USSR. And it is interesting to note that it really dominated mainframe programming in the USSR, far outpacing Cobol and Fortran that still dominate the mainframe arena in the USA and other Western countries. So here analogy with Perl hold perfectly. Moreover PL/1 dominated despite the fact the Soviet IBM 360/370 clones (called EC -- Russian abbreviation of "Uniform System of Computers") were less powerful (and less reliable) that Western counterparts.

I would like to stress that PL/1 (as a system programming language for Multix) has large influence on C -- one of the most widely used compiled programming languages and many of it's ideas directly or indirectly found its way into other programming languages (I have no information about Larry Wall possible exposure to PL/1) can be found in Perl. IMHO understanding if not PL/1 programming, but PL/1 philosophy -- or its close relative Perl philosophy can benefit programming community much more that playing with languages based on some kind of religious doctrine like pure strongly type languages or OO languages ;-).

The beginning of Perl development

Perl is an acronym for "Practical Extraction and Report Language."  The first version of Perl was developed by Larry Wall around 1987 and like many other languages the development was partially financed by military. See excellent  Perl Timeline for more information. In the paper Linux Magazine October 1999 FEATURES Uncultured Perl  Larry Wall wrote:

Like the typical human, Perl was conceived in secret, and existed for roughly nine months before anyone in the world ever saw it. Its womb was a secret project for the National Security Agency known as the "Blacker" project, which has long since closed down. The goal of that sexy project was not to produce Perl. However, Perl may well have been the most useful thing to come from Blacker. Sex can fool you that way.

"Blacker" project needed some  C/AWK/SED superset -- an attempt to add AWK and SED features to the C-shell framework. The idea was to create a language more suitable for processing logs and generating reports for large quantities of data than combination of shell, AWK and C-shell. Design contains both a lot of strong solutions and the language got some traction. Here how Larry Wall explains his decision:

At this point, I'm talking about Perl, version 0. Only a few people in my office ever used it. In fact, the early history of Perl recorded in O'Reilly's Camel Book (Programming Perl) was written by my officemate of the time, Daniel Faigin.

He, along with my brother in law, Mark Biggar, were most influential in the early design of Perl. They were also the only users at the time. Mark talked me out of using bc as a backend expression processor, and into using normal, built in floating point operations, since they were just being standardized by the IEEE (Institute of Electrical and Electronics Engineers). Relying on that standard was one of the better decisions I ever made. Earlier scripting languages such as REXX didn't have that option, and as a result they tend to run slower.

The very first version already contained a lot strong points anf first of all the principle idea that the langue should provide for special constucts optimizing the usage of common, most frequent idioms:

I made one major, incompatible change to Perl just before it was born. From the start, one of my overriding design principles was to "optimize for the common case." I didn't coin this phase, of course. I learned it from people like Dennis Ritchie, who realized that computers tend to assign more values than they compare. This is why Dennis made = represent assignment and == represent comparison in his C programming language.

I'd made many such tradeoffs in designing Perl, but I realized that I'd violated the principle in Perl's regular expression syntax. It used grep's notion of backslashing ordinary characters to produce metacharacters, rather than egrep's notion of backslashing metacharacters to produce ordinary characters.

It turns out that you use the metacharacters much more frequently than you do the literal characters, so it made sense to change Perl so that /(.*)/ defined a substring that could be referenced later, while /\(.*\)/ matched a sequence inside literal parentheses.

The decision to release it as free open sourced software was also a brilliant and in 1997 not an easy one:

I knew that I didn't dare ask the company lawyers for permission, because they'd have thought about it for something like six months, and then told me "no." This is despite the fact that they wouldn't be interested in peddling it themselves. In the old days, a lot of free software was released under the principle that it's much easier to ask forgiveness than to seek permission. I'm glad things have changed -- at least to the extent that the counterculture is acknowledged these days, even if it's not quite accepted. Yet.

There were several versions of Perl but that most important are version 4 and version 5 (released in 1995). The latter is still the current version of the language. Version 4 was widely available before WEB explosion in 1994.

Another thing that helped legitimize Perl was the addition of the Artistic License to stand beside the GPL. Perl 3 used only the GPL, but I found that this didn't do quite what I wanted. I wanted Perl to be used, and the GPL was preventing people from using Perl. Not that I dislike the GPL myself -- it provides a set of assurances that many hackers find comforting. But business people needed a different set of assurances, and so I wrote the Artistic License to reassure them.

The really brilliant part was that I didn't require people to state which license they were distributing under, so nobody had to publicly commit to one or the other. In sociological terms, nobody had to lose face, or cause anyone else to lose face. Most everyone chose to read whichever license they preferred, and to ignore the other. That's how Perl used psychology to subvert the license wars which, as you may or may not be aware, are still going on. Ho hum.

Yet another thing that helped legitimize Perl was that there was a long period of stability for Perl 4, patch level 36. The primary cause of this was that I abandoned Perl 4 to work on Perl 5.

 Version 5 was introduced slowly with first workable version in early 1995 (just before Java).

For Perl, the meltdown happened because I decided to follow the rule: "Plan to throw away your prototype, because you will anyway." Perl 5 was nearly a total reorganization. I have in times past claimed that it was a total rewrite, but that's a bit of a stretch, since I did, in fact, evolve Perl 4's runtime system into Perl 5's. (Though if you compared them, you'd see almost nothing in common.) The compiler, though, was a total rewrite.

All programming languages are essentially compilations. There have always been important programming languages that differ from mainstream ALGOL-style languages.  For example Fortran was different and more suitable than Algol-style languages to numeric computations. One should see Perl as one of such non-Algol family languages. Among important non-traditional precursors of Perl are:

Although this is an important part of history, I do not want to delve into religious debates about merits of a particular approach or discuss in what language a particular feature was first introduced. Many things in languages were invented/reinvented in parallel. See Python Compared -- a very interesting page that provide a lot of relevant links. Perl is a compilation, but it is a useful complication that extent some features in such way that they can be considered innovations. But at the same time viewing Perl as one branch among several largely parallel development streams helps in understand the language, it's strengths and limitations.  Being a PL/1 style language Perl added  and developed further some interesting ideas originated in Unix shell languages (mainly in Born shell). Among them:

WEB period

WWW has dramatically raised the visibility of Perl in recent years -- to certain extent at the expense of TCL and other Unix-based scripting languages, although WEB also produced several Perl competitors like JavaScript and PHP.  Due to the Web Perl has become one of major programming languages for Internet -- practically like VB dominates Windows arena, Perl now dominates CGI scripts arena -- not only because it is quite suitable for the purpose -- but also because it happened to be at the right place at the right time.  For that role Perl has been called "the duct tape of WEB".

Although Perl implementation is an open source implementation, commercial companies actively participate in its development. The major commercial beneficiary of Perl success was O'Reilly & Associates that published first books on the language (Programming Perl and Learning Perl in 1993) and now sells millions of dollars worth of Perl books each year. Recently they make a largely unsuccessful attempt of distributing Perl Resource Kit. At the same time they provide financial support for the Perl movement. Since 1995 they employ Larry Wall. O'Reilly also hosts Perl web site and sponsors a Perl conference.

Larry Wall is a pretty interesting figure on the open source/free software arena. Perl creating and writing first Perl interpreter was a really huge project. Unlike Linux Torvalds Larry Wall did not have POSIX standards before him to solve architectural problems although Unix shell languages provided some guidelines. It is interesting to know that Perl was not his first freeware effort -- before it he created a popular USENET newsreader rn and several other programs -- the development of the language of this level of complexity is really an exhausting full time job. His personal site is www.wall.org. The little known fact is that he created all his programs being almost completely blind on one eye. Recently he published a diary relating details of hiscornea transplant surgery that improved his vision. See Portraits of Open Source Pioneers for additional information.

Future Developments

Perl is now so big and complex that adding features are a tricky exercise. Support for Unicode was one of the most important recent additins, but another that that I expect that the language will evolve very slowly.

 

 


Copyright © 1996-2008 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: March 15, 2008