C++ sucks for games

G

Gerry Quinn

Lisp is mature, older than C++ in fact.

Maturity of a technology is not a direct function of age. Where are the
IDEs, what is the standard version?
I can't buy the first sentence. What about the performance advantages of,
say, epxression templates for matrix arithmetic. Sounds sensible enough to
me.

To what percentage of programmers are such things relevant?
The development environment may well have been object-based. Do you
know whether or not the Lisp dialect the used was OO?

You know, from the description of Common Lisp, it's hard to tell!

- Gerry Quinn
 
G

Gerry Quinn

And absolute buzzword-induced foolishness. Object orientation and
interfaces does not have anything to do with the issue you mention. I
have no clue what "generic programming" is, but simply having
polymorphism and definable type hierarchies does nothing to indicate
_what_ it is some operator is supposed to achieve. The current project I
am on at work is a case in point. They don't comment or document their
code because they think that if you want to know what the code does,
just read it. Of course, that's utter nonsense. Documentation tells us
not what the code does, but what the point of some code is. No amount of
polymorphism will explain the design rationales and models behind some
API or language.


Then you shouldn't assume that it was something in the compiler that was
hard to understand and not some specially-designed operator in GOAL that
had semantics that weren't quite properly defined.

I don't assume that - in fact I mis-spoke when I said "development
environment" - I mean the GOAL engine.

On re-reading the article, however, it seems that what was meant was
that other programmers attempted to work on the engine itself but could
not, due to the obscurity of the code. So the engine interface may well
have been perfectly adequate, and I withdraw my comments above.

- Gerry Quinn
 
B

Bulent Murtezaoglu

[question and non-answer elided]

GQ> I think the nub of the issue is that, if you take away the
GQ> relatively useless ability to write self-modifying code,

I don't understand where this self-modifying code idea is coming from.
Do you mean the ability to write code that writes code? Self
modifying code, in the usage I am familiar with, means changing the
code (not data) in memory as the code itself runs. An example would be
changing jump destinations in running code by modifying the immediate
operand of the jump instruction to get home-made memory-indirect jumps
in ISA's that lack such things. These tricks may have been (ok were)
cute 15-20 years ago, but they tend to stall the deep pipelines in
modern processors. Perhaps the usage/meaning of the term has shifted
due to this?

GQ> what
GQ> Lisp is mainly good for is representing complicated
GQ> algorithms.

This is like saying "what lawyers are good for is winning cases."
(But to stretch the analogy, the lawyer in question lets you draw up
interesting contracts too).

GQ> But representing complicated algorithms is a
GQ> solved problem on any modern high-level language, and any
GQ> extra benefits from Lisp are likely to be minimal for 99% of
GQ> programming tasks.

I assume this 99% number is coming from the same place you got the
data about professional lisp users not finishing projects. But I
would agree that most programming tasks, where 'most' is measured
by headcounts, LOC or programmer-hours are indeed mundane.

The claim is that the extra benefits from Lisp come in handy (or might
even be essential in some sense) for _interesting_ programming tasks.
What I mean by 'interesting' are things the programmer and the
customer (and quite possibly anyone else) have not done/used before.
This doesn't necessarily mean researchy open ended stuff (where your
deliverable is not likely to be a finished program anyway.) It can
mean things that are just becoming practical (eg: viaweb and such) or
problems nobody really tried to re-solve with modern tools/knowledge
(eg ITA and such).

cheers,

BM
 
S

Svein Ove Aas

Gerry said:
Maturity of a technology is not a direct function of age. Where are the
IDEs, what is the standard version?
Allegro CL, Lispworks CL and other commercial Lisps have their own IDEs.
These may or may not be the best available, but they do have features the
standard Free IDE - Slime - doesn't.

The standard version is, of course, Common Lisp. CL isn't a
single-implementation language. (But then, neither is C++.)
 
G

Gerry Quinn

I've never seen so many arguments in a short
time frame that were basically like "I've never heard of this, I don't
know what it is, but I can assure you I don't need it." Yeah, sure...

It's a pretty valid argument, is it not? For all but evangelists,
anyway...

- Gerry Quinn
 
E

Edi Weitz

It's a pretty valid argument, is it not? For all but evangelists,
anyway...

I'd say it's a valid argument for someone who routinely refuses to
learn new things. But YMMV, of course.

Edi.
 
M

Maahes

Why do 99.99% of game companies use C & C++ instead of Lisp...
There's plenty of startup companies that could use Lisp if they wanted to...

It would be extreme arrogance to assume they're all just stupid...
 
C

Christopher C. Stacy

Maahes said:
Why do 99.99% of game companies use C & C++ instead of Lisp...
There's plenty of startup companies that could use Lisp if they wanted to...

It would be extreme arrogance to assume they're all just stupid...

It would not be arrogant to suppose that they are largely uninformed.
 
A

Alex Drummond

Quite the contrary -- the function is something radically different
from its arguments. Even if a function accepts other functions as
arguments, the function being invoked is treated and used entirely
differently from the argument(s).

"Belongs with" doesn't mean "is the same thing as". Functions and their
arguments still need to be grouped. If you have trouble distinguishing the
first element of a list from the other elements, you shouldn't be
programming.
First of all, you should be sufficiently aware of programming language
terminology to be well aware that this is NOT an example of an
ambiguity. It's true that the default precedence in C isn't always
right -- but it's NOT true that this leads to an ambiguity. The
meaning without parentheses may not be what you wanted, but that
doesn't mean it's ambiguous at all.

It's not ambiguous if you're a C compiler, but it is if you're a human who
hasn't memorised all the operator precedence rules.
C defines operator precedence that works correctly (at least by doing
some looking through my code) well over 95% of the time. Lisp never
requires parentheses to override default operator precedence, but only
because it throws out the baby with the bathwater -- rather than
requiring parentheses to fix the precedence in a tiny minority of
cases, it requires parentheses in _every_ case, no matter _how_
obvious the right thing to do is.

So what? C requires semicolons at the end of every line, no matter how
obvious it is where the break between two lines of code is. The difference
here is really only in arithmetic expressions. If you really want infix
arithmetic in Lisp, you can have it.
The do considerably more than that -- they (along with C's plethora of
other syntactical clues) provide enough differentiation that the eye
tracks it much more easily.

Not true in my personal experience. Lisp code is very easy to track because
its structure is explicit. C code is potentially very confusing (e.g. a
multiline else clause which is indenteded correctly, but which isn't
deliniated by { }).
With that given, tests have repeatedly shown that C is far more
readable than Lisp. Just for an obvious example, consider finding
problems in code, such as:

int fact(int x) {
if (x == 0);
return 1;
return x * fact(x-1);
}

and:

(define (fact x) (if (= x 0)
(1
(* x (fact (- x 1))))))

In my testing, C programmers find the problem in the C code an average
of more than five times as fast as Lisp programmers find the problem
in the Lisp code. In addition, C compilers almost universally give
SOME sort of complaint pointing (at least indirectly) to the problem
in the C code (typically pointing out the dead code) while Lisp
compilers (and interpreters, the last time I looked) generally accept
the latter code without so much as a peep.

This test didn't work for me, I spotted both errors in a few seconds. The
extra parenthesis in the Lisp code is /really obvious/ if you know the
language because 1 can't possibly be a function. As for compiler warnings,
if you translate this into Common Lisp and compile it with a good compiler
(e.g. SBCL) you certainly will get a warning. The quality of many Scheme
systems isn't as high in this regard.
Lisp hardly provides a suitable platform from which to launch such a
diatribe. Rather the contrary -- Lisp has more extra punctuation than
nearly any other language extant.

Depends what you mean by punctuation. It has fewer rules of punctuation, but
probably more punctuation characters (if you count the parens).


Alex


Jerry said:
(e-mail address removed) (Kaz Kylheku) wrote in message

[ ... ]
The function belongs with the arguments; enclosing it together with
them expresses this grouping.

Quite the contrary -- the function is something radically different
from its arguments. Even if a function accepts other functions as
arguments, the function being invoked is treated and used entirely
differently from the argument(s).

[ ... ]
But:

(obj.*pmemb)(x, y); // .* low precedence, parens needed!

Ooops.

If you move the function to the right of the parenthesis, these
ambiguities disappear.

First of all, you should be sufficiently aware of programming language
terminology to be well aware that this is NOT an example of an
ambiguity. It's true that the default precedence in C isn't always
right -- but it's NOT true that this leads to an ambiguity. The
meaning without parentheses may not be what you wanted, but that
doesn't mean it's ambiguous at all.

C defines operator precedence that works correctly (at least by doing
some looking through my code) well over 95% of the time. Lisp never
requires parentheses to override default operator precedence, but only
because it throws out the baby with the bathwater -- rather than
requiring parentheses to fix the precedence in a tiny minority of
cases, it requires parentheses in _every_ case, no matter _how_
obvious the right thing to do is.

[ ... ]
The text is in fact mostly words and spaces. The, punctuation, is,
quite, minimal, compared, to, C++, Pascal, Etc. What a waste of
keystrokes; what do the commas accomplish? They disambiguate things
like x, ++y versus x++, y.

The do considerably more than that -- they (along with C's plethora of
other syntactical clues) provide enough differentiation that the eye
tracks it much more easily.

Hopefully we can start by agreeing that to somebody who doesn't know
the language at all, that nearly every programming language is
_completely_ unreadable -- Cobol is the only thing that really even
tries, and one of its unique dangers stems directly from the fact that
people _think_ they understand it long before they really do. Neither
C, nor C++, nor Lisp, however, presents much danger in this regard.

As such, at least _some_ degree of familiarity with the language at
hand is required before "readability" really has much meaning.

With that given, tests have repeatedly shown that C is far more
readable than Lisp. Just for an obvious example, consider finding
problems in code, such as:

int fact(int x) {
if (x == 0);
return 1;
return x * fact(x-1);
}

and:

(define (fact x) (if (= x 0)
(1
(* x (fact (- x 1))))))

In my testing, C programmers find the problem in the C code an average
of more than five times as fast as Lisp programmers find the problem
in the Lisp code. In addition, C compilers almost universally give
SOME sort of complaint pointing (at least indirectly) to the problem
in the C code (typically pointing out the dead code) while Lisp
compilers (and interpreters, the last time I looked) generally accept
the latter code without so much as a peep.
One syntactic sdidiocy is patched over
with another. What a false economy; just so that you could have these
prefix operators and whatnot, you have to type extra punctuation even
when you are not using them!

Lisp hardly provides a suitable platform from which to launch such a
diatribe. Rather the contrary -- Lisp has more extra punctuation than
nearly any other language extant.

In any case, while counting keystrokes has some meaning when
evaluating calculators (yes, I still use HPs), typing in punctuation
on a normal keyboard rarely seems to be a real source of major
problems. If terseness is your measure of choice anyway, then any
choice other than APL seems nearly indefensible for you.
 
A

Alex Drummond

Only one set of game developers in that list.

So? Given that they were pretty successful, despite writing their own
compiler instead of using a production quality Lisp compiler, I think
they're good evidence that Lisp is a suitable language for games. The other
successes show that Lisp is good for complex programs in general.
Admittedly, if you don't want to write a complex game, Lisp might not be
much of an advantage.

And you might want to look at the complete list of successes
(http://www.franz.com/success/all_customer_apps.lhtml), where you can find
http://www.franz.com/success/customer_apps/animation_graphics/nichimen.lhtml.


Alex


Gerry said:
I am familiar with the basic concepts of Lisp, I am familiar with the
arguments in favour of Lisp put forward by enthusiasts, and I am
familiar with the generally weak profile of Lisp enthusiasts in terms
of
actually delivering product. The success of one group of talented
developers despite a plainly idiotic choice of development tools
notwithstanding. [I even quoted them, the Lisp users, to justify my
opinions.]

How many times does this have to be said?! Go to the website of a lisp
vendor and look at their success stories. For example:
http://www.franz.com/success/. Most of the projects listed there are
pretty interesting. It's ridiculous to suggest that we're basing our
arguments on the success of one set of developers.

Only one set of game developers in that list.

- Gerry Quinn
 
A

Alex Drummond

And the "bugs in GOAL's compiler" I guess shows that Lisp isn't even
prooven to be good for writing the compiler..

Don't be silly. You can't possibly expect a completely bug free optimising
compiler for a complex language to be written in a year. The fact that the
compiler was functional at all is a pretty good testament to the quality of
Lisp.


Alex
 
P

Philippa Cowderoy

Ok, thanx for the heads up.
So Jak and Daxter isn't even a proof that Lisp is useful for games, since
even those programmers decided they needed a variant for it to be useful...

Er, AIUI there's no one language called Lisp so that's not really a valid
statement. You might say Common Lisp isn't useful for games, or Scheme...
 
A

Alex Drummond

Lisp is mature, older than C++ in fact.
Maturity of a technology is not a direct function of age. Where are the
IDEs, what is the standard version?

The standard version is Common Lisp, which has been around for over a decade
(i.e. longer than the latest C++ standard). CL vendors mostly provide IDEs.
To what percentage of programmers are such things relevant?

Programmers who want high performance numeric code. Or programmers who want
to write a parser (http://spirit.sourceforge.net/). Both things which game
programmers will probably want to do at some point.
You know, from the description of Common Lisp, it's hard to tell!

GOAL is not Common Lisp. You should know that Common Lisp supports OO if
you've done even a smidgen of research. In fact it was the /first/ ANSI
standardised OO language. So in terms of being standard and being OO, it
pretty much beats C++.


Alex
 
A

Alex Drummond

[Reply to myself]

Grr, apologies for trimming the followups again. Please reply to this rather
than my original post...


Alex
 
R

Rahul Jain

Brian Downing said:
For example, I know of no editors that support
manipulating C structure at the syntactic level the way emacs lets you
work with S-expressions. Once you learn how to use these features it is
/very/ powerful. (And it spoils you - editing C is not very fun for me
anymore because of the lack of editor support I'm used to with Lisp.)

Yes, I am constantly irritated that I don't get a single conceptual
block (such as an entire for loop or a single addend in a summation)
with a single keystroke when I'm at work coding Java. I have to keep
grabbing bits until I get what I want and even then sometimes I end up
getting more than I want... This is one consequence of the obfuscation
of the syntactic structure of C code. The syntax depends on the
semantics. In Lisp, you just go to the matching paren and you have one
conceptual unit of code.
 
R

Rahul Jain

Maahes said:
Ok, thanx for the heads up.
So Jak and Daxter isn't even a proof that Lisp is useful for games, since
even those programmers decided they needed a variant for it to be useful...

This is how lisp always works. You customize the language to the
application domain, so that you can describe _what_ you want acheieved,
not _how_ you might want it done in some specific situation that may not
even be relevant to the final production application.
And the "bugs in GOAL's compiler" I guess shows that Lisp isn't even prooven
to be good for writing the compiler..

Of course, compilers written in C are always bug-free. Makes me wonder
why people were so afraid of using C++ back in the days when the
compilers were first being written.
 
R

Rahul Jain

Gerry Quinn said:
I don't assume that - in fact I mis-spoke when I said "development
environment" - I mean the GOAL engine.

On re-reading the article, however, it seems that what was meant was
that other programmers attempted to work on the engine itself but could
not, due to the obscurity of the code. So the engine interface may well
have been perfectly adequate, and I withdraw my comments above.

Fair enough. Compilers tend to be rather complex beasts, especially if
you don't understand the various optimizations they are implementing.
Would you expect an average programmer to be able to understand the code
of GCC? :)
 
M

matt knox

You talk about fashion (what language the mass uses) and claim that
the current most popular language is the best. Statements of that
form are rarely correct, and this particular one is spectacularly
wrong.

Instead of posting in this interminable (and mostly uninformed)
fashion, why not try to put your code where your mouth is? Pick some
problem that can be solved, without libraries, in some small
number-let's say 200-of lines of C/C++. Then I'll do the same in
lisp. Then we both solve both problems, and see how much
processor/memory/lines of code/time it takes for each of the 4
solutions.
 
D

David Steuber

Following up on myself :-/


I should be more careful about responding in the middle of the night
(or the edge or whatever). It actually took me a while to realize
that this function will always return 1.
In Lisp, it is also fairly trivial to use a technique called
tail-optimization. Scheme guarantees this by definition. Most Common
Lisp compilers also support it. The tail-call version of fact looks
something like this:

CL-USER> (defun fact (x &optional (a 1))
(if (< x 1)
a
(fact (1- x) (* x a))))

Because Emacs + SLIME shows you the arguments for a function, and the
accumulator variable that makes tail-calls possible is not really
supposed to be part of the interface, I've decided I prefer this
version (even though it is a bit longer):

CL-USER> (defun n! (n)
(labels ((fact (x a)
(if (< x 1)
a
(fact (1- x) (* x a)))))
(fact n 1)))
N!

I also like the name better.

CL-USER> (mapcar #'n! '(0 1 2 3 4 5 6 7 8 9 10))
(1 1 2 6 24 120 720 5040 40320 362880 3628800)

This also introduces the Common Lisp feature LABELS which allows you
to define local functions that can call themselves recursively.
 

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,205
Messages
2,571,067
Members
47,673
Latest member
MahaliaPal

Latest Threads

Top