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,8623fab5750cd6aa X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!not-for-mail From: "Per Dalgas Jakobsen" Newsgroups: comp.lang.ada References: <40b9c99e$0$268$edfadb0f@dread16.news.tele.dk> <70Suc.8419$hB2.6364@nwrdny03.gnilink.net> Subject: Re: Improving Ada's image - Was: 7E7 Flight Controls Electronics Date: Tue, 1 Jun 2004 23:14:11 +0200 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Message-ID: <40bcf1a4$0$317$edfadb0f@dread16.news.tele.dk> Organization: TDC Totalloesninger NNTP-Posting-Host: 193.89.241.47 X-Trace: 1086124452 dread16.news.tele.dk 317 193.89.241.47:53758 X-Complaints-To: abuse@post.tele.dk Xref: controlnews3.google.com comp.lang.ada:998 Date: 2004-06-01T23:14:11+02:00 List-Id: >> *) that the reusability factor of Ada is magnitudes higher than for C/C++. > > Really? Why do you think so? What is it about Ada that would make a body > of code written for one purpose reusable for another, in a way that does > not apply to C or C++? Reusability implies portability (at least for my case), since we are using several platforms for a given system. Generics/templates aids reusability For generics/templates: For C it gives itself: no generics/templates. You could use macros for some, but they really doesn't do the job very nice. For C++, templates should be the answer, but unfortunately quite a bit of "implementation specific freedom" renders this feature "less useful". http://www.mozilla.org/hacking/portable-cpp.html (a bit old, but still valid to some extend). For Ada, generics seems to work quite nicely. For portability: C and C++: I would almost call it non-existing. Try reading a binary byte-aligned file into a C/C++ struct. It's fairly easy with one compiler (if it's not the opposite endianess), but try make it work across different compilers... :-( Ada has the nice for-use statement that pretty much solves this mess. And just exactly how big is an int? Well, we could define an int16 for a signed 16 bit integer, int32 ..., etc. But how do you get it into your code: You include a header-file with sized integer types. Then another guy wants to use your code, but he has his own header-file with sized integer types, unfortunately this guy has named his unsigned 8 bit as uchar8, and you called it uint8. Now what? Things gets very messy, very fast. In Ada you just define a type with a suitable range and size. C and C++ has conditional compiles, which very fast gets very messy. No such thing in Ada. I believe we could add quite a bit to this list. Btw.: "Safer C" by Les Hatton is "fascinating" reading. Did I miss the point here? Per