🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #2056

Re: cout vs printf speed (was: Should I learn C or C++ first?)

#2056
From: Fergus Henderson
Date: Wed, 06 Sep 1995 22:14
37 lines
2459 bytes
kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) writes:

>matt@godzilla.EECS.Berkeley.EDU (Matt Austern) writes:
>
>|> There's nothing wrong with a C++ implementation parsing
>|> printf's format string at compile time, doing error checking to
>|> make sure that there aren't any type errors, and putting in the
>|> appropriate low-level calls.
>
>|> I don't know the names of any implementations that actually do this, but
>|> I strongly suspect that there are some.
>
>Actually, I doubt it.  Normally, the format string in production code
>will not be a string literal, but rather something read from a
>configuration file, dependant on the locale setting.

That has not been my observation.

>Or do you really think everyone in the world can read English
>fluently.

That's not relevant.  The issue is optimization, not
internationalization.  What is relevant is that in many C programs,
most calls to printf() have a string literal as the first argument; if
optimizing those calls to printf() is likely to speed up the program or
reduce code size, then any good optimizing compiler should do so, just
as any good optimizing compiler should optimize division by a
constant.  The fact that there may be many programs that don't use
division by a constant or printf() with a string literal for the format
string does not imply that compilers should not optimize those
constructs.

-- 
Fergus Henderson             |  #define x t=a[i],a[i]=a[m],a[m]=t
                             |  char a[]=" 12345678";main(m,i,j,t){for(i=m;i<
fjh@cs.mu.oz.au              |  9;x,i++)for(x,j=m;--j?(t=a[m-j]-a[m])-j&&t+j:
http://www.cs.mu.oz.au/~fjh  |  main(m+1)*0;);m-9||puts(a+1);} /* 8 queens */
Technical Details
Message-ID: <9525008.24470@mulga.cs.mu.OZ.AU>
Path: arc1-ca.pugleaf.net!munta.cs.mu.OZ.AU!fjh
References: <DDJ2Lp.3DG@pentagon-ai.army.mil> <41afe9$d10@newsbf02.news.aol.com> <41kici$p4t@deyke3.fc.hp.com> <41ngln$qau@druid.borland.com> <41tjep$2hn@deyke3.fc.hp.com> <41v8k9$jq8@tpd.dsccc.com> <41vst0$9nb@gap.cco.caltech.edu> <MATT.95Aug29163934@godzilla.EECS.Berkeley.EDU> <KANZE.95Aug30210553@slsvhdt.lts.sel.alcatel.de>

Show Full Headers
Complete Article Headers
Newsgroups: rec.games.programmer,comp.lang.c++
Path: arc1-ca.pugleaf.net!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: cout vs printf speed (was: Should I learn C or C++ first?)
Message-ID: <9525008.24470@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU (CS-Usenet)
Organization: Computer Science, University of Melbourne, Australia
References: <DDJ2Lp.3DG@pentagon-ai.army.mil> <41afe9$d10@newsbf02.news.aol.com>  <41kici$p4t@deyke3.fc.hp.com> <41ngln$qau@druid.borland.com>  <41tjep$2hn@deyke3.fc.hp.com> <41v8k9$jq8@tpd.dsccc.com>  <41vst0$9nb@gap.cco.caltech.edu>  <MATT.95Aug29163934@godzilla.EECS.Berkeley.EDU> <KANZE.95Aug30210553@slsvhdt.lts.sel.alcatel.de>
Date: Wed, 6 Sep 1995 22:14:04 GMT