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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,897417b380f5731e X-Google-Attributes: gid103376,public From: Brian Rogoff Subject: Re: STL, Ada, C++ (Was Re: The Next Microsoft?) Date: 2000/05/10 Message-ID: #1/1 X-Deja-AN: 621890727 References: <391328F0.1221@synquiry.com> <39133213.64A@Ganymede.com> <8f50hc$hpo$1@nnrp1.deja.com> <8f83i2$osk$1@slb1.atl.mindspring.net> <8fab3r$642$1@slb6.atl.mindspring.net> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: nntp1.ba.best.com 958022464 200 bpr@206.184.139.136 MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-05-10T00:00:00+00:00 List-Id: On Wed, 10 May 2000, Richard D Riehle wrote: > In article , > Brian Rogoff wrote: > > >On Tue, 9 May 2000, Richard D Riehle wrote: > > >> I wonder if there is a trade-off here between convenience and type > >> safety. Ada tends to lean heavily in the direction of safety, > >> and automatic instantiation seems not quite as focused on that issue. > > > >Overloading, runtime dispatching, and "use clauses" don't seem quite > >as focused on safety either. The only way that automatic instantiation > >is troubling is that in the case of a language like C++ it is undecidable, > >I think in standard C++ they limit the depth of template expansion > >(Hyman?) and I imagine a similar solution would be needed for Ada. > > Overloading is resolved at compile time. Automatic instantiation is still a "compile time" notion. It isn't the same as a runtime method select, so it is even safer than OO style programming with tagged types. Programmers used to languages like ML, Haskell, and Clean use "automatic instantiation" all of the time, they just don't call it that. I find that it works OK from the point of view of safety and lack of run time errors, but that the error messages in OCaml are not as good as in GNAT and even worse in some other FPs. This is getting better though, and doesn't look like a fundamental problem. I haven't seriously used C++ for a few years now, so it wouldn't be fair for me to comment on the error messages from heavy template programming. Once again though, this is all having to do with "ease of writing", duration of compilation, etc. > It is a little safer than run-time > dispatching, according to some practitioners. Use clauses certainly can > be problematic with regard to visibility, but they generally do not obviate > type safety. Of course, Geoff Mendal's paper on this subject illustrates > some of the concerns for use clauses with predefined types. The question > I was raising was whether we would expect the same level of confidence > from automatic instantiation we already expect from Ada's model of generic > instantiation. How do you measure level of confidence? If you mean, do I trust that type checkers for languages with parametric polymorphism can be made to work, I do. I use a language with parametric polymorphism, and it works for the scale of project I use it in. It's hard to look at any feature independently, but this one compresses code by eliminating cascading instantiations. It allows higher level programming without requiring runtime overhead, at least in C++. > >> For example, the model for generic formal package parameters in Ada > >> forces the designer to create a generic signature package corresponding to > >> the parameter. This makes automatic instantiation quite difficult to > >> achieve, but has the benefit of pretty thorough compile-time evaluation > >> of all the elements of the signature. > > > >> The goals of C++ are different from those of Ada. > > > >Programming languages don't have goals, people do. Languages are artifacts > >that can and should be discussed dispassionately. > > Please excuse my inadvertant anthropomorphism of the languages. Perhaps I > should have said, "The goals of the C++ designers were different from those > of the Ada designers." With that clarification, I doubt you would disagree > that there were some goals, at very minimum, a loose rationale, for the > design of both languages under discussion. Sure, I shouldn't be nitpicky, but C++ and Ada are both intended to be capable of doing systems programming. Ada isn't purely about safety, and as you well know has many unsafe features. And new ones were added which are also verboten in SPARK: tagged types, aliased/access all, etc. -- Brian