C++ sucks for games

P

Paul Foley

Pretty much everything worthwhile.

I doubt it. I'd bet MSDOS was written in assembler.
You're totally correct in this. But most higher-order toolkits are written
in C++.
BTW: I don't know a single piece of "real" software that was written in LISP

I.e., you're ignorant. [By the way, it's spelled "Lisp", not "LISP"]
(AFAIK even Emacs only uses LISP as an extension and scripting language:
Something that is really bad bevhaviour according to the original troll ..
eerrh ... poster).

Which Emacs? Emacs was original TECO macros (hence the name), then
Lisp. (Some) Unix versions are now written in C with (a crufty
ancient) Lisp as "extension language", yes (but there's hardly any
call for your "only": a fair amount of the core functionality is in
Lisp, and there's rather more Lisp than C there)
I am also awaiting good examples for LISP 3D-Engines, LISP- OS kernels, LISP
device drivers, LISP text processors or LISP numerical toolkits. Feel free

Google for "Mirai" and "Genera", for starters.

[You C++ types still have a way to go to catch up to 1980's Lisp :)]
 
F

Frode Vatvedt Fjeld

JKop said:
Ignorance? Arrogance maybe? (no pun intended)

Ignorance and arrogance are the best of friends.
As for the issues raised being truly something you need to know
about... do you need to tell a child not to eat its own excrement?
No. Why? It figures that out for itself. If you're writing code and
you have "new" all over the place and you've no "delete"'s, then
you'll figure out the aim of the whole "Garbage Collection" ideal. I
myself am not retarded, so I've no need for "Garbage
Collection". If, hypothetically speaking, I forsaw that I would
temporarily become retarded (a golfclub to the head maybe), then I
would make use of auto_ptr, but that has yet to happen.

I'm sorry, but it is quite obvious that you are ignorant of many
aspects of memory management. I'd recommend you find any introductory
book on the subject and read it.

[comp.lang.lisp and comp.games.development.programming.misc trimmed
from recipient list.]
 
S

Stewart Gordon

JKop wrote:
Incorrect.

If both function bodies are identical, then there's no need to write
a non- const version.

If there exists both a const version and a non-const version, then
this indicates that one version alters the object, while the other
doesn't. Conclusion: different code.
<snip>

Actually, it tends to indicate that one version returns a non-const
pointer/reference and the other returns a const pointer/reference.

[Followups trimmed]

Stewart.
 
S

Stewart Gordon

Neo-LISPer said:
Hey

Recently, I researched using C++ for game programming and here is what
I found:

C++ game developers spend a lot of their time debugging corrupted
memory. Few, if any, compilers offer completely safe modes.
Alternatively, you can't execute a small portion of the program
without compiling and linking the whole thing, then bringing your game
into a specific state where your portion of the code is being executed.

Yes I can. I can write a module that runs one or two functions from the
project as the whole program.

It's hard to find good programmers for C++ projects, because most of
the good programmers graduated to languages like Lisp or avoided C++
altogether. C++ attracts unimaginative fellows with herd mentality.
For creative projects, you want to avoid them like a plague.
<snip>

I guess the answer is: if you can't find anyone to join your C++ team,
start your project in a language that everyone likes.

Have you checked out D? It addresses a handful of your issues....

http://www.digitalmars.com/d/

Stewart.
 
J

Julie

Neo-LISPer wrote:
<snip>

Yes, it does suck -- however it sucks a lot less than a majority of the other
available languages.

If you ever decide to come out of your cave and re-join society in a beneficial
manner, you should probably consider thoroughly studying the topic of languages
and posting a comprehensive comparison of them w/ respect to a particular
task/topic (such as game programming).
 
M

Mark A. Gibbs

Phlip said:
C++ syntax is somewhat irregular. But it's lack of a 'read_mind' keyword
disturbs me most.

stroustrup probably meant to put that in, but there would have been way
to many issues with null mind pointers.

indi
 
K

Kenneth Tilton

Maahes said:
hmm. I remember vividly doing lisp at uni.
I think the assignment was a simple long division problem. I remember that
only a few people in the entire class managed to work out a way of achieving
it... I problem that is a newbie would do in C without breaking a sweat.

Post the C version (or just give a fuller spec) and I'll try it in Lisp.

After that, no-one ever used lisp again...

..except the Jax & Daxter developers. Their game engine runs on an
interpretted lisp platform (I believe) and has spawned some of the most
impressive platformers I've ever seen...

So the moral is....
I don't know, but I won't be switching to Lisp any time soon...
Maybe its good once you get the hang of it...
But I think it may be too recursive & bottom-up programming for most brains
to want to deal with...

I wonder which Lisp you were using. The modern Common Lisp has all kinds
of ways to iterate, some simple, some complex, and one (LOOP) which is
effectively a built-in iteration mini-language. So no one is forced to
do recursion, and many Lispniks frown on it style-wise if an iterative
approach would work.

Recursion takes a while to get the hang of, but not long and then it can
be quite elegant.


kenny
 
T

Thomas Matthews

Neo-LISPer said:
Hey

Recently, I researched using C++ for game programming and here is what
I found:
[Snip -- This section already commented on by others elsethread.]
It is my opinion that all of the above makes C++ a very bad choice for
commercial game development.
It is your opinion and you are welcome to it.

My observation from watching shows on video games is that there
are only a handful of different types. My guess is that the
engine is written in some language, Pascal, C++, Lisp, and
each "level" is written in a higher level language. Once the
engine is working, they don't change it. Most of the changes
are made using the higher level language. A video game project
doesn't want its time wasted in coding up each level in C++,
C, Pascal, Ada or whatever. A less time-consuming method is
to write each level using a higher level language. Many
game shops have specialized languages for their engines.

Perhaps you need to learn that the choice of the language
is not the issue. The issue is the quality of the product
that one can produce using the given language. If the
shop dictates that assembly is the language, then the
company must produce the best quality product using
assembly. In many shops, there is no choice on which
language can be used. You use their language and live
with it.

So if you are independently developing games, then by
all means, use the language you are most comfortable
with. However, do the rest of us a favor and keep
your opinions of other languages to yourself. The
issue of the "best" language for a given project is
and will always be a religous issue.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
M

M Jared Finder

Neo-LISPer said:
Hey

Recently, I researched using C++ for game programming and here is what
I found:

While I personally prefer Lisp for my side projects, C++ is not an
absolutely horrid language for game development. It is definitely much
better than C; overloading operators and templates allow a "weak man's
macro system" and virtual functions provide some much-needed dynamicness.
C++ game developers spend a lot of their time debugging corrupted
memory. Few, if any, compilers offer completely safe modes.

Why must both sides of the garbage collection debate go to such extremes?

Pro-garbage collectors say that garbage collection prevents all resource
leaks. I know that this is not true as I have seen many resource
"leaks" occurring because the programmer forgot that some part of the
code would hold a reference to some data.

Anti-garbage collectors say that garbage collection is fast, but with
unreliable slowdowns. While this is true, I have found that in
application development, the slowdown is not noticeable at all. I view
arena allocation and deallocation as a more game-centric garbage
collector, which works quite well in many games.

On the whole, I find that I rarely need garbage collection in my
programs. But when I do need garbage collection, I *really* need it. I
think Lisp is right here to default to the more general solution
(garbage collection) unless you explicitly tell it otherwise.
Unsurprisingly, there is a very high failure rate among projects using
C++ for modern game development.

There is a very high failure rate among modern game development
projects, period. I don't think this has as much to do with the
programming language as it does with insane schedules/no real
direction/increased expectations. This is improving. Supposedly.

That doesn't mean that using a more high level language wouldn't speed
up development -- it would.
You can not even change function definitions while the program is
running and see the effects live (the ultimate debugging tool).

Alternatively, you can't execute a small portion of the program
without compiling and linking the whole thing, then bringing your game
into a specific state where your portion of the code is being executed.

A REPL debugging mechanism allowing function definitions is extremely
cool. If it had an integrated unit-test tester, that would be super
good. It's so good that I find myself implementing a half-assed REPL
test loop for any language which doesn't have a built in one. In C++ it
looks like this:

void functionToTest( int a, string& b );

int main() {
int a;
string b;

while( true ) {
BKPT();
functionToTest( a, b );
}
}

Every reasonable debugger will let me change the values of a and b.
It's a Read, Eval, Print Loop with out the Reading. :p
The static type system locks you into a certain design, and you can't
*test* new ideas, when they come to you, without redesigning your
whole class hierarchy.

I can't comment on this one way or the other, as I only have a few
months experience with Lisp. My guess is that the implicit interface
will prove similarly difficult to modify with Lisp as the static type
system does with C++.

Any eXtreme Programming Lispers or C++-ers care to comment?
C++ is so inflexible, even those who do use it for games, have to
write their game logic in some other language (usually very slow,
inexpressive and still garbage collected). They also have to interface
the two languages.

This is a very valid point. Game logic is one of the most obvious
applications of a REPL and function redefinition at runtime, which is
why many games use a language such as Python that supports such
features. As stated above, this is a great feature for *any* part of
development.
C++ lacks higher-order functions. Function objects emulate them
poorly, are slow and a pain to use. Additionally, C++ type system does
not work well with function objects.

Really? I find that function object emulate higher order functions
extremely well. It would be nice if the dispatch on them could be
either static (using templates and overloading) or dynamic (using
virtual functions), but it's simple to create such a library.

The main problem I have with function objects is that writing a separate
class is distributing logic in a way that's both confusing and annoying.
I should not have to write a separate class for this one function when
all the logic for that class is available to the compiler.

I already know about Boost.Lambda and I have found it to be impossible
to use. Every time I make a little change in my lambda function, I get
tons upon tons of errors. I last tried to use Boost.Lambda about a year
ago; has it improved its usability?
C++ programs can not "think" of new code at run-time, and plug that
new code into themselves in compiled form. Not easily, anyway.

I assume you are thinking about closures like cl-ppcre uses. While this
is doable in C++ using template meta-programming, it's so convoluted to
not be usable. C++ really needs a macro system like Lisp's.
C++ coding feels very repetitive, for example, when writing class
accessors, you often have to write const and non-const methods with
completely identical function bodies. Just look at STL.

A better macro system would help here again. I know that I'd much
rather write:

DEF_ACCESSOR( int foo(), { /* code */ } );

than

int foo_impl() const { /* code */ };
int foo() const { return foo_impl(); }
int foo() { return foo_impl(); }

The first is just more to the point.
When programming in C++ you feel like a blind person trying to draw
something. You don't _see_ the data structures that your procedures
will operate on. Lisp programming is much more visual.

I have no idea what you are saying here. Can you give an example of a
problem where the solution in Lisp is much more visual than in C++?
Constructors and smart pointers make it hard to tell cheap operations
from expensive ones.

Any language with flexible abstractions is going to have this problem.
Can you tell me if foo() is faster or slower to execute than bar(a,b)?
C++ lacks automatic memory management and so it encourages copying
objects around to make manual memory management manageable.
Reference-counting schemes are usually slower than modern garbage
collectors and also less general.

See above for my feelings on garbage collection.
Most important, C++ syntax is irregular, and you often find yourself
typing repetitive patterns again and again - a task easily automated
in languages with simpler syntax. There are even books on C++
patterns, and some C++ experts take pride in being able to execute
those patterns with computer-like precision - something a computer
should be doing to begin with.

I agree here as well. C++'s syntax is awful, and its deduction rules
are even worse. This made Boost.Lambda to be such a pain to use. A
good macro system would help here as well.
C++ programs are slow: even though the compilers are good at
micro-optimizing the code, programmers waste their time writing
repetitive patterns in C++ and debugging memory corruption instead of
looking for better algorithms that are far more important for speed
than silly micro-optimizations.

As stated before, macros would be nice. Unlike template meta
programming, I find that quasi quotation macros make sense.
It's hard to find good programmers for C++ projects, because most of
the good programmers graduated to languages like Lisp or avoided C++
altogether. C++ attracts unimaginative fellows with herd mentality.
For creative projects, you want to avoid them like a plague.

It seems to be quite easy to find good programmers for C++ projects.
It's hard to find great C++ programmers; the kind that think outside the
proverbial box. Lisp seems to encourage such thinking by its very
nature of being a programmable programming language. They're there, but
they are also much more rare.

If this is a good or bad thing is left to the company
It is my opinion that all of the above makes C++ a very bad choice for
commercial game development.

Since you stated many strengths of Lisp, it is natural that on most of
these statements, Lisp is better. On the whole, Lisp and C++ are very
similar (except with regards to macros), Lisp and Python/Java/C#/your
favorite dynamic language even more so. Lisp and C++ just take
different approaches to what the default assumption should be:

Lisp tries to assume the most general, and let the programmer specify
specifics when the generic solution is too slow. Lisp prematurely
pessimizes.

C++ tries to assume the fastest possible thing, and let the programmer
specify generics when needed. C++ prematurely optimizes.

So which is worse? Premature optimization is the root of all evil, but
premature pessimization is the leaf of no good. I prefer to start with
the general case and then optimize the hell out of it if needed, but
other programmers differ.

-- MJF
 
F

Florian Bachmann

JKop said:
Ignorance? Arrogance maybe? (no pun intended)

As for the issues raised being truly something you need to know about... do
you need to tell a child not to eat its own excrement? No. Why? It figures
that out for itself. If you're writing code and you have "new" all over the
place and you've no "delete"'s, then you'll figure out the aim of the whole
"Garbage Collection" ideal. I myself am not retarded, so I've no need for
"Garbage Collection". If, hypothetically speaking, I forsaw that I would
temporarily become retarded (a golfclub to the head maybe), then I would
make use of auto_ptr, but that has yet to happen.

Isn't great how we're all entitled to our own opinions! ;-P


-JKop

Garbage Collection is not just for the retarded -- it becomes sort of an
requirement when dealing with lock-free collections, for example. And
you are wrong to believe that your programs won't leak memory just
because you aren't retarded.


Regards
 
L

Lisptracker

JKop said:
AKA Retarded mode.

With C++ you can't vary safe/fast mode on per function or per line
basis.
Nothing to do with the language. Such a debugging tool could be developed,
why not develop it?
I myself wouldn't use it.

Actually, you can change program during execution (at least in VC++
7.1) however in half of cases you have to stop and recompile it.
That's because there's no such thing as "half a program". If you really want this, copy-paste it to another file and just append:

int main(){}
to the end of it.

Than cut and add "main()" to another file and stop/start program each
time ??? In Lisp you can share intermediate data between small
portions of the program.
Bullshit. Vague bullshit.

You forced to think of types all time. It's kind of unnecessary
foresight in many cases.
Provide an example. I myself forsee no reason or motive to do or have to do > this.

You have to use interpreter for scripting. Hardly It would be
interpreter of C++.
"function objects". Get over it! It's just syntatic sugar!

Really? IMHO they are very limited imitation of closures.
"think of new code at run-time". That's because it takes intelligence to
write code, something which computers lack. As for the code coming from
somewhere else, well it's done extremely easily actually - we call it
dynamic linkage.

I.e. C++ self-reflection sucks.
Incorrect.

If both function bodies are identical, then there's no need to write a non-
const version.

If there exists both a const version and a non-const version, then this
indicates that one version alters the object, while the other doesn't.
Conclusion: different code.

So "cut and paste" technology is used all time ;-))
You could also make the non-const version call the const version, and then
just do something extra.


"procedures"? Never heard of them. I've heard of "functions" alright. I must
say I don't... see... your argument, no pun intended.
If you have a function which takes in an object of a certain class, or as
you call it "data structure", then... (actually, it's so simple I'm not even > going to finish this paragraph).

It means that on Lisp you can easily try current piece code to see it
does well and write another small piece. In C++ you forced to write as
much as possible before you start visualize results (maybe because
"edit and continue" doesn't work properly?).
int auto k = 4;

int* auto p_w = new int(4);

From MSDN:

"The auto storage-class specifier declares an automatic variable, a
variable with a local lifetime. It is the default storage-class
specifier for block-scoped variable declarations

An auto variable is visible only in the block in which it is declared.
Few programmers use the auto keyword in declarations because all
block-scoped objects not explicitly declared with another storage
class are implicitly automatic. Therefore, the following two
declarations are equivalent:

// auto_keyword.cpp
int main()
{
auto int i = 0; // Explicitly declared as auto.
int j = 0; // Implicitly auto.
}
"
Is that automatic memory managment ???
Which "garbage collector"? "less general" = vague bullshit.

What's the difference ??? Anyway reference-counting is slower than
modern generational GCs.
I don't see your argument. I've never encountered such.

It means no macro. C preprocessor and templates is hardly comparable
with Lisp macro.
MS-DOS was written in C++. Window XP was written in C++. Linux was written
in C++.

Come to think of it, what *wasn't* written in C++?

You are mistaken: MS-DOS and Linux were not written in C++ (maybe
because C++ compilers at that time were very buggy). And also very
doubtful that Windows XP core was written in C++.

Many many things were not written in C++.

Lisptracker
 
J

Joe Laughlin

JKop said:
Really? What was it written in?



-JKop

C and assembly. Look at the source for it.

And I don't think MS-DOS could've been written in C++, wasn't that before
C++ was around?
 
P

Petter Gustad

Joe Laughlin said:
And I don't think MS-DOS could've been written in C++, wasn't that before
C++ was around?

The first native C++ compiler I used under DOS was Zortech C++. This
must have been around 1988/1989.

Petter
 
H

Howard

Personally, I couldn't care less! What're you trying to accomplish, change
someone's mind? No, you're just trolling. So get lost, and let us do some
real work.

-Howard
 
D

David Golden

"Neo-LISPer" has been quoting the "Mike Cox" known-troll in his sig in
some previous postings to comp.lang.lisp [1] I gave him the benefit of
the doubt for a few posts, but that might tell you where he's coming
from if you've encountered "Mike Cox" trolling before. For some reason
"Mike Cox" started attempting to troll comp.lang.lisp a while back,
too, it's even possible Neo-LISPer and Mike Cox are the same person.

Note that it may more innocent (even if it is Mike Cox!), could be just
the overenthusiastic lisp newbie effect (no one more zealous than the
recently converted) - if so, then, Neo-LISPer, please don't do that.
Two wrongs don't make a right [2].

I urge people in both language communities to write games in whatever
languages they bloody well feel like, and to not feed the trolls. Like
I probably just did by posting this. Gaah.

[1]
http://groups.google.com/groups?q=g...ie=UTF-8&[email protected]&rnum=1

[2] See recent silly "Why Lisp Sucks for Games" thread on comp.lang.lisp
caused by an article by someone self-identifying as a microsoft c++
programmer and apparently feeling some compulsion to attack (somewhat
poorly) the use of lisp in games. Or, better, don't...
 
J

JKop

Florian Bachmann posted:
Garbage Collection is not just for the retarded -- it becomes sort of
an requirement when dealing with lock-free collections, for example.
And you are wrong to believe that your programs won't leak memory just
because you aren't retarded.


Regards


Perhaps. But I've been right thus far.


-JKop
 
T

Thomas Stegen

JKop said:
Ignorance? Arrogance maybe? (no pun intended)

As for the issues raised being truly something you need to know about... do
you need to tell a child not to eat its own excrement? No. Why? It figures
that out for itself. If you're writing code and you have "new" all over the
place and you've no "delete"'s, then you'll figure out the aim of the whole
"Garbage Collection" ideal. I myself am not retarded, so I've no need for
"Garbage Collection". If, hypothetically speaking, I forsaw that I would
temporarily become retarded (a golfclub to the head maybe), then I would
make use of auto_ptr, but that has yet to happen.

Depending on the amount of memory and the size of each allocated block
garbage collection can be faster, or manual handling can be faster. If
you have many small to medium sized objects then garbage collection is
faster, otherwise not so. Copious amount of research exist. Start
some where around here:http://www.hpl.hp.com/personal/Hans_Boehm/gc/.

Retarded? It has nothing to do with being retarded. Sometimes the
requirements of a program is such that you cannot predict when a
resource can be freed without designing this into your program
(I can't really think of many examples where this is not the case)
and that can be hard. When GC can sometimes even make your program
faster... No brainer. (And for the reading impaired, I am not
saying... Nah, figure it out yourself)
 
J

Joe Laughlin

Petter said:
The first native C++ compiler I used under DOS was
Zortech C++. This must have been around 1988/1989.

Petter

And MS-DOS was first written in the early 80's.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top