C++ v. Pascal

I’ve had this debate with a lot of other programmers over the years and it seems to me to be one of those po-TAY-to, po-TAH-to kind of things. IMHO it really depends on where you started. I learned Pascal a long time before I learned C so I really like strong typing, “BEGIN” and “END”, etc. I have preferences (now I’m a Java kinda guy) but I’ve used a lot of computer languages and they’re all pretty much alike.

I think at least part of the reason that Pascal has faded while C (well, C++) has survived is that C has always been closely associated with the UNIX operating system. This gave C a large user base and kept the various extensions and additions under some degree of control, so everyone was using essentially the same language. That was never true with Pascal. Too many variants and none that rose to the top – although Turbo Pascal probably came the closest.

As has been suggested in previous posts, when these poor guys decided to rewrite they probably couldn’t find a decent Pascal compiler. They may have preferred Pascal but it’s become a VHS vs. Beta thing – even if Beta is better you have to use what everyone else is using. Even then you probably wouldn’t get much improvement in a straight Pascal to C conversion, but C++'s object-oriented capabilities would make a real difference.

For those who didn’t know – The name UNIX is derived from the Multics operating system. UNIX was intended to be smaller, cheaper, faster by cutting Multics down to size. In a sort of double pun, UNIX was described as “castrated Multics”.

If man was meant to fly faster than the speed of sound he would have been born with 5000 pounds of thrust.

A big difference for C was performance. It wasn’t that long ago that the speed difference between compiled C code and just about anything else was important, and showed itself in even trivial operations like scrolling documents and opening files. Now, that’s not so much the case. Computers are so fast that your average business apps can be written in just about anything. Plus, programs have gotten much more complex, so things like ease of debugging and maintanence start to become more important. Also, compilers have gotten better and better, so the gaps between languages is smaller.

Another thread rescue from the pruning-room floor.

::bump::

I actually wrote a few programs in B one summer. No, I don’t remember a damn thing about the language.

As mentioned before, many of Kernighan’s allegations aren’t true today (at least in Delphi/Object Pascal):
[ul]
[li]The size of an array is part of its type - yes, but you can use open array parameters (functions that take an array of unknown size) and resizable arrays. His example involves strings, but a built-in resizable string type has been available for quite a while.[/li][li]There are no static variables and no initialization - I believe local typed constants in Delphi work as static variables, and global variables can be initialized.[/li][li]Related program components must be kept separate - He derides forward declarations (function prototypes), but modern C++ code uses them as well. Declaration blocks can appear in any order.[/li][li]There is no separate compilation - In fact, modern Pascal libraries and apps make heavy use of separate compilation (units and the ‘uses’ clause). Headers and code are combined into a single file (the ‘interface’ and ‘implementation’ parts).[/li][li]Some miscellaneous problems of type and scope - His first example can be done with open arrays (var a: array of integer), his second works fine with Delphi (and will be compiled like a ‘case’ statement).[/li][li]There is no escape - Type casting can be done quite easily: Integer(y), TMethod(x.OnClick), etc. In some cases it’s more convenient… if P is an untyped pointer, you can use TSomeType(P^) instead of defining a pointer type and using PSomeType§^.[/li][li]Control Flow - Delphi does support short-circuit evaluation (and guaranteed order thereof) as an extension. Break, continue, return (exit), named labels, and ‘else’ parts of ‘case’ statements are all available.[/li][li]Cosmetic Issues - Delphi offers a Result variable which can be used for function return values (and can be read without recursively invoking the function). Bitwise and/or/xor/shl/shr are all available. ‘’ (quote marks with nothing inside) is a null string. Non-printable characters can be embedded in strings: ‘first line’#13#10’second line’. Delphi does allow constant expressions in declarations.[/li][/ul]

Of his summary of points, not a single one holds true today, at least in Borland’s products. While this may not apply to FileMaker (or does Borland have a Mac compiler?), Pascal is still a contender for Windows and Linux.

C++ is one of the worst languages from a Computer Science perspective. Very erratic structure, and many quirks that cause errors. One of the most notorious is starting arrays at 0 instead of one. This single thing has probably caused more errors than anything else. If you read a lot of code you will constantly see loops from 0 to 512, etc. instead of 1 to 512, or 0 to 511. The result is the out of boud condition occuring when the buffer is exactly full. This state usually happens the day after release of the product.

http://www.edfac.usyd.edu.au/staff/souters/Humour/Real.Programmer.Stories.html

“Real programmers can write FORTRAN programs in any language”

LordVor