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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 109fba,cd8ed9115942852f X-Google-NewGroupId: yes X-Google-Thread: 103376,b92b95c9b5585075 X-Google-NewGroupId: yes X-Google-Attributes: gid4f1905883f,gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.c++,comp.lang.ada Subject: Re: Why use C++? Date: Sat, 13 Aug 2011 11:52:14 +0200 Organization: cbb software GmbH Message-ID: References: <1e292299-2cbe-4443-86f3-b19b8af50fff@c29g2000yqd.googlegroups.com> <1fd0cc9b-859d-428e-b68a-11e34de84225@gz10g2000vbb.googlegroups.com> <9ag33sFmuaU1@mid.individual.net> <1d8wyhvpcmpkd.ggiui9vebmtl.dlg@40tude.net> <150vz10ihvb5a.1lysmewa1muz4$.dlg@40tude.net> <1q4c610mmuxn7$.1k6s78wa0r8fj.dlg@40tude.net> <1vn800hbyx8k4$.1lsveclj56197$.dlg@40tude.net> <1gu6ni1yb54k3$.4nbvfqqndl8m$.dlg@40tude.net> <9amuf2FdetU3@mid.individual.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: DLfz+iopJAs932asgPgYdA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: g2news2.google.com comp.lang.c++:92679 comp.lang.ada:21568 Date: 2011-08-13T11:52:14+02:00 List-Id: On Sat, 13 Aug 2011 21:29:05 +1200, Ian Collins wrote: > It's pretty rare for the application domain to be concerned about > the semantics of an integer beyond those specified by the language. If buffer overflows and code quality is not a concern, then yes. >>>> In each such case I will have to use a type different from the machine >>>> type. This is just another argument why types need to be precisely >>>> specified. I addressed this issue above. >>> >>> But they are precisely specified on any given platform. >> >> 1. They are not. In order to see the specification of int, you have to read >> the compiler documentation. My point was that the program code does not >> specify the properties of int. The answer that it is defined somewhere >> somehow is not an argument at all, anything works in this or that way. > > If you want to get the best performance out of a given platform (which > many C and C++ programs do), you have to program to the characteristics > of the platform. First of all, performance is not a functional requirement. If functional requirements are not met, non-functional ones are irrelevant. Thus the question stands: what does int implement? Where in the program code is any specification of the *functional* requirements which the implementation chosen to be int is supposed to fulfill [in the best etc possible way, which in its turn requires validation]? How do I know if int is OK, not unsigned, not long, not short and so on? Secondly, how do you know that int gives you the best performance across all possible implementations fulfilling the functional requirements? By choosing int you prohibit the compiler to select any other machine type, which also does the things you want. The point is, specify what you want and let the compiler to implement it in a best possible way. Choosing an implementation is an optimization issue, you can aim at memory use, at time, at best lock-free sharing and so on. Fixing a machine type makes your program potentially less efficient. More precisely you specify the semantics of required type, more knowledge the compiler has to generate efficient code. >> 2. I don't care about the platform, I care about what the program is >> supposed to do. The type's properties shall be defined by the application >> domain. > > Can you give an example of where that would be an issues not solved by > user defined types? BTW, the point was: don't use built-in numeric types. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de