In the first two articles in this series on classical programming 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 mathematician, physicist, philosopher and a man of many other distinctions. It is fun to know that, in addition to a programming 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 programming 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 interesting programming 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 enhancement of Pascal. Object Pascal is still used as a development tool by many software companies. I am a bit sad to say that the third reason is ‘proprietary’ 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 development of desktop and mobile applications. 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 programming languages ranking schemes to confirm that Pascal indeed is still relevant. The TIOBE Index is a very popular programming 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 corroborate 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 programming languages, Delphi (as mentioned earlier, a dialect of Object Pascal) is ranked 29th, which is better than the rank of programming languages like Perl, Clojure, Lua, Prolog, etc. In the latest PYPL PopularitY of Programming Languages ranking scheme, Delphi is ranked in the 28th position. The RedMonk programming 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 programming languages ranking scheme. Figure 1 shows the complete RedMonk programming languages ranking for January 2021.
Thus, it is clear that Pascal does impact the programming world even 50 years after the first program was written and executed in this language. Now, let us learn some history of the Pascal programming language. Pascal was designed by Niklaus Wirth and first came into existence in 1970. It was influenced by two programming 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 proprietary yet popular software development 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 Corporation. 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 Collections). 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 installation will only require one or two commands in other Linux distributions 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 compilation and execution of the program message.pp. Notice that the program message.pp is a minor modification 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 programming languages is the availability 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 OpenCobolIDE can be used to work with COBOL. But Lazarus is a dedicated Pascal IDE and very powerful, thereby making it a true enhancement to software development 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 programming languages. In this series, we saw why three programming languages — Fortran, COBOL, and Pascal — each more than half a decade old, are still relevant. But before we sign off, what predictions can we make about the future of these three programming 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 unavailability of professional programmers with expertise in these languages. I am sure that by attracting some young minds to work in these programming languages, their eventual day of demise can be prolonged for a long time.