C++ v. Pascal

The database program FileMaker Pro was recently rewritten “from the ground up”; FMPro prior to version 5 was written in Pascal; version 5 is in C++.

Question: I know there are “external” reasons for the rewrite, such as the greater ease of locating folks who can work as programmers for FileMaker Inc., and “accidental” performance reasons (with C++ being the leading programming tool, there are no doubt far better compilers available, resulting in tighter / faster / etc. compiled programs), but is there a distinct advantage of C++ that would ** intrinsically ** make the resultant program faster than one written in Pascal? Is is somehow “closer to machine language” or otherwise more capable of being compiled in an efficient manner?

Please answer in terms that will not require that I be a programmer in either Pascal or C++ in order to comprehend :slight_smile:


Designated Optional Signature at Bottom of Post

C++ is a far more flexible language than pascal. In particular, C (++ or vanilla) pointer structures allow data to be manipulated with much more control than Pascal which CAN lead to tighter code and faster run times. It can also lead to problems.
C++ is also object riented, which can make development and maintenance of code easier, thereby decreasing development overhead. Of course, object-oriented code can also bloat to truly inreasonable levels result in a final product that is far less efficient.

Am I showing my age?? Straight C rocks!! Wrap your GUI in an object and stick it where the code don’t shine.


The best lack all conviction
The worst are full of passionate intensity

Wow, where to start…

C & C++ have taken the advantage for many reasons. [ul][li]Perl & Java are close C-ist languages that are used greatly in Internet applications[/li][li]Weak type checking[/li][li]C’s original simplicity make it as close to machine language as possible. This simplified using registers (built-in storage cells in the main processor) for C variables, greatly increasing speed.[/li][li]Programmers finally got to use those cool-looking squiggly braces: “{}”[/ul][/li]I personnaly still like Pascal, even though my DOS-based editor/compiler can’t run on a Win 95/98/NT without rebooting the computer in MS-DOS-only mode. I liked the strong type-checking, set notation and operations, and the fact it was the first language I learned (aside from BASIC, which is so variant between machines and compilers that its tough to call them the same language without laughing).

Also, Pascal’s named for a great mathematician. C was just named by somebody who knew the first 3 letters of the alphabet. (But not the fourth; that’s why there’s C++ and not D.)

&lt joke &gt
I thought it was called C because that was the best grade you could hope to get with it as a design in compiler class.
&lt /joke &gt

Delphi, the deveopment system from Borland, uses Pascal as its development language so Pascal isn’t dead yet.


“Drink your coffee! Remember, there are people sleeping in China.”

Dennis Matheson — dennis@mountaindiver.com
Hike, Dive, Ski, Climb — www.mountaindiver.com

The basic reason is that every system has a good C/C++ compiler nowadays, but Pascal compilers are proprietary, incompatible (standard Pascal is a simple student language – serious professional work needs tons of stuff added to it) and usually technically way behind the times, because C/C++ is where the action is. Delphi is OK, but is available only from Borland (or whoever it is nowadays) and only on those systems Borland wishes to support.

And most ancillary tools, like SQL preprocessors, are available only for C/C++.


John W. Kennedy
“Compact is becoming contract; man only earns and pays.”
– Charles Williams

See: Why Pascal is Not My Favorite Programming Language by Brian W. Kernighan.

Of course he’s biased, but he makes some very good points: no separate compilation, array size is part of it’s type, no static variables or initialization, logical expression evaluation order is undefined, no default clause in ‘case’, etc.

Several of the above posts have alluded to this (particularly John’s), but to put it bluntly:

C was originally designed for people doing practical work. Built into it from the ground up is the notion of “it doesn’t have to be pretty if it gets the job done in the most efficient way.”

Pascal was originally designed to teach people how to program the way Wirth thought they should. Built into it from the ground up is the notion “it doesn’t have to be able to really DO anything significant as long as it enforces the rules.” IIRC, Wirth was not entirely pleased when people began actually using Pascal variants for application development; that had never been his intent for the language.

Most Pascal implementations are less rigid than the standard. For example, I used to use Borland’s Turbo Pascal, and am of the opinion that it could reasonably be regarded as a completely different language which happens to have a lot of syntax in common with Standard Pascal.

Apparently the teaching aspect of Pascal is going out of style. Last year, the introductory style here at Texas was Pascal. This year it Java, which, IMHO, is much more useful because Pascal is just a pain to use IRL. Hey, what’s that odd looking island down there? Hope everyone’s wearing their red stars today.


“There are many sweeping generalizations that are always true” -Space Ghost

My take on it is that when they had to do a rewrite (which you occasionally want to do so your code doesn’t get too hairy), they discovered the rest of the world has switched to C++.

The reasons have been explained above that C(++) lets you program much closer to the machine than pascal does, but I think the most important reason is that C++ is far more maintainable.

The typical maintenance routine is to write new code which calls (uses) old code, which will work around your problem. With C++, you can do the neat trick of having old existing code call your new code. This makes maintenance and adding features much nicer.

C++ was designed from the beginning to deal with large scale programs (though it could have really used a module system), while Pascal, as stated, was designed as a teaching language.

I was reading the link about the reasons why PASCAL shouldn’t be used and many of the points brought up are dealt with in many of the compilers available. Although the different compilers create a large problem for recompiling Turbo Pascal at least gives you the option to create an exe file which would allow the program to run virtually anywhere. Also most recently I was using Borland Turbo Pascal 7.0 (I loved it) and i supports an Object Oriented version of Pascal. Now I’m at college and I need to use Java, which in my opinion is the crappiest language ever invented! I can’t step run my files to find errors as they happen! But that can be discussed someplace else…

AWB said:

Actually, C++ has mostly strong typechecking, because people realized that weak typechecking was just a giant pain in the ass, and lead to really hard to find bugs. Not only that, but with run-time type information you can see not only what type you say something is, but what type it really is.

[/quote]

I’m pretty sure registers were used for pascal variables as well. Also C++ does its best to hide machine details like register assignment and memory layout from the programmer. With modern compilers doing a better job at optimizing than most programmers can, it doesn’t make sense now to program so close to the machine level, except in limited areas.

Of course, it still has pointer arithmetic and some bit operations that pascal didn’t, which can significantly speed up programs. IMHO, those make programs a pain in the ass to read, and I only use 'em in very time-critical operations.

Yup. Also the comment markers are way cooler in C and C++. /* */ and //.

Speaking of C++, has anyone use the object-oriented version of COBOL?

It’s called “ADD ONE TO COBOL”.

ba-da-bing!


La franchise ne consiste pas à dire tout ce que l’on pense, mais à penser tout ce que l’on dit.
H. de Livry

Al Stevens sums it up pretty well:

COBOL was made so managers could read code.
BASIC is for people who are not programmers.
FORTRAN is for scientists.
ADA comes from a committee.
PILOT is for teachers.
PASCAL is for students.
LOGO is for children.
APL is for martians.
FORTH, LISP, and PROLOG are for academics.

But C… C is for programmers.


peas on earth

Geesh, I kinda liked Pascal when I learned it in the way way long ago. Course, back then what I learned was called Algol-W and I have no idea why it was nearly identical to Pascal syntax when I looked into programming in later years… I gave up trying to keep up with computers long ago, and just assume they are magic. :slight_smile:

AWB sez

[UselessTrivia]
C evolved from B which evolved (or was created :wink: ) from BCPL which I think stands for Binary Control Pointer Language
[/UselessTrivia]

Oblio

What about Eiffel? RIT used it for their first year computer science students until this year. Now we use Java.

I’ve always found that Pascal had better debuggers and compilers. It seems like C compilers don’t exactly want to show me where my errors are, they merely like to point me in the right direction.

Besides, Pascal code sure looks alot neater than C code. C looks primitive. When I was doing my college C classes I always used to put the comment
// C : monkey :: Pascal : man
in my program headers… heh heh, nerd humor.

I can’t believe I didn’t see anyone standing up for poor old Pascal in this thread! But honestly, C is certainly the choice for multi-platform development, plus C has DJGPP going for it. {<-- damn I didn’t want to say anything nice about C, remember to change this later}

One of the things I always liked about C was its terse grammar. After a few years of experience, you can read nicely formatted ‘C’ code almost like english. Pascal is easier to read for novices, but harder to read for experienced programmers.

With modern, optimizing compilers there’s not really much difference between most programming languages in terms of speed and efficiency. A lot of application programming just involves linking together DLL’s, generating SQL queries, and whatnot. Even Java can be acceptably fast, and it’s an interpreted language. Visual Basic has become a standard for rapid development of client/server applications, even though C++ is much faster, because the VB code is just a shell around high-performance C or assembler code that does all the work.

In terms of programming ease, I actually like Java quite a bit because of things like automatic garbage collection. It’s also nice to not have to worry about debugging wild pointers. I’ve done enough of that to last me a couple of lifetimes.

There was a language in the 60’s called Combined Programming Language (CPL).

Someone did a simplified version called Basic Combined Programming Langauge (BCPL).

Someone else did an even simpler language and named it “B”, because it was only about 1/4 of BCPL.

C was a more advanced language inspired by B.

C++ is a more advanced language based on (not the same thing as “inspired by”) C.

As to the other poster, you have completely confused language and implementation. There are Java environments that can do the same thing that Turbo Pascal can do; you just don’t happen to be using one. And the Java language contains much more than Turbo Pascal (threads, system-independent windowing, general containers, sized arrays, garbage collection). And Turbo Pascal certainly cannot run “almost anywhere”; it runs on MS-DOS and its derivatives. Period.


John W. Kennedy
“Compact is becoming contract; man only earns and pays.”
– Charles Williams

JWK -
You are correct on the BCPL->B->C evolution, I stand guilty of dereferencing a garbage pointer. Thanks for clearing that up, now I’m off to find where I read that geek UL I regurgitated.

::mumbling ‘I know I read that somewhere …’ grumblegrumble::

Oblio