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: fdb77,5f529c91be2ac930 X-Google-Attributes: gidfdb77,public X-Google-Thread: 103376,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,59ec73856b699922 X-Google-Attributes: gid1108a1,public X-Google-ArrivalTime: 2003-05-11 11:52:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!sccrnsc02.POSTED!not-for-mail Message-ID: <3EBE9BD4.1050008@attbi.com> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.java.advocacy,comp.object,comp.lang.ada Subject: Re: Using Ada for device drivers? (Was: the Ada mandate, and why it collapsed and died) References: <9fa75d42.0304230424.10612b1a@posting.google.com> <9fa75d42.0304240446.493ca906@posting.google.com> <3EA7E0E3.8020407@crs4.it> <9fa75d42.0304240950.45114a39@posting.google.com> <4a885870.0304291909.300765f@posting.google.com> <416273D61ACF7FEF.82C1D1AC17296926.FF0BFD4934A03813@lp.airnews.net> <9fa75d42.0305010621.55e99deb@posting.google.com> <0-WcnWfafqsNpiyjXTWcqw@gbronline.com> <1051804573.732603@master.nyc.kbcfp.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.62.164.137 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc02 1052679125 24.62.164.137 (Sun, 11 May 2003 18:52:05 GMT) NNTP-Posting-Date: Sun, 11 May 2003 18:52:05 GMT Organization: AT&T Broadband Date: Sun, 11 May 2003 18:52:05 GMT Xref: archiver1.google.com comp.lang.java.advocacy:63519 comp.object:63203 comp.lang.ada:37189 Date: 2003-05-11T18:52:05+00:00 List-Id: Wesley Groleau wrote: > >> I don't know where this notion arose that a "super-strong" >> type system is just for preventing bugs. I know that in C++ > > > I didn't say that it was only for preventing bugs. > I said it's a crock that it requires programmers > to do a lot of allegedly unnecessary workarounds. > > For me, preventing bugs is the second biggest benefit > of Ada's type system. The bigger one is that it > allows you to define things in terms of your > abstraction instead of your implementation. I think my first deep insight into the implications of Ada programming came in 1983, just after Ada 83 became an ANSI standard. I told someone working on our (Ada) compiler: "No, in Ada you model the problem space, not the solution space." I then excused myself for a minute to write it on my office whiteboard. The reasons this works so well are twofold. First it makes code much more understandable to the reader--and therefore logic bugs are much more obvious. But the second and more powerful reason is that requirements change. If your abstraction model is close to the "real" world problem space, then changing requirements have no effect on most of the code. My favorite example is a program I wrote in a few hours to demonstrate the "right" way to generate random permutations in Ada. The main loop of the program looks like: for I in 0..Number_of_Hands - 1 loop Text_IO.New_Page; -- Print header -- Put_Line calls to output Board number, Dealer and -- Vulnerability omitted. Shuffle(Deck, Gen); Deal; -- Print hands. -- More Put_Line calls with arguments like Cards(North, Spades) -- omitted. end loop; The type declarations are also very closely bound to the problem space, a deck of cards: type Suits is (Spades, Hearts, Diamonds, Clubs); type Ranks is (Ace, King, Queen, Jack, Ten, Nine, Eight, Seven, Six, Five, Four, Three, Deuce); ... type Card is record Suit: Suits; Rank: Ranks; end record; type Card_Array is array (Natural range <>) of Card; Deck: Card_Array(0..51); It is really, really hard to have bugs in code that is as unsubtle as that. And even if the universe changes, the changes are pretty localized. For example, it would take just a few minutes to change the code to deal Pinochle hands, or even to switch to a Tarot deck.