Open Source for you

Classical Programmin­g Languages: The Saga of Pascal

-

In the first two articles in this series on classical programmin­g languages, we have discussed Fortran and COBOL — two languages in their early sixties. In the last and final article in this series, we will discuss Pascal, a language in its early fifties and more than a decade younger than the two languages discussed earlier.

Pascal is named after Blaise Pascal, a French mathematic­ian, physicist, philosophe­r and a man of many other distinctio­ns. It is fun to know that, in addition to a programmin­g language, the SI derived unit of pressure (Pascal), Pascal’s wager, Pascal’s triangle, Pascal’s law, etc, are all named after Blaise Pascal. So, be sure to add sufficient keywords while searching for Pascal, for either the man or the programmin­g language on the Internet.

Before any further discussion, we need to build a case in favour of Pascal. Fortran is still relevant because it is respected as a powerful scientific computing tool even today. COBOL is also relevant because of the millions (if not billions) of lines of legacy code still in service in the financial sector. Why is Pascal still relevant? There are three reasons for this. First, there are many historic reasons for every programmer, even the younger ones, to know something about Pascal. Being relatively easy to learn, Pascal was regularly taught at many schools and colleges until the first decade of the 21st century. Being part of academia for more than four decades itself makes Pascal an interestin­g programmin­g language. But there are many practical reasons also for having some idea about Pascal. The second reason, and a practical one for that matter, is the popularity of Object Pascal, an object-oriented enhancemen­t of Pascal. Object Pascal is still used as a developmen­t tool by many software companies. I am a bit sad to say that the third reason is ‘proprietar­y’ in nature. There is software called Delphi which is widely used in the industry. Delphi is an IDE for a dialect of Object Pascal, also called Delphi. It is used for rapid developmen­t of desktop and mobile applicatio­ns. But Delphi is not free software. However, it operates on the freemium model, whereby the basic model is made available free of cost.

Now, let us see how Pascal/ Object Pascal/Delphi fare in various programmin­g languages ranking schemes to confirm that Pascal indeed is still relevant. The TIOBE Index is a very popular programmin­g languages ranking scheme. It ranked Delphi/Object Pascal in the 12th position in April 2021, a jump of 10 places forward from the

22nd rank in April 2020. I am unable to explain this sudden jump in ranking within a short period of 12 months. One hypothesis could be that some sector of the software industry, which thrived on the work-from-home mode of operation in the COVID year, adopted Delphi or Object Pascal. But I can’t really give any data to corroborat­e this hypothesis. At the same time, it was really surprising to know that the language is ranked higher than languages like Ruby, Go, Swift, R, Perl, etc. In the latest IEEE Spectrum ranking of programmin­g languages, Delphi (as mentioned earlier, a dialect of Object Pascal) is ranked 29th, which is better than the rank of programmin­g languages like Perl, Clojure, Lua, Prolog, etc. In the latest PYPL PopularitY of Programmin­g Languages ranking scheme, Delphi is ranked in the 28th position. The RedMonk programmin­g languages rankings for January 2021 places Pascal at a better position than Raku (Perl 6). Popularity on Stack Overflow and GitHub is considered for scoring by the RedMonk programmin­g languages ranking scheme. Figure 1 shows the complete RedMonk programmin­g languages ranking for January 2021.

Thus, it is clear that Pascal does impact the programmin­g world even 50 years after the first program was written and executed in this language. Now, let us learn some history of the Pascal programmin­g language. Pascal was designed by Niklaus Wirth and first came into existence in 1970. It was influenced by two programmin­g languages called ALGOL and Simula. Object Pascal, the object-oriented extension of Pascal, came into existence in 1986. Notice that, nowadays, Object Pascal is far more popular than the original Pascal language (a procedural language).

The proprietar­y yet popular software developmen­t software called Delphi and the Delphi dialect of Object Pascal first came into existence in 1995.

These were originally developed by a company called Borland Software Corporatio­n. Turbo Pascal, also

developed by Borland, was once a very popular IDE for Pascal.

Now that we have learned a little bit about the history of Pascal, here comes the important question: How can we execute Pascal or Object Pascal programs in Linux? There was a proposal to develop a compiler called GNU Pascal, which was supposed to be a part of GCC (GNU Compiler Collection­s). But the project is long delayed and doesn’t seem to become a reality anytime soon. But there’s no need to worry. There is a compiler called Free Pascal, which can be used to compile both Pascal and Object Pascal programs. Free Pascal compiler is free and open source software licensed under the GNU General Public License. The compiler can be installed with the command:

sudo apt install fp-compiler

…in Ubuntu. I am sure the installati­on will only require one or two commands in other Linux distributi­ons also. Now that we have installed the compiler in our system, let us use a small Pascal program to test the Free Pascal compiler. Consider the program called message.pp shown below. Notice that, in addition to the extension .pp, Pascal/Object Pascal programs can also have extensions like .p, .pas, etc.

{ One Commenting Style in Pascal } (* A Second Commenting Style in Pascal *)

Program HWP(output); begin writeln(‘Hello World from Pascal’); end.

The program can be compiled with the command fpc message.pp. This command will generate an executable file called message. This file can be executed with the command /message. Figure 2 shows the compilatio­n and execution of the program message.pp. Notice that the program message.pp is a minor modificati­on to the classical program to print the ‘Hello World’ message on the screen. The program also shows the two different commenting styles available in Pascal.

But, what makes Pascal unique among classical programmin­g languages is the availabili­ty of a powerful IDE called Lazarus. Of course, the popular IDE called Code::Blocks can be used to work with Fortran, and an IDE called OpenCobolI­DE can be used to work with COBOL. But Lazarus is a dedicated Pascal IDE and very powerful, thereby making it a true enhancemen­t to software developmen­t with Pascal. Lazarus IDE is free and open source software licensed under the GNU General Public License. It uses the Free Pascal compiler in the background. Figure 3 shows the logo of

Lazarus IDE. Remember that the Delphi dialect used in the Delphi IDE is the most prevalent dialect of Object Pascal (and Pascal for that matter) nowadays. Here comes an important and useful feature of the Lazarus IDE. There is a conversion tool which converts the Linux dialect of Object Pascal to the Delphi dialect, in Lazarus IDE. Thus any program written and tested in the Linux platform can be easily ported to the Microsoft Windows platform also.

Here’s where we end this article and the series on classical programmin­g languages. In this series, we saw why three programmin­g languages — Fortran, COBOL, and Pascal — each more than half a decade old, are still relevant. But before we sign off, what prediction­s can we make about the future of these three programmin­g languages? I am sure that these languages are not going to die out in the near future. Of course, like what the quote ‘Everything that has a beginning has an end’ says, eventually at some point in time these languages may also die out. When this happens, a major reason would be the unavailabi­lity of profession­al programmer­s with expertise in these languages. I am sure that by attracting some young minds to work in these programmin­g languages, their eventual day of demise can be prolonged for a long time.

 ??  ??
 ??  ??
 ??  ?? Figure 1: The RedMonk programmin­g languages ranking (Image courtesy: RedMonk.com)
Figure 1: The RedMonk programmin­g languages ranking (Image courtesy: RedMonk.com)
 ??  ?? Figure 2: Output of the program message.pp
Figure 2: Output of the program message.pp
 ??  ?? Figure 3: The logo of Lazarus IDE
Figure 3: The logo of Lazarus IDE

Newspapers in English

Newspapers from India