🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #2043

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

#2043
From: J. Kanze
Date: Tue, 05 Sep 1995 16:42
50 lines
2576 bytes
Kevin Cline (kcline@sun132.spd.dsccc.com) wrote:

|> I assume you are talking about an interface like

|>   MessageId.H:
|>   ------------
|> 	enum { DOOR_LOCKED, MONSTER_SEEN, ... } MessageId;

|>   Message.H:	
|>   ----------
|> 	#include "MessageId.H"
|> 	void message(MessageId, const char* fmt, ...)

|> with some data file that is compiled to produce MessageId.H, and also
|> a run time database of message formats for various languages.

More or less.

|> For C++, I would compile the data file to produce a class definition
|> for each message, instead of just an enum identifier, e.g.

|>   Messages.dat:
|> 	FoundObjectMsg(string color, string type) {
|> 	  ENGLISH(There is a %s %s here,1,2)
|> 	  SPANISH(Aqui esta un %s %s,2,1)
|> 	}
    [Rest of example cut...]

|> Sorry for my pathetic monolingualism.

Which is exactly the problem.  Most programmers don't know *all* of the
worlds languages, at least not well enough to write messages in them
that would be acceptable to a native speaker.  So the translations are
typically done locally, after the program is written and compiled.
Results: you cannot have the messages in the code.

|> This scheme is typesafe, and no more expensive in time or space
|> than non-typesafe methods.  There is a minimal cost at compile time.

This scheme still doesn't address a major problem: word order varies
from one language to another, so in some languages, you will have to
insert the color first, in others, the type (to take your example.  In
fact, I suspect that this is the case between English and Spanish; if
Spanish is like Italian or French, the color should come after the noun
it modifies, and not before.)
-- 
James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils en informatique industrielle--
                             --Beratung in industrieller Datenverarbeitung
Technical Details
Message-ID: <42humd$1ug@gabi.gabi-soft.fr>
Path: arc1-ca.pugleaf.net!gabi-soft.fr!not-for-mail
References: <DDJ2Lp.3DG@pentagon-ai.army.mil> <41afe9$d10@newsbf02.news.aol.com> <423cuc$tab@harbinger.cc.monash.edu.au> <424os9$1ci@sun132.spd.dsccc.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!gabi-soft.fr!not-for-mail
From: kanze@gabi-soft.fr (J. Kanze)
Newsgroups: rec.games.programmer,comp.lang.c++
Subject: Re: cout vs printf speed (was: Should I learn C or C++ first?)
Followup-To: rec.games.programmer,comp.lang.c++
Date: 5 Sep 1995 18:42:53 +0200
Organization: GABI Software, Sarl.
Message-ID: <42humd$1ug@gabi.gabi-soft.fr>
References: <DDJ2Lp.3DG@pentagon-ai.army.mil> <41afe9$d10@newsbf02.news.aol.com> <423cuc$tab@harbinger.cc.monash.edu.au> <424os9$1ci@sun132.spd.dsccc.com>
NNTP-Posting-Host: gabi.gabi-soft.fr
X-Newsreader: TIN [version 1.2 PL2]