Toy compilers (was Re: gotos)
Every system needs one
terry at wsccs.UUCP
Tue May 17 13:35:51 AEST 1988
In article <1080 at maynard.BSW.COM>, Larry Campbell writes:
| In article <504 at wsccs.UUCP> I wrote:
| <> ... I happen to write code that uses
| <>
| <> for( ;;) {
| <> }
| <>
| <>instead of
| <>
| <> while( 1) {
| <> }
| <>
| <>too, as I need the best speed out of the hardware I can get and the 'for'
| <>avoids a test instruction being generated. Certainly, the 'while' is better
| <>at self-documenting, but it isn't the right tool for the job.
|
| For someone who believes in using the right tool for the job, you seem
| to have chosen a pathetically lame compiler. The compiler should generate
| the same code in both cases, since (1) is obviously a compile-time
| constant expression.
Not all compilers do, however.
| It's penny-wise and pound-foolish to buy a toy compiler, and then feel
| compelled to write code like the above. In the long run, the
| maintenance and support costs you incur will vastly overshadow the few
| hundred dollars you might have saved by skimping on the compiler.
You are neglecting the fact that "for(;;)" takes less code in "portable to
lame compilers" fashion. When a lame compiler is all you have, better to
write code that works on lame and un-lame (healed?) compilers alike.
You also neglect the fact that the majority of software companies that have
the same software on a *lot* of machines (we have code that runs on over
140 with only minor #ifdefs, usually relating to SysV vs. Berklix vs. VMS,
etc.) doesn't necessarily own either the machines or the compilers. In
addition, priveledges on porting machines are usually limited, so installing
then removing a compiler is out of the question. Time, also, is generally
limited to several hours, and if you can't port your 65000 lines of code
relatively quickly (say 40 minutes at most), you won't have enought time
to master a tape or remove your code. Note that this totally neglects the
need to make tapes within that time frame if you are porting to something
like a Northern Telecom system which can only read Northern Telecom tapes
while purporting to be QIC-24 compatible.
Generally, it is better to be portable to many compilers rather than having
to buy many machines or have them sent to you, let alone the expense of
having to buy a compiler that will compile your code because you're not
portable to the compiler that comes with the machine and is supported by
the manufacturer.
| Terry Lambert UUCP: ...{ decvax, ihnp4 } ...utah-cs!century!terry |
| @ Century Software OR: ...utah-cs!uplherc!sp7040!obie!wsccs!terry |
| SLC, Utah |
| These opinions are not my companies, but if you find them |
| useful, send a $20.00 donation to Brisbane Australia... |
| 'Admit it! You're just harrasing me because of the quote in my signature!' |
More information about the Comp.lang.c
mailing list