Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #8781

Re: Why use C++?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++, comp.lang.ada
Subject Re: Why use C++?
Date Sat, 13 Aug 2011 23:10:48 +1200
Lines 66
Message-ID <9an4doFdeuU2@mid.individual.net> (permalink)
References <fb9f787c-af06-427a-82b6-b0684e8dcbc5@s2g2000vby.googlegroups.com> <j1kaj8$dge$1@adenine.netfront.net> <1e292299-2cbe-4443-86f3-b19b8af50fff@c29g2000yqd.googlegroups.com> <j1tha5$11q5$1@adenine.netfront.net> <1fd0cc9b-859d-428e-b68a-11e34de84225@gz10g2000vbb.googlegroups.com> <9ag33sFmuaU1@mid.individual.net> <j1v17b$h98$1@munin.nbi.dk> <1d8wyhvpcmpkd.ggiui9vebmtl.dlg@40tude.net> <j203cu$q97$1@dont-email.me> <150vz10ihvb5a.1lysmewa1muz4$.dlg@40tude.net> <j20cif$dr6$1@dont-email.me> <1q4c610mmuxn7$.1k6s78wa0r8fj.dlg@40tude.net> <j22c68$2m7$1@dont-email.me> <1vn800hbyx8k4$.1lsveclj56197$.dlg@40tude.net> <j239le$4l8$1@dont-email.me> <fwnlcp4mgj03$.1tjeqjtos00o8$.dlg@40tude.net> <j23tkh$gqa$1@dont-email.me> <1gu6ni1yb54k3$.4nbvfqqndl8m$.dlg@40tude.net> <j25ahb$gqm$1@dont-email.me> <s2xz04q9idte.hfqivhx1f77o.dlg@40tude.net> <9amuf2FdetU3@mid.individual.net> <m0g18wtbk40g$.1ebe2ndaeyvuj$.dlg@40tude.net>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net hsGNwT40HS4Rkql4kdLGOwrSNHaaAQ48gX6Ag9djEaPiyZoCR9
Cancel-Lock sha1:j0T/Ai9rC1qL0kM3MmZgoAZKJf8=
User-Agent Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4
In-Reply-To <m0g18wtbk40g$.1ebe2ndaeyvuj$.dlg@40tude.net>
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:8781 comp.lang.ada:3258

Cross-posted to 2 groups.

Show key headers only | View raw


On 08/13/11 09:52 PM, Dmitry A. Kazakov wrote:
> 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.

Most variables have limited scope and a well defined range.  So if I use 
an int in a for loop over a small set of data, I'm not writing poor 
quality code.

>>>>> 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.

It very often is the first one for most of the embedded systems I write!

> If functional
> requirements are not met, non-functional ones are irrelevant.

The functional requirements are irrelevant if they can not be met in the 
required time.

> 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?

In general, you can't.  Where it matters, you have to measure.

> 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.

I do see your point and for C or C++ the best we can do knowing a 
variable is signed or unsigned of a given range is to use one of the C 
fast_xx types.  Far from ideal I know.

Yes I agree being able to specify a type without reference to an 
underlying fundamental type is a powerful feature C and C++ lack.

-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Why use C++? Miro <nickbergeronsemail@gmail.com> - 2011-08-06 14:00 -0700
  Re: Why use C++? "Paul" <pchristor@yahoo.co.uk> - 2011-08-06 22:09 +0100
    Re: Why use C++? Stuart Redmann <DerTopper@web.de> - 2011-08-10 00:39 -0700
      Re: Why use C++? "Paul" <pchristor@yahoo.co.uk> - 2011-08-10 09:59 +0100
        Re: Why use C++? Stuart Redmann <DerTopper@web.de> - 2011-08-10 07:09 -0700
          Re: Why use C++? "Paul" <pchristor@yahoo.co.uk> - 2011-08-10 17:22 +0100
          Re: Why use C++? Niklas Holsti <niklas.holsti@tidorum.invalid> - 2011-08-10 22:05 +0300
            Re: Why use C++? "Randy Brukardt" <randy@rrsoftware.com> - 2011-08-10 17:37 -0500
              Re: Why use C++? Ludovic Brenta <ludovic@ludovic-brenta.org> - 2011-08-11 00:49 +0200
                Re: Why use C++? "Randy Brukardt" <randy@rrsoftware.com> - 2011-08-11 23:54 -0500
              Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-11 09:54 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-11 11:13 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-11 13:43 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-11 17:09 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-12 10:32 +0200
                Re: Why use C++? Hyman Rosen <hyrosen@mail.com> - 2011-08-12 09:15 -0400
                Re: Why use C++? "Randy Brukardt" <randy@rrsoftware.com> - 2011-08-12 17:09 -0500
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-12 19:20 +0200
                Re: Why use C++? Ludovic Brenta <ludovic@ludovic-brenta.org> - 2011-08-12 23:22 +0200
                Re: Why use C++? Ludovic Brenta <ludovic@ludovic-brenta.org> - 2011-08-16 06:06 -0700
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-13 11:37 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-13 12:27 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-15 13:38 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-13 13:02 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-12 11:21 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-12 16:30 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-12 22:05 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-13 11:15 +0200
                Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-13 21:29 +1200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-13 11:52 +0200
                Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-13 23:10 +1200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-13 13:46 +0200
                Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-14 08:30 +1200
                Re: Why use C++? Brian Drummond <brian@shapes.demon.co.uk> - 2011-08-13 11:54 +0000
                Re: Why use C++? Simon Wright <simon@pushface.org> - 2011-08-13 14:12 +0100
                Re: Why use C++? Brian Drummond <brian@shapes.demon.co.uk> - 2011-08-14 11:01 +0000
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-14 08:46 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-14 08:51 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-14 09:29 +0200
                Re: Why use C++? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-16 01:18 -0700
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-16 10:47 +0200
                Re: Why use C++? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-16 02:52 -0700
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-16 12:39 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-16 12:23 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-16 12:58 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-16 13:44 +0200
                Re: Why use C++? Bill Findlay <yaldnif.w@blueyonder.co.uk> - 2011-08-16 15:51 +0100
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-16 21:13 +0200
                Re: Why use C++? Bill Findlay <yaldnif.w@blueyonder.co.uk> - 2011-08-16 20:23 +0100
                Re: Why use C++? "Randy Brukardt" <randy@rrsoftware.com> - 2011-08-12 00:02 -0500
                Re: Why use C++? Robert Wessel <robertwessel2@yahoo.com> - 2011-08-12 00:16 -0500
                Re: Why use C++? Adam Beneschan <adam@irvine.com> - 2011-08-12 09:39 -0700
                Re: Why use C++? Paavo Helde <myfirstname@osa.pri.ee> - 2011-08-12 01:51 -0500
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-12 09:41 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-12 11:40 +0200
                Re: Why use C++? Stuart Redmann <DerTopper@web.de> - 2011-08-12 04:48 -0700
                Re: Why use C++? "Vinzent Hoefler" <0439279208b62c95f1880bf0f8776eeb@t-domaingrabbing.de> - 2011-08-12 15:12 +0200
                Re: Why use C++? Stuart Redmann <DerTopper@web.de> - 2011-08-12 08:50 -0700
                Re: Why use C++? Bill Findlay <yaldnif.w@blueyonder.co.uk> - 2011-08-12 18:02 +0100
                Re: Why use C++? "Vinzent Hoefler" <0439279208b62c95f1880bf0f8776eeb@t-domaingrabbing.de> - 2011-08-15 14:59 +0200
                Re: Why use C++? Louisa <louisa.hutch@gmail.com> - 2011-08-18 06:39 -0700
          Re: Why use C++? Colin Paul Gloster <Colin_Paul_Gloster@ACM.org> - 2011-08-11 10:02 +0000
      Re: Why use C++? Dombo <dombo@disposable.invalid> - 2011-08-11 20:20 +0200
        Re: Why use C++? Lynn McGuire <lmc@winsim.com> - 2011-08-11 14:50 -0500
        Re: Why use C++? Dombo <dombo@disposable.invalid> - 2011-08-12 19:22 +0200
    Re: Why use C++? Miro <nickbergeronsemail@gmail.com> - 2011-08-13 08:37 -0700
      Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-14 08:38 +1200
        Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-14 10:41 +1200
          Re: Why use C++? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-14 07:26 +0000
            Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-14 20:18 +1200
              Re: Why use C++? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-14 09:00 +0000
        Re: Why use C++? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-16 02:10 -0700
          Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-16 21:25 +1200
            Re: Why use C++? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-16 02:54 -0700
              Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-16 22:04 +1200
  Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-07 09:10 +1200
    Re: Why use C++? "Paul" <pchristor@yahoo.co.uk> - 2011-08-06 22:13 +0100
      Re: Why use C++? Juha Nieminen <nospam@thanks.invalid> - 2011-08-07 09:09 +0000
        Re: Why use C++? "Paul" <pchristor@yahoo.co.uk> - 2011-08-07 12:37 +0100
          Re: Why use C++? Juha Nieminen <nospam@thanks.invalid> - 2011-08-07 14:52 +0000
            Re: Why use C++? "Paul" <pchristor@yahoo.co.uk> - 2011-08-07 20:21 +0100
  Re: Why use C++? Lynn McGuire <lmc@winsim.com> - 2011-08-06 16:29 -0500
  Re: Why use C++? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-07 09:35 +0000
    Re: Why use C++? "crea" <no@invalid.com> - 2011-08-07 13:40 +0100
  Re: Why use C++? Dombo <dombo@disposable.invalid> - 2011-08-07 15:12 +0200
    Re: Why use C++? Juha Nieminen <nospam@thanks.invalid> - 2011-08-07 14:55 +0000

csiph-web