C++ sucks for games

M

Michael Naunton

Just for pig-iron, I wrote a clone in C++ today, based on your
description (I can't run yours). Took about the same time! Likewise,
it's not production code (in particular, it will crash if it's given no
images at all - I should have fixed that at least).

Thanks for taking the time to do this: it was interesting to look at
your version. My original code also failed with no images -- I added
a test to drop to the debugger in that case right before posting the
code.
The two might be an interesting comparison for readers of the thread.
My version is for an MFC dialog app. I left out most of the AppWizard-
generated boiler plate i.e. a CWinApp-derived class whose files I didn't
open at all, and a CDialog-derived class where I only added code to one
function. All my actual code is in the text file:
http://bindweed.com/misc/concen-src.txt

There is some bitmap-twiddling done by my DibDC class (not included),
but your version makes external calls to do the same thing, so I figure
that's fair.

Seems fair to me.
I was surprised to find it is actually shorter than the Lisp version in
terms of characters, though it has more lines (a lot have just one curly
bracket). I was sure it would be longer, especially since I did some
things in quite a roundabout and repetitive way.

Note that one third of the Lisp code implements a simple event loop
(code to call a redraw function and a user-input function.) I included
it for completeness, but it's just library code like your MFC framework.
I think, anyway, correct me if I'm wrong.
Those who want can download the 148 KB Windows executable from:
http://bindweed.com/misc/Concen.exe

This is a clear win for the Win/C++ code: providing a Linux/Lisp
executable would be 10 times the size. This is the classic exe vs.
big runtime environment issue.
Just pop it into a directory along with some .bmp files of any size
(there must be at least one or it will crash). It's quite fun! When
you've solved the puzzle, you have to close it and run it again for
another. Perhaps I'll tidy it up a bit, add a few options and sfx and
release it as a freeware...

Hehe, I quite agree with you here: as dumb as the game is, it's
actually fun to play: I've actually played it several times over the
past few days. Ah, the satisfaction of getting a tile right when you're
not quite sure :)

I have a couple of questions about extensions to this problem, e.g:

o Make it a two player gmae (i.e. fail to flip a pair and the other
player gets to turn card.)
o Make it a net game (serve over http?)

It seems to me that the first case can be handled well by just hacking
code, but the seond case requires a major rewrite (we're using a code
generator, and must add our code to its framework as text.)

Regards,
-- MMN
 
J

Jacek Generowicz

Michael Naunton said:
.


This is a clear win for the Win/C++ code: providing a Linux/Lisp
executable would be 10 times the size. This is the classic exe vs.
big runtime environment issue.

Funny, the 148 KB executable fails run on my computer.

Oh, you mean I need to install the big Microsoft Windows and MFC
runtime environment first, and only then can I run the 148 KB
executable on top of that?

And how does this differ from first installing a big Lisp runtime
environment, and then running a small fasl file on top of that?

All this alludes to, is that more computers have some C++ runtime
support installed on them by default, than is the case for Lisp.
 
G

Gerry Quinn

Argument by analogy! I love these!! Seriously, I checked out your web
site, and I think it might be helpful to turn the challenge "Show me the
Lisp game!" around: what exactly do you think Lisp might not be able to
handle in writing such games? The logic? The graphics? The GUI?
Performance? Other?

My biggest concern (leaving pure language and re-use considerations out
of it) would be easy integration with standard Windows controls and
features. I would also require the creation of reasonably compact
downloadable .exes that would work reliably on just about any Windows
machine, and would not require downloading of added libraries or
environments.

Compare Java, as an example. I could write all my games in Java, though
two of my screensavers would be unusably slow. But the buttons would
look odd and to my mind ugly, unless I messed around with an interface
to the native API. And many people would need to download a runtime.
Even if I preferred Java to C++ (and in fact I prefer C++) I would not
use it unless it had major advantages for some purpose. (I've done some
applets.)
After all the ranting about how different is Lisp, at one level it
really is just a conventional HLL, with functions, iteration, objects,
structures, arrays, etc, etc.

All your games could be done easily in Lisp, and because Lisp is so much
more productive you could put more time and energy into the graphics and
gameplay logic and still finish sooner.

But this is the thing - you go on about how Lisp is "so much more
productive" but there's no evidence of it! My 'Concentration' clone
(see else-thread) is about the same length as Michael Naunton's and took
about the same time to write. No doubt each one has its own advantages,
and might be more or less comprehensible to any given person. But the
key point is that IT DOESN'T MATTER. The time it takes to sling
together a few algorithms and produce a basic pre-designed game is
insignificant. Even if Lisp were ten times more productive in this
regard, it wouldn't make any difference. Produce a finished reasonably
original game, even a small one, and see!

Productivity in messing around with small programs that are not for
general release is not really an advantage. I'll grant you there is a
bit more cruft in a typical small C++ program, but that may be because
we typically start off in a more basic environment. In the long run,
all that matters is that we can keep the amount of visible cruft within
reason all the way to the finished product.

Call it prejudice if you like, but I *trust* C++, like C before it, to
not fail in this regard. Even for apps much much bigger than mine.

- Gerry Quinn
 
G

Gerry Quinn

I don't think, that a screen saver is a good choice for any
serious program. It occupies the whole screen, when it is
running, therefore it does not allow one to work with the
computer the normal way. It also can not easily be monitored
with other programs at the same time, so I feel less secure
when running a screen saver. Moreover, it will not install,
when the windows size is less than 1024 x 768 - can't it even
rescale?

Like I said, the integration is not great, but it could be worse.
All I saw in the gallery was a parameterized picture:

A parametrised picture whose 'artistic' qualities are the matter at
issue.

- Gerry Quinn
 
G

Gerry Quinn

Thanks for taking the time to do this: it was interesting to look at
your version. My original code also failed with no images -- I added
a test to drop to the debugger in that case right before posting the
code.

I had an ASSERT, but did not bother to convert it into a run-time
test...
Note that one third of the Lisp code implements a simple event loop
(code to call a redraw function and a user-input function.) I included
it for completeness, but it's just library code like your MFC framework.
I think, anyway, correct me if I'm wrong.

Yes, they are both about the same size anyway. There's still some auto-
generated stuff in mine as well.
This is a clear win for the Win/C++ code: providing a Linux/Lisp
executable would be 10 times the size. This is the classic exe vs.
big runtime environment issue.

Probably not an issue for Lisp nowadays, as 1.5MB for a downloadable
executable is still nothing.
Hehe, I quite agree with you here: as dumb as the game is, it's
actually fun to play: I've actually played it several times over the
past few days. Ah, the satisfaction of getting a tile right when you're
not quite sure :)

I have a couple of questions about extensions to this problem, e.g:

o Make it a two player gmae (i.e. fail to flip a pair and the other
player gets to turn card.)
o Make it a net game (serve over http?)

It seems to me that the first case can be handled well by just hacking
code, but the seond case requires a major rewrite (we're using a code
generator, and must add our code to its framework as text.)

I think the first would be a good opportunity to refactor the code a
bit. It's about as hacky as I like to get now (look at my nasty 'tree'
of if..else statements). Putting in two or more well-defined 'player'
objects that can provide input to the 'game controller' in a standard
format would be easy enough. And then we see that the game controller
is actually a server, and the clients don't need to be local. So we are
on the right road to an internet game!

Another idea is a version in which you have to flip three at a time
(more would be overkill). This would be trivial to implement. (In fact
I'd lose a member variable, as m_FirstPick and m_SecondPick would join a
vector of picks.)

Gerry Quinn
http://bindweed.com
Games, Kaleidoscopes, Screensavers
 
W

William Bland

My biggest concern (leaving pure language and re-use considerations out
of it) would be easy integration with standard Windows controls and
features. I would also require the creation of reasonably compact
downloadable .exes that would work reliably on just about any Windows
machine, and would not require downloading of added libraries or
environments.

Windows? Are you serious? Do people really still use that monstrosity?

Cheers,
Bill.
 
P

Philippa Cowderoy

Windows? Are you serious? Do people really still use that monstrosity?

Only the vast, vast majority of home users, who're Gerry's target market.

Personally I use it because I'm a gamer, and to a lesser extent because I
can't be bothered to figure out how to duplicate my desktop setup under X.
I do seem to make a bit more of an effort to write portable code than
Gerry does though.
 
J

John Thingstad

Windows? Are you serious? Do people really still use that monstrosity?

Cheers,
Bill.

Have you ever developed commercially? lol
Only a academic can afford to ignore 80% of the market potential.

I like Lisp. I like CAPI. But what do I do when people ask as about mouse
scroll that
dosn't work or tool-bars that don't move.

I'd write the interface in Microsoft Visual C++.
Much hated but the origin of hundreds of thousand of commercial Windows
programs.
Tested and proven.

Quality assurance is also making sure that you environment can adapt any
needs you are likely to have.

Most of commercial code is boiler plate. It consists of calling functions
in some library. So for this Lisp is not much terser.
Sure Lisp is great for algorithm's, but this is just a small percentage
of the code in a commercial app.
More important, for conserving time, is how much time you need to
get to the necessary library functions. As such, I fear, Lisp
might well loose.

Totally depends on your app, of course.
For web based apps, Allegro 7 seems to fit the bill.
Still when it comes to Windows interfaces Lisp still has a ways to go.
 
W

William Bland

Have you ever developed commercially? lol

Only for eight years. I guess I'm still a bit of a newbie.
Only a academic can afford to ignore 80% of the market potential.

I haven't been an academic for eight years. None of my market is on
Windows.

OK, I'm sorry, the Windows thing was a cheap shot. I'm lucky enough to
work server-side, where users don't know or care what OS and programming
language you use.

Cheers,
Bill.
 
J

John Thingstad

OK, I'm sorry, the Windows thing was a cheap shot. I'm lucky enough to
work server-side, where users don't know or care what OS and programming
language you use.

Cheers,
Bill.

My last job was for Opera Software (www.opera.com).
Opera is a Web browser, mail/news and IRC interface.
There presentation is everything!
As you said. Different jobs, different experiences.
 
E

Espen Vestre

William Bland said:
OK, I'm sorry, the Windows thing was a cheap shot. I'm lucky enough to
work server-side, where users don't know or care what OS and programming
language you use.

Most (about 95%) of the users of the end-user program I'm the main
developer of, use Windows. But I rarely do development on Windows,
I do most of the development of that application on linux, and some
on my Mac laptop. The cross platform wonder that let's me do this
is Xanalys LispWorks :)
 
B

Bulent Murtezaoglu

EV> [...] But I rarely do development on
EV> Windows, I do most of the development of that application on
EV> linux, and some on my Mac laptop. The cross platform wonder
EV> that let's me do this is Xanalys LispWorks :) -- (espen)

I second that. Apart from some sound etc. bits that requires #+win32
I've had the same pleasant experience. You pay twice the price for this
convenience, of course (LW pro in both platforms) but it is worth it.

One of these days I'll figure out how to get a dos/shell window from
windows under vmware in an xterm on the linux host and I'll be able to
go from 'it works' to exe w/o seeing the windows desktop.

cheers,

BM
 
S

Sashank Varma

Gerry Quinn said:
But this is the thing - you go on about how Lisp is "so much more
productive" but there's no evidence of it!

There is this website called Google where you can go
and type things like "lisp comparison C++" and it
lists relevant web pages and if you click on the
links you can go to those web pages and read
what others have said on the issue. When I typed
that query, Google responded that there were no
matches, proving that you're right...er, no, wait,
it did find a number of matches. So I clicked on
a few and found some interesting, honest evaluations.

http://userpages.umbc.edu/~bcorfm1/C++-vs-Lisp.html
http://www.lisp.org/table/compare.htm
http://www.python.org/doc/essays/comparisons.html
http://www.flownet.com/gat/papers/lisp-java.pdf
http://www.norvig.com/java-lisp.html
http://www.memorymanagement.org/articles/lang.html
http://http.cs.berkeley.edu/~fateman/papers/software.pdf
http://lemonodor.com/archives/000180.html
http://www.franz.com/success/customer_apps/data_mining/cadabra.lhtml

Those are from the first few pages that this website
called Google returns. I was unwilling to search
any longer for what I consider the most detailed
comparison of Lisp, C++, and Java by programmers at
an observatory looking for the best language in which
to continue software development. Maybe Googgle will
favor you with the link I could not find.
 
S

Sashank Varma

Gerry Quinn said:
A parametrised picture whose 'artistic' qualities are the matter at
issue.

And this differs from the art of any abstract
expressionist painter how?

If a formal model of painting is possible, then it
will be a parameterized function of some kind. The
point is this guy has produced the best such
parameterized function in existence, and he did it
in Lisp.

And this counts as evidence for C++ somehow?!

You have a real problem facing discomfirming evidence.
 
J

John Thingstad

Most (about 95%) of the users of the end-user program I'm the main
developer of, use Windows. But I rarely do development on Windows,
I do most of the development of that application on linux, and some
on my Mac laptop. The cross platform wonder that let's me do this
is Xanalys LispWorks :)

What exactly are you developing?
I seem to remeber something about an interface to the stock exchange in
Oslo
but seem unable to find it.
 
B

Bulent Murtezaoglu

SV> ... I was unwilling to search any longer for what
SV> I consider the most detailed comparison of Lisp, C++, and Java
SV> by programmers at an observatory looking for the best language
SV> in which to continue software development. Maybe Googgle will
SV> favor you with the link I could not find.

Well Google wasn't being very agreeable (the original link no longer
works) but a bit stubborn searching (having the orginal on file helped)
gave this link:

http://act-r.psy.cmu.edu/~douglass/Douglass/Agents/Lisp/psflang-report.pdf

If you had something else in mind, I'd also be very interested to read
that.

cheers,

BM
 
P

Pascal Bourguignon

Espen Vestre said:
Most (about 95%) of the users of the end-user program I'm the main
developer of, use Windows. But I rarely do development on Windows,
I do most of the development of that application on linux, and some
on my Mac laptop. The cross platform wonder that let's me do this
is Xanalys LispWorks :)

I suspect that most "MS-Windows Developers" work like that too.
Probably an important factor as why we see so many BSOD in public
appliances...
 
S

Sashank Varma

SV> ... I was unwilling to search any longer for what
SV> I consider the most detailed comparison of Lisp, C++, and Java
SV> by programmers at an observatory looking for the best language
SV> in which to continue software development. Maybe Googgle will
SV> favor you with the link I could not find.

Well Google wasn't being very agreeable (the original link no longer
works) but a bit stubborn searching (having the orginal on file helped)
gave this link:

http://act-r.psy.cmu.edu/~douglass/Douglass/Agents/Lisp/psflang-report.pdf

If you had something else in mind, I'd also be very interested to read
that.[/QUOTE]

No, that's the one. Thanks for the pointer.
 

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

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,667
Latest member
DaniloB294

Latest Threads

Top