Object Pascal beats C++
Jim Phillips, Software Developer
A down to Earth comparison
between Object Pascal and C++
(for a more light-hearted comparison, check out Why Pascal is Better Than C)
This article is in response to the ever-prying question, "Why program in Pascal when most everyone programs in C?" It attempts to summarize the many reasons why choosing Object Pascal over C++ is a sound choice. It is not intended to represent all the reasons, nor does it pretend to represent every Pascal programmer's viewpoint. It also does not provide detailed information about each of the features illustrated (the assumption is made that the reader understands the features mentioned). It does, however, provide a good heads-up summary of the differences between the two languages illustrating why Pascal is the better choice.
As a matter of history, it should be noted that I have tried C++, and I found it wanting.
I found that I could use Object Pascal to create most of the things I missed from C++. These include:
I had to weigh the effort to do the above against the things I missed from Object Pascal:
Then there are the things that are just done more elegantly in Pascal:
Memory management is a nightmare in C++ because much of the allocation and deallocation is done automatically in C++'s libraries. These libraries are optimized for speed so that you can't step through them when you are trying to debug your inevitable memory problems.
I am convinced that C/C++ is a terrible foundation to build future programming languages. The argument about "dying languages" sounds like people going along with the herd rather than choosing a language or language direction based on genuine merit.
Consider the following statement from C. A. R. Hoare (case statement, quicksort fame) in "Great Papers in Computer Science", 1996. He wrote a preface in 1994 to his and Wirth's paper "An Axiomatic Definition of the Programming Language Pascal" to put that paper in context.
"One of my goals in the study of program proof techniques is to assist in the design of better programming languages, ones which make it easier to write correct programs and harder to write incorrect ones. ...
It is a matter of continuing regret that so few languages have ever been designed to meet that goal, or even to make significant concessions towards it. For example, the programming language C was designed to assist in writing a small single-user operating system (UNIX) for a real-time minicomputer (PDP 11), now thankfully obsolete. For this purpose, its low level of abstraction and plethora of machine-oriented features are entirely appropriate. For all other purposes, they are a nuisance. The successful propagation of the language can be explained by accidental, commercial, historical, and political factors; it is hardly due to any inherent quality as a tool for the reliable creation of sophisticated programs. ..." - C. A. R. Hoare, 1994.
Pascal will die only if programmers let it die. Cries for its death do not offer any justification for its demise other than inertia. Our goal should not be to adopt the "winner", but to use the best tool available. After all, that's why we use Macintosh.
-- Jim Phillips
All rights reserved