l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2002 Sep 20 12:57

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] global variables in C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] global variables in C

begin Bill Kendrick <nbs@sonic.net> 
> On Fri, Sep 20, 2002 at 10:34:51AM -0700, Peter Jay Salzman wrote:
> > 
> > 1. name clashing
> > 2. readability
> These are good reasons.
i agree, but if this is all there is, i don't think the topic deserves
the amount of ire that i've seen it draw.

> I'm pretty bad about using globals all over the place, though.
> My main reason, however, _is_ for readability.
> In _most_ cases, the functions I'm calling need to do things to,
> or refer to, the same variables over and over again.
> As an example, in my games I open the SDL window surface and name it
> "screen".

(good stuff snipped)
yeah, you're SDL is pretty much the same with my experiences with gtk+.

in gtk:

   most of the functions have absurdly long names to begin with.  i know
      you've seen xlib functions.  imagine them with the prefix "gtk_".

   there are so many objects that you end up having to call them long
      names just to keep it straight, like "upper_left_radio_button"

   whenever you pass upper_left_radio_button, you almost always need to
      typecast it to help C with typechecking.  so you almost never pass
      upper_left_radio_button, you actually pass something like
      GTK_OBJECT(upper_left_radio_button).  35 characters for a stupid
      radio button!   :-)

i can go on, but gtk programming gets very ugly very quickly.  passing
data to callbacks is a headache.  globals are actually very convenient
and enhance readability by an order of magnitude (as i physicst, i take
an order of magnitude very seriously ;)).

so yeah, my gtk (and ncurses) experiences are very similar to your
experience with SDL.

but some people are really insistent on this point, and i'm kind of
wondering why.

vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!