Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!mit-eddie!bu-cs!halleys!frog!john From: john@frog.UUCP Newsgroups: comp.lang.c Subject: Re: Portable C vs Efficient C or "Cost of Portability" Message-ID: <1316@frog.UUCP> Date: Tue, 14-Apr-87 14:46:00 EST Article-I.D.: frog.1316 Posted: Tue Apr 14 14:46:00 1987 Date-Received: Fri, 17-Apr-87 00:21:33 EST References: <213@pyuxe.UUCP> <636@edge.UUCP> Organization: Superfrog Heaven [ CRDS, Framingham MA ] Lines: 36 > If you are more concerned about efficiency than about portability, then > consider this: There are 4 basic reasons for writing a particular program > in C instead of in assembler: > a) If efficiency is of little consequence -- the program is only going to > be run once or twice; > b) If portability is important; > c) If the programmer is ignorant of assembler; or > d) If the boss wants "BIC lighter" programmers: cheap, disposable, and > easily replaceable. You forgot e) Reducing the opportunity for bugs by roughly a factor of 10. Most estimates of the average number of bugs in a program indicate that the number is roughly a constant fraction of the number of lines (which I believe is typically 10%), independant of language. A program written in C will typically be 1/10 the size of an equivalent assembly program (depending on the complexity of the C statements), so there are (roughly) 1/10 as many thoughts to mis-think -- in assembly, they may go wrong on a less grand scale, but they still are bugs. I believe there was an article in the most recent Comm. ACM about this general topic. My favorite quote, which didn't arise from this consideration, but does have the same philosophical bent: "Presumably it was essential to get the wrong answer as fast as possible." Kernighan & Plauger, The Elements of Programming Style. -- John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101 ...!decvax!frog!john, ...!mit-eddie!jfw, jfw%mit-ccc@MIT-XX.ARPA "Happiness is the planet Earth in your rear-view mirror." - Sam Hurt, in "Eyebeam, Therefore I Am"