[comp.sys.ibm.pc] Buying C for PC

gavin@mit-caf.MIT.EDU (Gavin C. H. Zau) (10/10/89)

	I am looking for a C compiler for the IBM PC type computer 
that will be most compatible with the C on my MIPS M120.  Is there
any advantage /disadvantage of the 2 most popular C compilers for the
PC: Turbo and MSC?  [other people uses Turbo pascal here so
compatibility with data from these program might be a great advantage.]
Thanks

-- 
************************************************************
Gavin Zau	Dept of Chemical Engineering, MIT
		gavin@caf.mit.edu	mefl@eagle.mit.edu

mkelly@blackbird.afit.af.mil (Michael P. Kelly) (10/14/89)

gavin@mit-caf.MIT.EDU (Gavin C. H. Zau) writes:


>	I am looking for a C compiler for the IBM PC type computer 
>that will be most compatible with the C on my MIPS M120.  Is there
>any advantage /disadvantage of the 2 most popular C compilers for the
>PC: Turbo and MSC?  [other people uses Turbo pascal here so
>compatibility with data from these program might be a great advantage.]
>Thanks

	Recent issues of Doctor Dobb's Journal and Computer Language have
reviewed both compilers at length.  The conclusion is that they are very
much the same in features, environment, speed, code size and various other
aspects.  The differences are minimal and it is more a matter of personal
taste as to which you choose.  I own both, but continue to use Turbo C v2.0
because I prefer it over Quick C.  MSC 5.1 costs a couple of hundred and
unless you are a serious developer, I do not suggest that you purchase it.
Quick C w/Assembler though looks good, but I have not seen any reviews yet.
	As for compatibility with your C on MIPS M120, which I admit I am
not very familiar with, do not expect to much.  C's big claim is portability 
across various platforms (notice all the buzzwords!) yet this is just a myth!
If you write a text editor on your PC (I use my own example) and take 
advantage of any extensions to ANSI C, such as using specific interrupt calls,
graphics, sound, any hardware dependent operations (bit manipulation and
port reading/writing, etc.), you will NOT be able to simply upload it to
a mainframe (or any other computer), make a few changes and get it to run
like it did on your PC (or initial development computer).  Good programs on
PC's always take advantage of those system specific routines.  Nearly all
programs do.  Why have those capabilities if you do not write programs to
take advantage of them?  
	Uploading it to my UNIX machine was simple but compiling it was not.
I knew beforehand that there would be many adjustments that would have to be
made, so it was no shock.  Most C compilers on mainframes support the classic
parameters:
		int swap(x,y)
		int x;
		int y;
		{
			...
		}
While PC compilers support either classical or ANSI:

		int swap(int x, int y)
		{	
			...
		}

Adjustments such as that are more cosmetic and require simply tedious adjust-
ments with a text editor (i.e. vi).  Of course, you could just adopt the
classical approach from the start on your PC since Quick/Turbo C support
either.  Now all those direct screen writes, cursor movements, lite-bar and
pop-up menu and window routines are set right!  Portability right!  Wrong!
If you want to move the cursor and write text anywhere on the screen, you
must use a third-party library such as Curses (UNIX platform) or directly
examine the termcap database of screen control codes for the various monitors
or terminals that your users may be using.  You thought the PC was bad when
it came to the number of monitors.  Lite-bar menus may be out of the question
when it comes to many mainframe terminals since many do not support reverse
video (newer terminals support much more).  
	It comes down to this:  If you are writing a simple I/O program that
does not take advantage of any hardware specific operations on you PC, you
will probably have no problem in compatibility (portability).  But the 
second you start using anything but the 32 ANSI keywords and the C standard
library you lose portability.  The more you use, the more portability you lose.
Few things irk me more than reading some computer columnist or journalist
write about how great C portability is!  Does this mean C is a bad language,
of course not!!!  No langauge is 100% portable because what makes a program,
especially the user interface, good is it was written taking advantage of
the hardware underneath it.  And this differs from platform to platform and
hence eliminates the portability aspect.
	Purchase either C because they are both excellent compilers, but
unless you are writing simple WC (word count, for example) programs, forget
about complete portability!  Good luck.



>-- 
>************************************************************
>Gavin Zau	Dept of Chemical Engineering, MIT
>		gavin@caf.mit.edu	mefl@eagle.mit.edu