Global variables

This is a discussion on Global variables within the Other Technologies forums in category; "Phlip" <phlip_cpp @ yahoo.com> wrote in message news:qtz6e.608$nK5.124 @ newssvr33.news.prodigy.com. .. > William wrote: > > > > - nobody yet reported a global making something faster... > > > > Yes, they did. Global look up tables were mentioned a while > > back. -Wm > > Profiled? In my own work, yes, but it's really a no-brainer. Generating a table of any significant size for a moderately complex function once is hard to beat. (In one case I got a 10x speed up in exchange for a fraction of a second more initialization time.) -Wm...

Go Back   Application Development Forum > Other Technologies

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #101  
Old 04-12-2005, 10:51 AM
William
Guest
 
Default Re: Global variables

"Phlip" <phlip_cpp@yahoo.com> wrote in message
news:qtz6e.608$nK5.124@newssvr33.news.prodigy.com. ..
> William wrote:
>
> > > - nobody yet reported a global making something faster...

> >
> > Yes, they did. Global look up tables were mentioned a while
> > back. -Wm

>
> Profiled?


In my own work, yes, but it's really a no-brainer. Generating
a table of any significant size for a moderately complex
function once is hard to beat. (In one case I got a 10x speed
up in exchange for a fraction of a second more initialization
time.) -Wm


Reply With Quote
  #102  
Old 04-12-2005, 10:52 AM
William
Guest
 
Default Re: Global variables

"Gregory L. Hansen" <glhansen@steel.ucs.indiana.edu> wrote in message
news:d3ehor$j9a$2@rainier.uits.indiana.edu...
> In article <_uWdnQq3c6oHPsffRVn-1g@giganews.com>,
> William <Reply@NewsGroup.Please> wrote:
> >
> >Yes, they did. Global look up tables were mentioned a while
> >back. -Wm

>
> Because it was global, or because it was a look up table?


Where's the efficiency in generating the same look up tables
repeatedly? -Wm


Reply With Quote
  #103  
Old 04-12-2005, 11:10 AM
Phlip
Guest
 
Default Re: Global variables

William wrote:

> > >Yes, they did. Global look up tables were mentioned a while
> > >back. -Wm

> >
> > Because it was global, or because it was a look up table?

>
> Where's the efficiency in generating the same look up tables
> repeatedly? -Wm


Objects may have a long lifespan without harming design.

The worst global is read-write. Wrap globals in language features (such as
'const') that prevent writes. Then they cannot transmit bugs between
modules.

So emmend my summary:

- nobody has seen a global that had to be naked
to be efficient

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces


Reply With Quote
  #104  
Old 04-12-2005, 11:16 AM
ad_scriven@postmaster.co.uk
Guest
 
Default Re: Global variables

William wrote:

> "Gregory L. Hansen" <glhansen@steel.ucs.indiana.edu> wrote [...]
> > William <Reply@NewsGroup.Please> wrote:
> > >
> > >Yes, they did. Global look up tables were mentioned a while
> > >back [as being faster than a local variable]

> >
> > Because it was global, or because it was a look up table?

>
> Where's the efficiency in generating the same look up tables
> repeatedly? -Wm


That translates as `because it was a look-up table.'

Antony

Reply With Quote
  #105  
Old 04-12-2005, 12:52 PM
Christer Ericson
Guest
 
Default Re: Global variables

In article <SxR6e.759$bc2.212@newssvr17.news.prodigy.com>,
phlip_cpp@yahoo.com says...
> So emmend [sic] my summary:
>
> - nobody has seen a global that had to be naked
> to be efficient


In <115ludqq2ld0b6d@corp.supernews.com> "CTips" posted a very good
example of where a global variable solution would not exhibit the
aliasing problem of an encapsulated solution and therefore the
former would be (potentially vastly) faster.

It's well-known that higher levels of abstraction are detrimental
to execution speed in languages that exhibit aliasing due to
missed compiled optimizations. So, in short, your summary is crap.

Why are you harping on about this?

--
Christer Ericson
http://realtimecollisiondetection.net/
Reply With Quote
  #106  
Old 04-12-2005, 01:04 PM
CBFalconer
Guest
 
Default Re: Global variables

Phlip wrote:
> William wrote:
>
>>>> Yes, they did. Global look up tables were mentioned a while
>>>> back. -Wm
>>>
>>> Because it was global, or because it was a look up table?

>>
>> Where's the efficiency in generating the same look up tables
>> repeatedly? -Wm

>
> Objects may have a long lifespan without harming design.
>
> The worst global is read-write. Wrap globals in language features
> (such as 'const') that prevent writes. Then they cannot transmit
> bugs between modules.


You can't do that cleanly if you have to write initialization code
to set the table up.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson

Reply With Quote
  #107  
Old 04-12-2005, 02:06 PM
Philippa Cowderoy
Guest
 
Default Re: Global variables

On Tue, 12 Apr 2005, CBFalconer wrote:

> Phlip wrote:
>> The worst global is read-write. Wrap globals in language features
>> (such as 'const') that prevent writes. Then they cannot transmit
>> bugs between modules.

>
> You can't do that cleanly if you have to write initialization code
> to set the table up.
>


Depends on your language - it works fine under lazy evaluation, for
example.

--
flippa@flippac.org

Ivanova is always right.
I will listen to Ivanova.
I will not ignore Ivanova's recomendations.
Ivanova is God.
And, if this ever happens again, Ivanova will personally rip your lungs out!
Reply With Quote
  #108  
Old 04-12-2005, 02:16 PM
Phlip
Guest
 
Default Re: Global variables

Philippa Cowderoy wrote:

> CBFalconer wrote:
>
> > Phlip wrote:
> >> The worst global is read-write. Wrap globals in language features
> >> (such as 'const') that prevent writes. Then they cannot transmit
> >> bugs between modules.

> >
> > You can't do that cleanly if you have to write initialization code
> > to set the table up.

>
> Depends on your language - it works fine under lazy evaluation, for
> example.


In C++, the object could easily be 'const':

BigTable const globalTable(parameters);

int main() { game(); }

'const' engages after construction time. (Warning: Before main() starts,
using globalTable generates undefined behavior.)

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces


Reply With Quote
  #109  
Old 04-12-2005, 02:52 PM
Philippa Cowderoy
Guest
 
Default Re: Global variables

On Tue, 12 Apr 2005, Phlip wrote:

> Philippa Cowderoy wrote:
>
>> CBFalconer wrote:
>>
>>> Phlip wrote:
>>>> The worst global is read-write. Wrap globals in language features
>>>> (such as 'const') that prevent writes. Then they cannot transmit
>>>> bugs between modules.
>>>
>>> You can't do that cleanly if you have to write initialization code
>>> to set the table up.

>>
>> Depends on your language - it works fine under lazy evaluation, for
>> example.

>
> In C++, the object could easily be 'const':
>
> BigTable const globalTable(parameters);
>

<snip>
> 'const' engages after construction time.
>


*smacks forehead*

Spot who's not written any serious C++ recently? Though initialisation
order makes a potential thorn in the side for some purposes there.

It makes rather a lot of sense that const can't prevent construction
though, value objects are kinda useless otherwise.

--
flippa@flippac.org

'In Ankh-Morpork even the shit have a street to itself...
Truly this is a land of opportunity.' - Detritus, Men at Arms
Reply With Quote
  #110  
Old 04-12-2005, 02:57 PM
Phlip
Guest
 
Default Re: Global variables

Philippa Cowderoy wrote:

> > BigTable const globalTable(parameters);
> >

> <snip>
> > 'const' engages after construction time.

>
> *smacks forehead*
>
> Spot who's not written any serious C++ recently? Though initialisation
> order makes a potential thorn in the side for some purposes there.


I originally wrote "but don't use the global before main()," but erased it
as too pedantic. Who renders frames before main()? Who in C++ doesn't know
not to depend on the order of initialization of objects before main()?

You really want me to go into pure hand-holding mode here?

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 07:20 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.