Why Pascal?

In real, we have long experiences with Pascal on our department. We have started with the Turbo Pascal 3.0 in the 1987. In this time, only few compilers had been available for the PC. This one was very fast and produced small and fast programs.

Main advantages of the Pascal:

Delphi

Delphi (we using for our courses) is a typical RAD system. Many form manipulation can be done using the Visual programming methods. For Borland is typical, that you can just execute Delphi and without any other action, you can translate and execute the prepared empty program. It does obviously nothing, only can be closed or maximized, but it works. If you add a button, you can just double-click on it and write a command. In distinction of most of common RAD, programs written in Delphi work. Our students can try to create usable calculator or something like Paint-brush, and with a few lines of code, it works (and even can be useful, for some special purposes).

Delphi provides full dll creating support, allowing to programmer to work with computer hardware, direct memory access or even create its own device drivers. This was the main reason, why (before about ten years) Delphi has been used by Visual Basic Programmers. Even inline assembler use is very easy, programmer can even use the Pascal variables in its assembler code.

The biggest advantage of the Delphi is the speed (the speed of translated programs is a heritage of the Turbo Pascal). For showing this, I have prepared the following example:

The following program will evaluate the factorials from one to seven, then make a sum of them. To measure time needed for this, it will repeat this action. Originally, I have a thousand of cycles here, but I had to change this number to ten million to get a measurable time. Note, that for system time use, the shortest period to measure is about one tenth of second (internal timer counts each 18 ms). Older computer with 800 MHz system clock has been used.

The code to be translated:

The result is (on the end of this program) written to form caption, it means to name of the form (window). The result has been caught graphically and you can found it on the end of this example.

After compilation and execution, the program has been stopped (see red line above) and the CPU window has been showed. Now, you can see the original Pascal code and its machine code translation. Note the "n:=n+k" translation; even if you yse the C language and a simpler solution like "n+=k", the compiler cannot create shorter or faster code - in the example (see CPU window), it is only one instruction. BTW, see, that many local variables do not exist at all, for example instead of "k", the eax CPU register is used:

CPU window displaying:

The CPU window itself - red line is now blue, because there is cursor on it:

Only calling of the system function is more complicated:

... but there is no better solution. The resume is, not to call a system (or API) function, if program should be fast.

And now, the resulting time - the 10 000 000 cycles take nearly two seconds:

Now, you can write it in your preferred language; when you have result, send it to me (with source code, processor speed and name and version of the language), I will present it here. BTW, this has been translated by Delphi 4. Newer version can be slower. My computer has 800 MHz Celeron CPU.


Notes.

In the older version of the Delphi, libraries and functions, translated by C++ or assembler (.obj, .lib), could be used in Delphi, but not backwards. From some version (I don't know exactly, which one), there is possible set the Delphi compiler to produce the .obj type output (instead of .dcu).

For professional programmers, the C language has another advantage - internet is full of solved programs you can use. But till now, I have found everything (I had need) in the Pascal as well. But in the C, there are usually more variants, often even better coded. So, for professionals, C++ is a better solution.

In some cases you cannot select a program language. For example, web application should be done in the php and Javascript (Javascript has nothing common with Java but name). In Excel, you have to use the Visual Basic. In this case, there is no discussion.


Don't forget the main advantage of C++ and Pascal in compare to Java and Visual Basics: If you are use a compiler, the result will be executable file, without any runtime needed. You can even create a program, which don't need to be installed before being used. For example with Java, there are many version of so called "runtime"; typical solution is to use the last one and ask the potential user to reinstall the runtime to the latest version. Unfortunately, if he has some older application in Java, it can become unstable in some special tasks, and this can be detected even few weeks later, in the least acceptable moment.

Few more comments:

"Pascal has been never used to create any application"
- I don't know, why it should be relevant (Pascal is as the first the best for teaching programming), but it has been probably mentioned by many peoples. The result is huge amount of web pages in the Google result, if you ask about "application written in Delphi". For me, the pages like StackOverflow, list on the wikia.com, info on the Delphi Insider or the article of Mr. Marco Cantu (or: Lazarus apps.) has been listed. From the Czech environment - an workplace advertisement: from the computer shop.

"Java is for free"
... and a Pascal was even sooner. When the Borland did not develop the 32bit version of the Pascal for DOS (they switched to Windows, by creating Delphi), the Free Pascal project has been established. It is not so fast as the Borland products, but computers are now very fast (and this is still faster then other competitors). For the Windows, there is Lazarus (it has the MS Windows, X Window (=Linux) and Mac OS version). The Lasarus is the complete substitution for the Delphi in the professional version, with the advantage of application portability among all of this environment (to convert application to Linux, you have to translate it there). Lazarus is free under the GNU GPL license.

"Delphi is just for MS Windows"
Only comment - except the Lazarus, there was original version of the Delphi for Linux, named Kylix. Now, this development is stopped, but there is for example Delphi for php, so you can debug your php application in the Delphi environment.

Recapitulation: The Pascal is intended for programming education and has many positive features for that. Many languages extracts features from the Pascal (or its Algol origin), for example C uses the Pascal-style cycles and conditions, the C# is even more influenced. The pseudocode, often used in a literature about algorithms, or on the Wikipedia, is most similar with the Pascal (then to C, Basic or Java).

The Delphi itself is powerful RAD environment as well. You can create very fast working application, which can be used far before being completed (without solving wrong data or user errors, for example), and continuously corrected. Many stupid bosses ask programmer to have a part of application the next week, so the RAD is a solution.

For people, who like to work as a programmer as the main job, the C++ (or C#) is probably better solution, because wide range of available libraries (parts of solution) on the internet. For people, who has different job, but need to create an application few times a year, the Delphi is a better solution.


From where comes this strange program appearance with blocks, cycles and declarations? The origin is the Algol. Algol has been proposed by mathematician, who tried to imagine, how algorithms can be described. In this time, all the other programming languages (Fortran, Cobol) has been created by programmers. Only the limited version of the Algol has been realized - the first has been the Algol 58, then Algol 60 (from the 1960, first widely implemented, even on small computer, as PDP 11). This version has been inspiration for Dr. Niklaus Wirth while creating Pascal.

Why the C ist named C? Its ancestor has been the B language. Ancestor of the B was not A, but Algol. So the C is the version of Algol, simplified to be easily implemented on small computers (easy to implement, not easier to use).