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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,103b407e8b68350b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-05 06:12:40 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsmi-us.news.garr.it!NewsITBone-GARR!news.mailgate.org!newsfeed.stueberl.de!fu-berlin.de!uni-berlin.de!dialin-145-254-036-036.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Anybody in US using ADA ? One silly idea.. Date: Sun, 05 Jan 2003 15:13:07 +0100 Organization: At home Message-ID: References: <3E147D79.2070703@cogeco.ca> <4519e058.0301031434.51a0c880@posting.google.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-036-036.arcor-ip.net (145.254.36.36) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1041775958 14060698 145.254.36.36 (16 [77047]) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:32570 Date: 2003-01-05T15:13:07+01:00 List-Id: Hillel Y. Sims wrote: > "Dmitry A. Kazakov" wrote in message > news:av6hla$cggao$1@ID-77047.news.dfncis.de... >> Kevin Cline wrote: >> >> > Today, the features that Ada provides have little value >> > compared with the features that C++ provides and Ada lacks: >> > the STL, automatic template function instantiation, >> >> Generics in any form is an illness of programming languages. > > As someone who uses C++ template functionality extensively, I find that a > very odd statement and completely inconsistent with my own experience. Can > you provide some rationale? In short generics is a meta language and no more than dressed macros used to patch the source code. More elaborated: 1. Generics are static. You cannot have an object or dynamic-link library of generics. 1.a. This kills code reuse at run-time. 1.b. You cannot have a true polymorphism with generics. [A fake, "static" polymorphism was invented to hide the truth.] 1.c. You have geometric code size explosion if you consequently use generics. 2. You have no ADT with generics. All generic types are hard-wired. In C++ you have only one generic type: "class". In Ada there are few: "private", "range <>" etc. This is Stone Age. Theoretically one could leverage generics to full ADT, but what for? It is much better to have a better ADT in the core language and abadon generics. 3. Generics are inconsistent with type relationships. When you instantiate something, this something is absolutely unrelated to everything else. A generic container instantiated with a subtype will never become a subtype of same container instantiated with the base type. 4. Generics are inconsistent with DbC. In C++ you just instantiate and pray. In Ada it is better, but still you have reemergence of predefined operations and other contract violations. The reason is clear, while the core language operates with types and their relations, generics are sort of: let's substitute one string for another and see if the result go through the compiler. I think it was Kernigan and Ritchie who said that preprocessor does not know C. Substitute generics for preprocessor and language X for C. 5. Generics are unstructured and too powerful. They are comparable with gotos. Gotos arbitrarely change control flow. Generics arbitrarely produce new language objects. You can have a generic type, subroutine, package, everything. The consequences of an instantiation is almost impossible to predict. As with gotos, you should admit, that a program with generics is very difficult to understand and maintain. [For C++ replace difficult to impossible, because of automated instantiation] 6. Generics completely fall out of the language, because in fact they form a meta-langauge. A generic object does not exist for the core language. What could be done with a generic object? The answer is: nothing. One cannot pass a generic function as a parameter to a normal function. Even a generic parameter cannot be generic (:-)), only instances [= objects of the core language] are allowed. So even as a meta-language, generics represent an inconsistent one. ------------------------ A little of bad philosophy as a conclusion. (:-)) If we consider the evolution of programming languages, we could note maybe unconscious, but constant and very successfull attempts to solve the problem of parametrization in a more civilized way than just by brute force of preprocessing = generics. A subroutine is parametrized by the values of the arguments [FORTRAN] A subroutine is a value which can be a parameter [?] A type is parametrized by the values of the discriminants [Ada 83] A type set (=class-wide type) is parametrized by a type (=type tag) [OOPL with dispatching] In the end of this process we will need generics as much as we need gotos now. -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de