Wondering why ID choosed C for Quake 3 instead of C++
#1
Posted 10 May 2010 - 04:27 PM
First, I'm not a very experienced programmer, but I know C and C++, maybe not the advanced stuff.
Since ID software released of the quake 3 source code, I was wondering why they used C instead of C++.
Is there a real advantage of working with plain C, meaning not dealing with abstract stuff ?
I know the object concept can be great, by I never really understood the real advantage of C++, since it depends of the programmer's way of solving a problem...
I already asked on a french forum (which was closed for reasons I don't really know, maybe they could not really answer, but apparently they did not like my tone, you know the french...)
Thanks for reading :)
#2
Posted 10 May 2010 - 04:42 PM
You can download the sourcecode for Doom, and compare for yourself :)
As for using C++ over C, features like templates and dynamic binding make it easier to use, imho.
#3
Posted 10 May 2010 - 04:48 PM
#4
Posted 10 May 2010 - 05:55 PM
#6
Posted 10 May 2010 - 06:45 PM
1. c may have been more portable than c++ at some point
2. without message passing, c++ isn't really objected oriented anyway, and one can write fairly object oriented style code in c.
#7
Posted 10 May 2010 - 11:27 PM
martinsm said:
The reason they were using C was performance considerations and simply because "they've always been coding C".
tobeythorn said:
-
Currently working on: the 3D engine for Tomb Raider.
#8
Posted 11 May 2010 - 12:53 AM
In my opinion, message passing is a requirement of encapsulation. If telling a object to do something that it doesn't understand can break a program, then the object isn't completely encapsulated. Furthermore, since c++ doesn't natively support reflection or dynamic typing, the programmer must always be aware of exactly what class each object is, which doesn't seem like pure encapsulation to me either. The point is that c++ really isn't much different from c, just sometimes more convenient.
In c we would write...
Rabbit* myRabbit = rabbit_new(); rabbit_run(myRabbit);
In c++ we would instead write...
Rabbit* myRabbit = new Rabbit(); myRabbit->run()
Are these not exactly the same?
#9
Posted 11 May 2010 - 01:51 AM
|myRabbit| myRabbit := Rabbit new. myRabbit run
in Smalltalk is exactly the same as the two examples you posted. Does it really matter whether you call what's going on "message passing" or "calling a method"? It's all the same when you get down to it.
IMHO, the core concept of object orientation is that some data (an object's state) and code (its behaviors) are tightly integrated and presented as a unified component (an object) to the outside world. Languages can support this model to a greater or lesser extent. C++ doesn't fail to be object-oriented just because it doesn't take the idea to some (il)logical extreme.
#10
Posted 11 May 2010 - 02:07 AM
No, I don't think so. In all three example the grammar is essentially identical. However, the underlying behavior of message passing is different, even though it does involve a function call. In contrast, the underlying behavior of both the c and c++ example I gave is the same.
I think that your definition of object-orientation is both fair and de facto. C++ is then clearly an object orientated language. However, I think most people do include encapsulation in their definition.
#11
Posted 11 May 2010 - 10:00 AM
On the other hand, if your compiler *let* you pass a message the object doesn't understand, it could easily break your program.
I have been working with Objective C the last few weeks, where you call methods in objects and the runtime decides if the method is supported or not for the speciffic object.
I really can't see how it is any better to use lots of void* (which is what Objective C does) instead of base class pointers, where you *know* exactly what methods you can call.
#12
Posted 11 May 2010 - 10:10 AM
2. It's possible to understand everything about C. I'm not quite sure if the same can be said about C++. It feels like I keep forgetting more obscure things about C++ than I learn.
3. C++ has plenty of hidden overheads that also may vary from platform to platform or compiler to compiler.
4. Since C is older, the compiler optimizations have had more time to mature.
5. Preferences.
6. Basing designs on C++ doesn't mean they automatically become easier, clearer, faster to develop for. Just look at Symbian.
Before I moved from C to (majorly) C-With-Classes C++ coding, my code was already turning very much class-like (storing states in structures that were passed along etc). If C++ had not been available to ease my typing, I'm pretty sure I'd continued the same route.
#13
Posted 11 May 2010 - 10:56 AM
#14
Posted 11 May 2010 - 12:36 PM
Sol_HSA said:
I think that argument is mostly void, and the contrary is the case: Because C++ is mostly compatible to C, a lot of C++ code can benefit from those optimizations. And because C++ offers additional and very powerful tools, it has even more stamina in optimization.
~/www/ | picogen.org | metatrace
- --- / .-.. . - / -- -.-- / ... .. --. -. .- - ..- .-. . / .- .--. .--. . .- .-. / --. . . -.- -.--
#15
Posted 11 May 2010 - 03:09 PM
rouncer said:
Actually, according to Carmack himslf the Quake I/II/III engines are supposedly written in an object oriented "style".
I'm not really sure what that means.
#16
Posted 11 May 2010 - 03:42 PM
tobeythorn said:
In my opinion, message passing is a requirement of encapsulation. If telling a object to do something that it doesn't understand can break a program, then the object isn't completely encapsulated.
Quote
Quote
Besides, it would be very easy in C++ to devise objects that actually uses message passing rather than method calling, if you find that more attractive. But that doesn't make it any more OOP.
Quote
Quote
Rabbit* myRabbit = rabbit_new(); rabbit_run(myRabbit);
In c++ we would instead write...
Rabbit* myRabbit = new Rabbit(); myRabbit->run()
Are these not exactly the same?
-
Currently working on: the 3D engine for Tomb Raider.
#17
Posted 11 May 2010 - 03:49 PM
Before that, ASM was the main language of choice for games.
#18
Posted 11 May 2010 - 04:03 PM
Quote
In non-message passing environments, if I have an array [snake, elephant, bird] and want to call a function move() on each element of the array, I can't without an unnecessary mess, without explicitly casting (which is just a fancy way of calling an explicitly different method for each), which means that I really do have to know about the guts of the objects, and not just their interfaces. Sorry, but to me that is just not encapsulation.
#19
Posted 11 May 2010 - 04:26 PM
#20
Posted 11 May 2010 - 04:38 PM
Quote
That's just using an abstract. Every OO language does that. You don't recast, you just put all the objects in a base class container and call the abstract function.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


This topic is locked









