September 14, 2019

The Perl language as a guideline for understanding modern programming

The Perl language was developed in the late 1980s and had fallen out of fashion since a while. It's a programming language which has revolutionized computer programming in the past, because it was the first widespread used scripting language. Perl was introduced in a time, in which programming in UNIX was done entirely with the C language. From the perspective of C, Perl doesn't make much sense. Because all the libraries are written in Perl again. It was yet-another-programming language which resulted into extra work, new scripts and a different ecosystem.

Exactly this was the reason why Perl and all the other later examples of scripting languages were successful. Because they are focussed not on classical programming but on scripted programming. The advantage of using Perl over C is the same, like modern Python programmer would explain why they have choosen the language of Guido van Rossum: because in a few lines of Perl it's possible to create complex applications. Secondly, there is no need to use pointers, integer variables or a compiler. But a simple hello world script fits into a single line of code.

From the computer history perspective, Perl was a successful attempt in reinventing computer programming. Instead of writing code for the machine, the code was written for a parser, called the Perl interpreter. Similar to a modern Java VM or a PHP interpreter, the Perl parser isn't compiling the code into machine code, nor it is doing a syntax check if the semikolon was put at the correct position. The self-understanding of Perl programmers is, that they are not interesting in creating machine code, or want to extend the operating system. But they want to deliver a HTML webpage or test a prototype.

Another interesting point is, that Perl never replaced existing C code. After the invention of Perl, the previous created c applications were used unchanged. But Perl was thought as an additional language. It was the beginning of creating a zoo of languages. Instead of deciding between C and assembly language, the programmer had the choice between Perl, TCL, Bash script, Modula-2, Postscript and Clipper.

From an abstract point of view, Perl resulted into many newly created lines of code. The CPAN directory was created from scratch. It started with 0 entries and today around 180k modules written in Perl are available. All of the code was created manual and tested by the community. In most cases, the code is doing exactly the same what a well maintained C program can do, but it's written in Perl. It seems, that there is some kind of general law which says, that the number of different programming languages has exploded. And each language community follows it own rules.

Does it make sense to invent the Perl language next to the C language? Sure, because technically both concepts are different. For some tasks, C is the better choice, but many things can be done with Perl perfect. With the same argument, new languages after Perl can be explained. For example the Java language is very different from Perl and C together. Java is not a compiled language, but it's also different from an interpreted language. In contrast to Perl, Java was developed with object orientation in mind from the beginning.

All the programming languages can be divided into two groups. The first one are optimized for the compuer in mind. They are compiled low level languages which are hard to learn but run efficient on today's hardware. Typical example is the C++ language. The second group are prototyping languages which are mostly interpreted but sometimes they run a virtual machine like C# language. Their idea is, that it's ok if the program runs 5x slower than a C program, but it provides an easier syntax and makes it useful for programming newbies. The typical example is Python, but languages like AutoIt (Macro language for Windows GUI testing) and Matlab script (embedded language in a mathematics software) can be included in this category as well.

The most interesting fact is, that code reuse between the languages isn't there. Instead, each community is creating all the libraries from scratch. The idea is to increase the total number of codelines. The reason why so many languages were invented has to do with the architecture which runs the code. The classical platform for run computer code was a barebone CPU. That means, the CPU contains of 10 registers and an instruction pointer, and the language of choice was Assembly. The next logical step is a compiled language which simplifies assembly programming. In the C language the programmer doesn't create a program for a Register machine, but he is programming software which runs on a general computer which contains of memory and lots of subroutine. This kind of evolution goes on: OOP means to program code for an architecture which is more powerful, and the latest version of the AutoIt programming language assumes that a well equipped Windows operating system is already there which contains of preinstalled programs.

No comments:

Post a Comment