From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d89b08801f2aacae X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-30 08:03:29 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!sunqbc.risq.qc.ca!nf3.bellglobal.com!wn1feed!worldnet.att.net!135.173.83.54!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3CCEB246.9090009@worldnet.att.net> From: Jim Rogers User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Is strong typing worth the cost? References: <4519e058.0204290722.2189008@posting.google.com> <3CCE8523.6F2E721C@earthlink.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 30 Apr 2002 15:03:29 GMT NNTP-Posting-Host: 12.81.130.152 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1020179009 12.81.130.152 (Tue, 30 Apr 2002 15:03:29 GMT) NNTP-Posting-Date: Tue, 30 Apr 2002 15:03:29 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:23274 Date: 2002-04-30T15:03:29+00:00 List-Id: dmjones wrote: > Marc, > > > Why? Can you prove to me that the benefits will be greater > than the costs? > > Why am I asking for this evidence? I am working on a detailed > analysis of C that includes material on coding guidelines. > I have set myself the target of basis these guidelines on > empirical evidence. I am a fan of strong typing. However, > unless I can find any evidence to the contrary, the most I > can say at the moment is "some people think ...". > What costs are you seeing? Seriously, any software that reports itself as safe and correct must perform a significant amount of what the old COBOL programmers call data editing. It must verify that the data is correct in all phases of the program. Weakly typed languages such as C do not avoid this problem. C simply delegates all such responsibility to the application programmer. Ada, on the other hand, allows the application programmer to supply important information, such as the minimum and maximum values for a scalar type, and then lets the compiler generate the range checking. Range checking always requires someone to do the coding. Ada has put that burden on the compiler developer. C puts it on the application developer. For the application developer this makes coding in C more expensive than coding in Ada. C complicates the problem by its extensive use of implicit numeric convrsions. The C compiler is not allowed to object if you assign an int to a double. In all cases, such assignments are dangerous. C insists the danger does not exist because a double can always represent all values representable in an int. The problem is that you can be assigning an AppleCount to a WeightOfScrapIron. Strong typing can flag the danger of such assignments, forcing you as the programmer to review your program. Weak typing gives you no help. You are left with the need to carefully test all possible value combinations for your code, an impossible task for any non-trivial program. Jim Rogers