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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c406e0c4a6eb74ed X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews2.google.com!not-for-mail From: kevin.cline@gmail.com (Kevin Cline) Newsgroups: comp.lang.ada Subject: Re: ADA Popularity Discussion Request Date: 3 Sep 2004 08:25:54 -0700 Organization: http://groups.google.com Message-ID: References: <49dc98cf.0408110556.18ae7df@posting.google.com> NNTP-Posting-Host: 198.23.26.253 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1094225154 25166 127.0.0.1 (3 Sep 2004 15:25:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 3 Sep 2004 15:25:54 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:3294 Date: 2004-09-03T08:25:54-07:00 List-Id: Georg Bauhaus wrote in message news:... > Kevin Cline wrote: > > : Perhaps more importantly, how to write programs without > : the array and the for-loop. > > I'd agree with you if this weren't about Ada arrays. > True, some programs with little to no support for "true" > arrays still show arrays where sets, maps, lists, etc. > should be, using that language. But then I always miss the > close connection of Ada's enumeration types and Ada's arrays, > and Ada's predefined operations of array types. > > Ada enums allow me to name things known at compile time. In addition, > Ada arrays made with an Ada enum as index type can be used like > a map. Due to the index type mechanism, completeness checks > are made at compile time. For example, an array aggregate > must be completely specified. A case distinction looking at > a value of an array's index must handle each case. > > Ada arrays can also be used like lists, with concatenation predefined, > and with a NIL (null range). Using any number of dimensions. > > They can be used with generic array algorithms, with built > in bounds checking and loop index optimizations. > They can also be used with STL like array algorithms when > there is a simple adapter that makes them look like a > container. > > Bounds can be determined and set at run time, like index > subtypes. > Arrays can be returned on the stack, allowing typical recursive > list processing subprograms. No for loops required. :-) No doubt that Ada has fabulous support for integer-indexed arrays. Still, in my experience what is most often wanted in applications is not an integer-indexed array, but a map or set. In 25 years of programming I have seen about 17,000 implementations of linear search and 5,000 implementations of sorted insertion, almost all of which could and should have been eliminated by using an associative container of some sort. I've seen large applications where over half the code was devoted to looping through arrays in one way or another. I've seen multiple instances where someone had written array-based code with O(n^3) run-time while vastly simpler map-based code would have run in O(n) time. By providing extensive facilities for array-based programming while ignoring all other data structures, Ada leads most programmers to do the wrong thing, and frustrates most of the remainder.