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-Thread: 103376,243dc2fb696a49cd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) Date: Mon, 11 Oct 2004 10:08:57 +0200 Message-ID: <1b8ku4fw7i3hu.mh6hbapsz59f$.dlg@40tude.net> References: <41547dae$0$91007$39cecf19@news.twtelecom.net> <1g2d9xmnita9f.5ecju0eftkqw$.dlg@40tude.net> <87u4rkhddelw$.1uuoqhfyd2eay$.dlg@40tude.net> <6zobtdp3ckqx.plmvz5og15id.dlg@40tude.net> <2n0j0jfe6sex.2bcfi09ss44w$.dlg@40tude.net> <1xc5ofa4jkd2x.ejgxx5gcwy4l$.dlg@40tude.net> <63z609r5z0h9.180f2ao5xdqg9$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de IdrNjw6q3+Wo0oMfGheg+gMt7Spr9YmsgMwf8Z3aB2kCzalwE= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:5029 Date: 2004-10-11T10:08:57+02:00 List-Id: On Sun, 10 Oct 2004 23:09:24 +0200, Robert Kawulak wrote: >> Yes. For *you*, it is not a fiction, because you know its semantics. The >> problem is how you communicate your personal percept of semantics to other >> people. It is what a language all about... > > Similarily, I could say that Ada has no classes. Of course it has > packages, tagged records etc. but no true classes with true methods. Classes > in Ada are just as fictious as interfaces in C++ template metalanguage, yet > it doesn't mean you can't use OOP in Ada (and interfaces for templates in > C++). Yes, Ada does not have OO-ish classes. Whatever is usually meant under OO "class" is either rubbish or just another name for type. Ada's classes (T'Class) are type closures. >> Templates constitute a meta-language. That is >> inherently bad, provided there is a way to solve the problem within the >> native language (maintaining a reasonable level of expressiveness). > > I'm afraid that our discussion will never reach its conclusion ;-) The > reason is our opposite approach to templates and using them to implement > containers. Of course everything that is done using templates may be as well > done without them (although not always so easily). The point is that in many > cases they simplify the design and, what is crucial for C++, they provide > containers with efficiency. There is a broader picture. Consider parametrization in general, as a tool for generic programming. The generic algorithms are represented as operations defined on the sets of types. Sets of types are obtained by varying the parameter or parameters. In this view C++ templates where the parameter is a string containing either name of a type or an integer literal is just a tiny stain on the face of the universe! (:-)) There are other, more structured and controllable ways of parametrization. For example, 1) we all know built-in unconstrained arrays in languages like Ada. They are parametrized by index bounds. 2) Ada 83 introduced type discriminants and subtyping based on constraining discriminants. 3) OO languages provide dynamically polymorphic types, were the specific type(s) plays the role of the varying parameter (type tag, vtable etc). > There's no need for dynamic binding, wrappers > and those ugly downcasts :-P. Statically and dynamically polymorphic > containers are just two different points of view, two different > philosophies. They are not so different, see above. > It's nearly impossible to objectively say which one is the > proper, for it depends on what is important to you. Both approaches have > pros and cons (as we both tried to show in all our posts) and both aren't > ideal in all cases. I think C++ chose the templates approach because it's > closer to C++'s 'spirit' (don't pay for what you don't use, make built-in > and UDTs the same etc). I think #define is even more in C++'s spirit. Note also how simple and effective it is! (:-)) > For contrary, Java has taken the opposite approach. > And you are forced to use dynamic dispatching and downcasting, which doesn't > sound attractive to me (at least you don't need wrappers, because Java > object hierarchy is single-rooted). Need of donwcasting just highlights language design faults. There are also, similar cases in Ada, alas. Yes, ADT in its present state is unsuitable for building a decent container library. But that does not mean that it never be... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de