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,c406e0c4a6eb74ed 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 Discussion Request Date: Tue, 17 Aug 2004 09:50:07 +0200 Message-ID: References: <49dc98cf.0408110556.18ae7df@posting.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1NCuew3M0Imnjz54ZZT6rQO/0jQTq2kXT24LBWJoVwFvze7xw= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:2767 Date: 2004-08-17T09:50:07+02:00 List-Id: On 16 Aug 2004 14:09:41 -0700, Keith H Duggar wrote: > "Ada was an experiment that failed. It was specified in such a way > that it's hard to get adequate performance. Theoretically Ada has better support for optimizations than C. For example, in C you can get pointer to any object. This assumes that compiler is restricted in how and where it allocates them. In Ada an object has to be "aliased" to allow that. Another example is for Index in A'Range loop A (I) := ... -- There is no need to check array bounds Yet another example, in C++ any call to a virtual function is dispatching. In Ada it is only when the object is class-wide. For an OO application the difference in terms performance could be huge. > Or are there simply missing features that preclude some > efficient coding idioms (does Ada have pointers?). I'm > very ignorant when it comes to Ada so please forgive these > newbie questions. Yes, Ada has pointers, and interestingly, because that wasn't design intent, richer than C++ has. 1. Ada has specific and class-wide pointers. In C++ all pointers are class-wide. Dereferenced class-wide pointers dispatch on member functions. In Ada you have a choice. 2. Ada has anonymous pointers. It is difficult to find any equivalent in C++, because it has many limitations Ada does not have. It is something like: class X // This is not C++! { public : friend void Foo (int Something, virtual X * This); 3. Ada has pool-specific and general access pointers. A rough C++ equivalent would be operators new and operator delete. But Ada is more flexible here, its "new" is attached not to the object type, but to the pointer one. So you can have many pools of objects of same type. 4. Ada pointers are true types. In C++ pointers have structure equivalence. The difference appears when building large libraries. Consider objects of type X to be sorted using different ways. In Ada you can: type X_By_Name is access X; -- Pointer to X function "<" (Left, Right : X_By_Name) return Boolean; -- Dereferences and compares names type X_By_Value is access X; -- Another pointer to X function "<" (Left, Right : X_By_Values) return Boolean; -- Dereferences and compares values Now, you can instantiate a Sort procedure once with X_By_Name and its "<" and once with X_By_Value and its "<". The result is two different sorts with no extra control parameters to pass and no subsequent parameter checks. 5. Ada pointers are transparent to member extraction and array indexing. I.e. in Ada "->" and "." are same. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de