Ocean of Awareness

Jeffrey Kegler's blog about Marpa, his new parsing algorithm, and other topics of interest

Jeffrey's personal website

Google+

Marpa resources

The Marpa website

The Ocean of Awareness blog: home page, chronological index, and annotated index.

Tue, 06 Jul 2010


Parsing Perl 3: Perl and Minimalism

One ring to rule them all, one ring to find them,
One ring to bring them all and in the darkness bind them.

One Idea to Rule Them All

Ever since the 50's, the fashion in language design has been minimalism. Languages were designed around paradigms, and paradigms were judged on elegance. If your choice of paradigm was lists, the result was LISP. If you decided on strings, you invented SNOBOL. Arrays, you wound up with APL. If your reasoning led you to logic, you ended up with Prolog. If you thought that descriptions of algorithms must be the basis of programming, then your fate was Algol.

If assembly language stayed at the core of your world view, what you created would be an imperative lanugage and might look like any of C, BASIC or FORTRAN. If stacks were your thing, you created a language that looked like Forth. And who knows if the belief in objects as the one paradigm will ever again see Orodruin and feel the heat of the flames in which it was forged.

Some of these languages were totalitarian -- they insisted everything be shoehorned into their central concept. I recall some very unpleasant struggles with early dialects of SNOBOL, LISP and Prolog. Imperative languages tended to be more elastic. But, while the strictness of adherence varies, almost every language invented over the past 50 years bears the clear stamp of minimalism.

Minimalism is not without its triumphs. Scientists, acting in the spirit of minimalism, ruthlessly brushed aside long-held ideas when they could not prove their worth, and much of 20th century science is a result of this. In our field, the Unix operating system is a very successful example of the application of minimalist principles.

Minimalism and its Discontents

But, over time, it has become clear that the less strictly a language adheres to its central paradigm, the more useful it is. For the totalitarian languages, success came more in the form of influence on other systems than in direct application. People discussed pure LISP, APL and Prolog. They used C, BASIC and FORTRAN.

Unfortunately, principles tend to guide thinking, and not vice versa. Established principles become established precisely because, first and foremost, they make sure they have the last word when it comes to judging their own value. When our principles fail us, our first reaction, typically, is not to abandon those principles.

Even today, minimalism remains the dominant ideology in computer language design. When dissatisfaction with minimalism emerges, it tends to take the form of "more minimalism". The early history of programming languages is to a large extent a record of attempts to use minimalism to solve the problems of minimalism.

The Principle of Plenitude

[ Orthogonality is ] "all very well if you're trying to define a position in a space. But that's not how people think. It's not how natural languages work. Natural languages are not orthogonal, they're diagonal. They give you hypotenuses." -- Larry Wall, from a Dr. Dobbs interview

On December 18, 1987, I was waiting for the release of Perl 1.0 to comp.sources.misc. I downloaded it and started programming. It was a paid project, one which I had bid fixed price. I had planned to use mixed shell and C for this project. But among those in the know, the advance buzz for Perl 1.0 was good. Larry Wall was not the name he is now, but he already had a very solid rep from rn and patch. I decided to take a chance, and the result was profitable.

To my knowledge, Perl was the first language to actively embrace plenitude. Bourne shell tightly followed a "shell command" paradigm, Anyone who tries to use Bourne shell as a general-purpose language (and many do) has experienced what it is to fight line-by-line against a paradigm. AWK easily could have been the first non-minimalist language. But while AWK followed its script-editor paradigm loosely, it never actually broke away from it.

Perl borrowed liberally from Bourne shell and AWK, but above all it embraced plenitude. If there is one sure sign that minimalism is at work in a language design, it is when those controlling the evolution of a language refuse to add a useful feature solely on ideological grounds -- because the new feature does not fit a core design concept. From day zero, Perl has given cool new hacks the priority over ideology. I'd hesitate to call either AWK and or Bourne shell "minimalist", but even over their evolutions, the heavy hand of minimalism has ruled.

This is part of a series which explores the technical details of Perl parsing. Since this post is devoted to matters of history and philosophy, it might seem to be a digression. It is not. Working code is never just code. As we will see, perly.y is one of the better examples of that fact.

posted at: 14:56 | direct link to this entry

§         §         §