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,54c513170bafd693 X-Google-Attributes: gid103376,public From: "Robert I. Eachus" Subject: Re: Desirability of C++ Date: 2000/05/03 Message-ID: <390FBAD0.7CECA91A@earthlink.net>#1/1 X-Deja-AN: 618571437 Content-Transfer-Encoding: 7bit References: <390DEC7F.9429C82C@online.no> <390E2A20.B647D0D6@maths.unine.ch> <8em8mb$evd$1@wanadoo.fr> <390EEF24.BD36AA24@maths.unine.ch> X-Accept-Language: en,pdf Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 957332159 63.24.55.141 (Tue, 02 May 2000 22:35:59 PDT) Organization: The MITRE Corporation MIME-Version: 1.0 NNTP-Posting-Date: Tue, 02 May 2000 22:35:59 PDT Newsgroups: comp.lang.ada Date: 2000-05-03T00:00:00+00:00 List-Id: Robert A Duff wrote: > ...Apparently, Turbo Pascal actually makes assignment work, which is > obviously preferable to either of the above Ada alternatives. I guess I don't see this. In Ada, you have several choices: String, Bounded_String, and Unbounded_String. Each is appropriate in different places, and, yes it can be painful if you are forced--by ignorance or management--to use the wrong abstraction for the job at hand. But when an instance of Bounded_String is the appropriate choice, it has always been my experience that you WANT the compiler to reject assignments between objects with different maximum sizes. That is almost always either a bug or a situation that code to handle the potential mismatch. If you really get upset about explicit conversions, then instantiate Bounded_String once, with the maximum of all the maximum sizes. The other thing to note is that having multiple instances of Bounded_Strings in your program cannot result in code bloat. Hint: Write a program that reads a number from Current_Input, then calls a subroutine that recursively calls itself and on each call, instantiates Ada.Strings.Bounded for a different maximum length: function Recur(N: Natural) return String is package BS is new Ada.Strings.Bounded(N); begin if N > 0 then return Recur(N-1) & 'X'; else return ""; end if; return end Recur; -- put in some code that exercises the instance if you want... How many copies of the code for Ada.Strings.Bounded are there in your executable? Can you call Recur with a larger value of N? > This thread sure is wandering! I mean, it's hard to see how one can > explain the popularity of C or C++ by the fact that Turbo Pascal has > better strings than Ada (in one respect). That was what was being > discussed, wasn't it? ;-) The popularity of C and C++ with many programmers is easy to explain. Ada asks too many questions! For software engineers who know what they are doing, programming in Ada is very easy: Find all the answers to the hard questions that need to be asked as part of the design process, then let the code write itself. But for those whe are used to finding a 75% or 90% or even 99% solution and never considering the rest of the hard questions, programming in Ada is a nightmare. Back in the early days of Ada, we ran an experimental course to teach Ada to a group of experienced software engineers, who had been programming in assembler. It quickly became obvious that a large portion of the class was never going to be able to compile and run a one page Ada program. We then switched tacks, and took a group that already knew Pascal, and taught them Ada. Much easier, and much more successful. We then looked at the results more closely and found that there really was no difference--if software engineers could program in Pascal or Algol or PL/I, they could easily learn to program in Ada. The high barrier was learning some of the key concepts of software engineering. Much later I discovered that if you taught software engineering and used Ada as a mode of expression, you wound up with software engineers who could program in Ada. (And incidently, I have also found from experience that it is not difficult to do software engineering in C or C++. But teaching software engineering in C is impossible. In fact, remember the earlier question: Why are there more C and C++ programmers than Ada programmers? The answer is simple. I don't know any Ada software engineers who can't program in C as well. C is fairly easy to learn, there are a few glitches that can catch unwary programmers once or twice, but the C Puzzle Book type of code does not belong in anything written to be maintained, so I don't miss it at all.