• Please review our updated Terms and Rules here

Pascal or C - from which to begin ?

Sandisk78

Experienced Member
Joined
Apr 2, 2016
Messages
111
Location
Moscow, Russia
Realised now that I want more than play games on classic computers. Thought to begin to learn Pascal- Turbo Pascal - 3.0 on very early machines - like CP/m Kaypro 10 and Turbo Pascal 7.0 on more advanced ones - dos machines, like 286/20mhz and 486. But friends, proffessionals who deal with computers and retrocomputers say, that Pascal is slow, and C is much better. If so for dos machines I have Turbo C 2.0 and what C is good for cp/m machines ?
 
Anyone who says C is better than Pascal is just plan uninformed, or flat out lying.

The only advantage C really has is that it's more popular, currently.
 
When I had programming at school we started off with Turbo Pascal 7.0 (it was back in 1997), then moved up to Delphi 2.0 and the next year we got to Cobol and C classes...
 
The only advantage C really has is that it's more popular, currently.

I would say that C has always been more popular, and as such, you can get a C compiler for virtually every platform out there. Getting a (good) Pascal environment is not an option on many platforms.
If I look at my own history, I've mainly seen Pascal as a popular option on DOS. On two other platforms I grew up with, C64 and Amiga, Pascal was not very popular at all. I've never even seen a Pascal compiler on Amiga. I've had exactly one Pascal environment on C64, but nobody seemed to use it.
On Amiga, C was quite common. On C64, well, there were some C compilers, I've used PowerC myself, which is quite impressive in its own right. But low-end platforms like that really want cross-compilers for serious work (or assembly of course).
It's still quite easy to get C cross-compilers for C64 and Amiga today, and I know various examples of people who are using them. Pascal? I don't think so.

As for performance... in terms of the compiled code, Pascal and C generally don't differ much. It mostly depends on how good the compiler is, and how well your code is written.
The main advantage that Turbo Pascal had at the time was that it compiled code on-the-fly while you were editing. This meant that 'compile' times were very short, so you could have a very effective workflow of changing a few lines, and running/debugging to see if it works. C on the other hand (even Borland's own Turbo C/C++) would only be compiled after you saved your file and hit the compile-button. Back in the day this could mean many seconds or even minutes of compiling, before you could test your code.
This was the main reason for Turbo Pascal's popularity in DOS, in the age of 8088-486.
Another reason for its popularity was the very seamless integration of inline assembly. A lot of 'Pascal' code from games/demos from the late 80s and early 90s is a lot of asm routines held together by a bit of Pascal-glue.

In the academic world, Pascal (and derivatives such as MODULA) was also quite popular since it was an easy and 'clean' language to teach students the basics of structured programming. Pascal eventually got replaced by Java for that same reason... An easy and 'clean' language, but Java embracing the object-oriented paradigm.
 
Last edited:
When i was at school we never had computer classes, I wish we had though, Been trying to teach myself C for the past few years on and off, Never tried Pascal.
 
Realised now that I want more than play games on classic computers. Thought to begin to learn Pascal- Turbo Pascal - 3.0 on very early machines - like CP/m Kaypro 10 and Turbo Pascal 7.0 on more advanced ones - dos machines, like 286/20mhz and 486. But friends, proffessionals who deal with computers and retrocomputers say, that Pascal is slow, and C is much better. If so for dos machines I have Turbo C 2.0 and what C is good for cp/m machines ?

Turbo Pascal is fine. It's perfect for programming on CP/M or other early systems, due to the fast edit/compile/run/debug turnaround. As for speed, it'll be in the same ballpark as (Turbo) C on the same platform. The "slow" Pascal variants would be interpreted or P-code versions (UCSD Pascal *is* slower). But Turbo Pascal isn't one of those.

My daily programming is done in C. Even so I recommend going for Turbo Pascal.
 
I would say that C has always been more popular, and as such, you can get a C compiler for virtually every platform out there. Getting a (good) Pascal environment is not an option on many platforms.
If I look at my own history, I've mainly seen Pascal as a popular option on DOS. On two other platforms I grew up with, C64 and Amiga, Pascal was not very popular at all. I've never even seen a Pascal compiler on Amiga. I've had exactly one Pascal environment on C64, but nobody seemed to use it.
On Amiga, C was quite common. On C64, well, there were some C compilers, I've used PowerC myself, which is quite impressive in its own right. But low-end platforms like that really want cross-compilers for serious work (or assembly of course).
It's still quite easy to get C cross-compilers for C64 and Amiga today, and I know various examples of people who are using them. Pascal? I don't think so.

HSPascal for Amiga is highly based upon Turbo Pascal. I found it to generate faster and smaller code. And at least one application I wrote in HSPascal ran circles round its C-coded equivalent (but I can't say that's due to Pascal over C, specifically).

I eventually switched to FPC for everything I did, and greatly regretted it. But I did successfully use FPC under 32 bit windows, and modern linux, a few years ago.
 
Yep - Pascal first.

One of my motto's is "a 'C' compiler warning is a run-time error waiting to happen"...

A lot of errors get caught by the Pascal compiler - leaving you to concentrate on 'your errors' rather than 'your misunderstanding of C' (and there are many in the latter category).

The logical extension after Pascal would be Modula-2. Surprisingly, I come across Modula-2 programs in my RealWorld job instead of 'C' - due to the safety critical nature of some of the software we use.

After Module-2 I started to become proficient in 'C' and that (and Java) are my 'goto' languages now (pardon the pun).

Turbo-C is pretty good to learn on as well - so don't dismiss it.

Code generation and speed is somewhat of a debatable subject. Pascal runs with a lot of run-time checks enabled by default. Try accessing outside the bounds of an array in 'C' and see what happens (usually mayhem or extremely difficult bugs to find). Try doing that in Pascal - and you get a run-time error. The run-time error is much better for 'learning' on. Sure, in Turbo Pascal (and others) you can disable the run-time checking to improve speed. But (if your are learning) please don't... I am sure you can enable run-time checking on some C compilers - but I think most of them are disabled by default.

Incidentally, some of the best code generation I saw was on a DEC VAX/VMS Ada compiler...

Dave
 
I would say that C has always been more popular, and as such, you can get a C compiler for virtually every platform out there. Getting a (good) Pascal environment is not an option on many platforms.
Yeah, there's so little cross platform support for Pascal these days...
"Free Pascal is a 32, 64 and 16 bit professional Pascal compiler. It can target many processor architectures: Intel x86 (including 8086), AMD64/x86-64, PowerPC, PowerPC64, SPARC, ARM, AArch64, MIPS and the JVM. Supported operating systems include Linux, FreeBSD, Haiku, Mac OS X/iOS/iPhoneSimulator/Darwin, DOS (16 and 32 bit), Win32, Win64, WinCE, OS/2, MorphOS, Nintendo GBA, Nintendo DS, Nintendo Wii, Android, AIX and AROS. Additionally, support for the Motorola 68k architecture is available in the development versions. " - first paragraph on freepascal.org

The main advantage that Turbo Pascal had at the time was that it compiled code on-the-fly while you were editing. This meant that 'compile' times were very short, so
Um... NO. Turbo Pascal (or Delphi or FPC) has not ever compiled code "on the fly". Ever.

g.
 
Right. What TP does is compile to memory, in a single pass.

I've never studied C compiler theory; can it compile in a single pass?
 
Um... NO. Turbo Pascal (or Delphi or FPC) has not ever compiled code "on the fly". Ever.

Well, pretty sure there's some tight ties between the editor and the compiler.
When the compiler crashes, you usually end up with zero-length source files. So if the compiler crashes, it apparently takes out the editor with it.
It almost definitely shares the memory between editor and compiler, and I bet the editor also does some of the preprocessing (tokenize keywords, keep track of line-ends etc).
I say that because it seems that compiling from the IDE is faster than using the commandline.

C is designed in a way to allow single-pass compilation as well (which is why you have to make forward declarations to functions and variables). C++ drops this requirement.
 
Last edited:
Right. What TP does is compile to memory, in a single pass.

Well that depends. Turbo Pascal/Delphi/FPC ARE single pass compilers, but only early versions of Turbo Pascal (v5 and prior?) would allow you to compile to memory or to disk, depending on a configuration option. After v6 came out, "compile to memory" (AFAIR) was no longer an option.

g.
 
In theory, yes--as long as declarations (or prototypes) precede use. Many compilers as a "pass and a half" affair--the code skeleton is generated during the first pass, with back-references patched during the half-pass without actually passing through the source a second time.
 
Well, pretty sure there's some tight ties between the editor and the compiler.
When the compiler crashes, you usually end up with zero-length source files. So if the compiler crashes, it apparently takes out the editor with it.
It almost definitely shares the memory between editor and compiler, and I bet the editor also does some of the preprocessing (tokenize keywords, keep track of line-ends etc).

In my experience, in the rare occasions that Turbo Pascal crashed, it never once zero-byted the source code file - unless of course you never saved the file to begin with and had save-before-compiled turned off (and in that case you'd have no source file at all...). Yes, the IDE encapsulates both the editor and the compiler[*], but the editor doesn't do any pre-processing at all. It never has. The same holds true of Delphi and FPC/Lazarus.

* - up to a certain version, the IDE & compiler were basically in the same executable. Right around Turbo Pascal 7 hit the streets, a command line compiler was shipped along with the IDE. I don't know if the IDE and compiler were split at this point, but I suspect not - at least not until Delphi 7 or later. Lazarus (Basically Delphi for FPC) has always been an IDE sans-compiler and leveraged the FPC compiler tool chain for code generation. Again, no pre-processing by the editor ever happened.

g.
 
It's a tough question. Pascal is interesting, but can be awkward at times. C started off as basically a high-level assembly language and has evolved with time. C is the language of Unix and its successors. Neither is object-oriented.

I view Pascal as an initial stab at a language--Module-2 and Oberon are perhaps closer to a refined work. If you're talking about pre-8086 microprocessors, neither C nor Pascal is well-supported by the architecture. FORTRAN, however, works very well.

Really, it doesn't matter. Learn to program well in any language and adding a new one to your vocabulary is much easier. There are exceptions, but they're not common. Prolog, LISP, Simscript and other languages are quite different with regards to their basis.
 
Anyone who says C is better than Pascal is just plan uninformed, or flat out lying.

The only advantage C really has is that it's more popular, currently.

Anybody who makes such generic statements like this is just plain uninformed, or flat out lying.


I'd go with C over Pascal. You can do anything in any programming language; I've seen object oriented behavior in COBOL. But C generally aligns much better with the underlying hardware and the design philosophy of Unix and C has permeated all modern operating systems.
 
Sure--and look for all of those Pascal compilers for modern ARM MCUs... :)

I know of two--mikroPascal (pay to play) and freePascal (not quite ready for primetime). There may be others, but C dominates that market.
 
In my experience, in the rare occasions that Turbo Pascal crashed, it never once zero-byted the source code file - unless of course you never saved the file to begin with and had save-before-compiled turned off (and in that case you'd have no source file at all...).

I haven't used Turbo Pascal much. I mainly had it with Delphi (I think at the time it was version 5 or so).
And yes, the save-before-compile function was disabled by default. Of course it has to happen 3 or 4 times before you decide to find that function and turn it on (coming from Visual C++, I couldn't understand why this was even an option at all. Of course you save your files to disk before you compile, and ESPECIALLY enter the debugger).
It doesn't just happen if you never saved the file, that's the worst part.
It happened when you had some edits in a file, then compiled it, ran it in the debugger, and Delphi farted.
 
Oh, those good old times of Pascal vs. C jihad...
https://www.lysator.liu.se/c/bwk-on-pascal.html

Anyway, my favorite programming tool for vintage PCs is Turbo Pascal/Borland Pascal.
Versions up to 5.5 run fine even on an 8088, for 6.0 I recommend a 286, for 7.0 - a 386.
Yes, fast compilation is a big plus, I suspect thanks to TPU format superiority over H/OBJ/LIB.
Also, TP is great for PC/DOS-centric low level stuff: mem[] and port[] arrays, "absolute" keyword, and such stuff.
And there's plenty of sample programs for early PCs written in TP - search for "Sourceware Archive Group (SWAG)", and back in the days there was plenty of books and magazines about PC/DOS programming with TP.

Yes, if you want to go beyond PC/DOS - especially into the Unix/Linux world - then the first choice is C, as it's more common, more standardized, more portable.

Note that Turbo Pascal is not quite Pascal, TP has many extensions and other differences compared to standard Pascal.
For many years, I used to experience countless problems with porting my TP code to various Pascal implementations running on Unix/Linux.
Finally, there came FPC, which emphasized on TP-compatibility, and pretty much solved such problems.
And the legendary Virtual Pascal, also meant as a TP-clone for 32-bit platforms: first OS/2, later Win32 as well.
 
Back
Top