[svlug] C/C++ flame bait (was "Any X11 Game developers on this list?")

Scott Deeg sdeeg at accesscom.com
Thu Nov 19 15:41:24 PST 1998


>D. Dante Lorenso wrote:
>> I'm also fighting between developing in C or C++.

Bevan Schroeder wrote:
>For a game, C++ is a very bad choice.  I would argue this in the general
>case as well, but I don't want to start a silly flamewar

Aaawwww, you're no fun. ;P

Seriously tho, I've just started playing with Linux, and I'm interested in
how people do their work.  You're confirming what I've observed which is
that much Linux development is done in C and not C++ (or the other OO C's).

The question becomes; why?

Granted C++ is going to be slower, but there have to be better reasons.
We're not talking about orders of magnitude speed differences. (are we?)

> ... Noteworthy WRT your comment
>about OO design is that Gtk is OO, and even garbage collects, so OO is
>feasible in C.

Feasible yes, but so is building battle ships with concrete.  I looked at
GTK, and while I'll concede that it's OO in principal, I consider it to be
that way in more of an academic sense.  It still follows the general C-like
"pass objects to functions for processing" methodology.  eg/

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "GTK Tic Tac Toe");

OKay, I would rather create an instance of an object instead of asking some
function to give me one, but I'll roll with it.  It's line 2 that really
makes me wince, and is a perfect example of what I'm talking about.  First,
you're calling an external function to modify the data in the object
(gack).  Second, you're having to cast the object to an appropriate type
because the framework obviously doesn't understand that GTK_WINDOW_TOPLEVEL
subclasses GTK_WINDOW (gack').  Then there's event handling with it's
passing around of function pointers and use of (void *) blocks for data
passing (gack'').

I found the basic TicTacToe example so inelegant that I have dropped even
the consideration of learning GTK until performance becomes such an issues
that I can't use Java.  Even with all Java's flaws (and there are many) the
standard libraries are very logical and OO, and facilitate the "use the
force, read the source" methodology for learning (even for beginning
programmers).  The OO design of GTK feels forced ... like it's using the
wrong tool for the job.  (hhmmmm ... :)

To compare, I recreated the TicTacToe example I found for GTK in Java.  The
Java source is less then half the size, is *much* easier to understand
(IMHO), and implements the game better.

see:
http://www.accesscom.com/~sdeeg/GTK.html

What would be the compelling reason to use GTK/C and not a good(tm) OO/C++
lib (if it actually existed).

>And the biggest reason for not developing in C++ on linux is my success
>rate (which is admittedly just personal experience):
...
>I don't know why this is, maybe it just means the less capable programmers
>are the ones who choose C++ (and it's not the language's fault at all),
>but even that is saying something. :)

It's very easy to interpret that as: the implementation of C++ in Linux
isn't all that good so everyone develops in C so it gets all the attention
(bug fixes) and C++ is left to flounder so C++ never gets any better so
everyone programs in C so ... (phew).  It is also likely that many senior
engineers working in Linux prefer C because they have been using it for 15
years.  This leaves only the hardy, fanatic, and crazy using C++.

>I think (hope) this has proven relevant for a decent amount of the
>readers, who may be interested in xlib or C/C++ issues.

Very relevant for me.  Linux is like a ray of sunshine in my life, and I
love it.  Since leaving college 3 years ago I've been doing Windoze, and
it's only since using Linux that I've really realized how jacked up that
system is.

Well, this mail isn't nearly as cohesive as I would like, but I don't have
time to edit.  I am very interested in Linux programming, and I hope I
didn't come across as considering C++/OOP as "the one true path".  I'm just
trying to gather as much information as I can.  All thoughts appreciated.

- Scott



--
echo "unsubscribe svlug" | mail majordomo at svlug.org
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ to unsubscribe
see http://www.svlug.org/mdstuff/lists.shtml for posting guidelines.



More information about the svlug mailing list