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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1cf653444208df72 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-08 07:55:07 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cyclone2.usenetserver.com!usenetserver.com!news01.optonline.net!news02.optonline.net.POSTED!not-for-mail From: "Mike Mohr" Newsgroups: comp.lang.ada References: <9pgr68$7pu1@news.cis.okstate.edu> <9phnic$9g5$1@nh.pace.co.uk> <5fkv7.134136$w7.19988807@news02.optonline.net> Subject: Re: ada vs. cpp X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Mon, 08 Oct 2001 14:55:05 GMT NNTP-Posting-Host: 24.188.177.13 X-Trace: news02.optonline.net 1002552905 24.188.177.13 (Mon, 08 Oct 2001 10:55:05 EDT) NNTP-Posting-Date: Mon, 08 Oct 2001 10:55:05 EDT Organization: Optimum Online Xref: archiver1.google.com comp.lang.ada:13925 Date: 2001-10-08T14:55:05+00:00 List-Id: "Pascal Obry" wrote in message news:u8zepgmea.fsf@wanadoo.fr... > > "Mike Mohr" writes: > > > C++ has a string class. > > I know. I doubt you did because you had indicated otherwise. >Yet in C/C++ it is hard to beat > > V1 : constant String := "1234567890"; > V2 : constant String := "AAA" & V1 (3 .. V1'Last - 2) & "BBB"; > > in readability and ease of use. const string V1 = "0123456789"; const string V2 = "AAA" + V1.substr(3, V1.size() - 2) + "BBB"; The indices may be off because I am not too familiar with Ada but as you can see, the C++ version mirrors the Ada version pretty closely. > > I have done many text processing code in both C/C++ and Ada and from > experience I found the Ada code far more readable. There is may examples. Of course you do (find Ada more readable), you are an Ada programmer. I doubt that this V1 (3 .. V1'Last - 2) is intuitive or readable to non-Ada programmers. > > Another one that come to mind: > > V1 : constant String := "0123/zzz"; > > subtype Code is Positive range 1 .. 4; > subtype Arg is Positive range 6 .. 8; > > V2 : constant String := V1 (Arg) & '-' & V1 (Code); > > This is not theory, I have used these kinds of code many many times. And again > I don't see how we could have a better readability ! const string V1 = "0123/zzz"; const string V2 = V1.substr(0, 4) + "-" + V1.substr(5,7); Even though your efforts to describe something easy for Ada and hard for C++ have failed, you should know that I can play these C++-strings-can-do-this-in-2-lines-and-Ada-can't games as well. Isolated examples which measure LOC are not a basis to claim that Ada strings are superior to C++ strings or that C++ strings are superior to Ada strings, or Java Strings etc... Completely unrelated issue; does anyone know the cost of ObjectAda for windows? I have the free download version and I like it. > > Pascal. > > -- > > --|------------------------------------------------------ > --| Pascal Obry Team-Ada Member > --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE > --|------------------------------------------------------ > --| http://perso.wanadoo.fr/pascal.obry > --| > --| "The best way to travel is by means of imagination"