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,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,59ec73856b699922 X-Google-Attributes: gid1108a1,public X-Google-Thread: fdb77,5f529c91be2ac930 X-Google-Attributes: gidfdb77,public X-Google-ArrivalTime: 2003-05-11 14:17:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.airnews.net!cabal12.airnews.net!usenet From: "John R. Strohm" 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) Date: Sun, 11 May 2003 16:07:44 -0500 Organization: Airnews.net! at Internet America Message-ID: References: <9fa75d42.0304230424.10612b1a@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> <3EBE9BD4.1050008@attbi.com> Xref: archiver1.google.com comp.lang.java.advocacy:63529 comp.object:63209 comp.lang.ada:37198 Date: 2003-05-11T16:07:44-05:00 List-Id: X-A-Notice: References line has been trimed due to 512 byte limitation Abuse-Reports-To: abuse at airmail.net to report improper postings NNTP-Proxy-Relay: library2.airnews.net NNTP-Posting-Time: Sun, 11 May 2003 16:15:20 -0500 (CDT) NNTP-Posting-Host: ![-nV1k-WWi2kke (Encoded at Airnews!) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 "Robert I. Eachus" wrote in message news:3EBE9BD4.1050008@attbi.com... > 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 There is ABSOLUTELY NO EXCUSE in Ada for the above. Human beings learn to count starting at "one", not "zero". for I in 1..Number_of_Hands 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); Same comment. Deck: Card_Array(1..52); > 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. Actually, with a Tarot deck, it would be a bit harder. You have the four different suits, and the various numbered cards, but you also have the various special cards (e.g., the Fool, the Tower, Death...) that have to be handled separately.