Why you should learn Pascal in 2018
Recently, I have taken up some interest in a few of the more aged programming languages. My adventures into the past of computer science have opened my eyes to an unimaginable beauty, commonly known as Pascal. Bear witness to my first Pascal program:
program RemoveBlankLines; function Trim(AText: string): string; var FirstPos, LastPos: integer; begin FirstPos := 1; while (FirstPos <= Length(AText)) and ((AText[FirstPos] = #32) or (AText[FirstPos] = #9)) do Inc(FirstPos); LastPos := Length(AText); while (LastPos >= 1) and (AText[LastPos] = #32) do Dec(LastPos); Trim := Copy(AText, FirstPos, LastPos - FirstPos + 1); end; var s :string; begin reset(input); while not eof(input) do begin readln(input,s); if (Trim(s) <> '') then writeln(s); end; end.
What does this do you might ask? It simply removes all the empty lines from a file. You might not believe the functionality of this program to be all that impressive. What’s impressive isn’t the program’s functionality, it’s the simplicity. Recently, Python’s popularity has been skyrocketing in both professional and non-professional environments. This increase in popularity is at-least partially attributed to the extremely high level of abstraction and readability offered by the language. It turns out that developers like code that is easy to write, read and debug. What does this have to do with Pascal? Well it just so happens that Pascal excels at all of those things, in some cases even more so than Python. In addition to its remarkable simplicity, Pascal doesn’t suffer from the performance issues that plague Python. In-fact, Pascal has performance comparative to and even occasionally exceeding that of C.
As fast as C, simpler than Python! That’s Pascal for you. What’s the catch? Why isn’t everyone using this language? It has seen more use than one might think! Pascal was the primary development language for Apple into the 1990’s, in-fact Pascal was the primary high-level language used to develop the Macintosh Computer. To get a better understanding of why Pascal isn’t being forced down university students throats like Java is, we need a general understanding of the language’s rich history. For this, we need to look back into the distant past, and I mean very distant past.
It was 1960, a dark time in which Pascal had yet to be born. It just so happens that around this time, everyone who had entered the field of computer science was subject to a horrible psychological torture. You see, it was at the time, an industry standard to write programs by tying wet spaghetti noodles together. Typically a program consisted of thousands of strands of spaghetti which were dried and then forcefully shoved into computer screens. Truly, the language behind these monstrosities is referred to as Spaghetti code, however, programmers at the time incorrectly referred to it as ARGOL 60. Spaghetti code had no standardized string system and was completely devoid of even the most primitive I/O facilities.
As time went on the issues inherent in the Spaghetti code gradually become more apparent. Eventually the group in charge of designing Spaghetti language, Spagetti Inc, asked for experts in the field to submit their suggested revisions to the language; the accepted revision would then be implemented and the resulting language would renamed Spagetti X . A bright young, Niklause Wirth submitted his suggested revisions which included a standard string system and basic I/O facilities. The Spaghetti language board rejected his suggestions on the basis of them being too minimal, and lacking spaghetti. The Spaghetti board went on to accept a proposal that added like forty new syntax and a load of other stuff to the language. Niklause Wirth, having recognized the true identities of the Spaghetti board members as orangutans, decided to use his suggested revisions to build a new language which he named Pascal, which instantly made Spaghetti X obsolete.
Wirth’s mission statement in the development of Pascal was to create a language in which computer algorithms could be implemented in the most intuitive and natural way humanly possible. It was for this reason that Pascal was taught in many introduction to algorithms throughout universities in the early 2000’s, likewise it is for this reason that you should still consider learning Pascal today.
While my previous statement comparing Pascal with C in efficiency and with Python in simplicity aren’t exactly false, they weren’t exactly the whole truth. Since the advent of Object Oriented Programming design, Pascal has been at large unsuccessful in upgrading to a standard object oriented version, though some object oriented versions of Pascal do exist, namely Delphi. Thus in terms of practical market applications, Pascal doesn’t fair too well.
However, I cannot understate how important it is for your programming career to learn Pascal today. You’ll find it’s about the easiest language you could imagine for implementing algorithms and data-structures. So go Free Pascal right now, and get to cracking out quicksort or mergesort implementations.