The C Language
3 posters
The C Language
I am wondering why C was the language used here. I am in the process of implementing the use of IPO curves into SIO2. I want to be able to have SIO2 handle IPO curves for lights, cameras, and meshes using the same code. This would work wonderfully if all three of these objects inherited the same base object. Only problem is that the way the C code is written each object cannot be handled with the same code becuase each object is different.
I am coming up with a solution that works around this C limitation but I am just wondering what decision caused you to use purely C.
I am coming up with a solution that works around this C limitation but I am just wondering what decision caused you to use purely C.
bucket- Posts : 4
Join date : 2008-10-07
Re: The C Language
Well for the IPO it is still pretty easy to implement. In example SIO2curve and after that simply add a SIO2curve* to the SIO2camera, SIO2object, SIO2light structure and that's it... I don't see why C++ should be used here...
The reason why C is mainly of speed and control... more low level you got more fast your code will run and well let's just say that I don't have the patience to write the code is ASM so I go for C
The reason why C is mainly of speed and control... more low level you got more fast your code will run and well let's just say that I don't have the patience to write the code is ASM so I go for C
Re: The C Language
Okay, just wondering why C was chosen. I can see the desire to have a speed boost. I hope I didn't come across like I was trying to pick out problems with the engine. Although it still has some development to go through, I find it to be really a great tool to build games with.
I don't want to sound like I am knit picking the engine but is performance the reason why loops are written like this.
instead of this
I don't want to sound like I am knit picking the engine but is performance the reason why loops are written like this.
- Code:
i = 0;
while (i != cap)
{
++i;
}
instead of this
- Code:
for (i = 0; i != cap; ++i)
{
}
bucket- Posts : 4
Join date : 2008-10-07
Re: The C Language
Because when I profile with shark I found out that for was slower using a 32bit int than a while using the approach that I include everywhere... and probably faster to unroll as well... ++i is faster that i++ while != give same performance as == and is faster than <, >, <=, >= of course comparison with 0 is the best but for loop well not really convenient... I mean think in ASM how you would code it... and you'll see that its kinda of obvious
Another thing why C more than C++ is the constructor, with class you need to init all variable to 0 with C struct 1 line of code using calloc is good enough. Also to resize **, with class its a pain in the !@#!*@ to do so with C a simple realloc would do and this is use ALOT in a game engine, since practically every structure are dynamically generated in run time etc... I think also C is more clean in general, more short straight to the point and ANSI ISO 99 (what Im using) is compatible with every compiler on this planet (well almost ). All the library that Im using: OpenGL, OpenAL, jpeg, lua, zlib, theora, ogg are all in pure C only Bullet is C++, but its standard as well and cross platform so it's ok I think, but if the C API of Bullet where more developed and if Bullet can use fixed point math well SIO2 will be in heaven
Theses are some of my thoughts and opinion, I don't want to start a debate thread here allright
Another thing why C more than C++ is the constructor, with class you need to init all variable to 0 with C struct 1 line of code using calloc is good enough. Also to resize **, with class its a pain in the !@#!*@ to do so with C a simple realloc would do and this is use ALOT in a game engine, since practically every structure are dynamically generated in run time etc... I think also C is more clean in general, more short straight to the point and ANSI ISO 99 (what Im using) is compatible with every compiler on this planet (well almost ). All the library that Im using: OpenGL, OpenAL, jpeg, lua, zlib, theora, ogg are all in pure C only Bullet is C++, but its standard as well and cross platform so it's ok I think, but if the C API of Bullet where more developed and if Bullet can use fixed point math well SIO2 will be in heaven
Theses are some of my thoughts and opinion, I don't want to start a debate thread here allright
For performance
For performance, you should reverse the loop:
i = n;
while ( i )
{
--i;
}
That way you can do the comparison with 0.
But beware off-by-one errors, and careful if n == 0 to start...
kb
i = n;
while ( i )
{
--i;
}
That way you can do the comparison with 0.
But beware off-by-one errors, and careful if n == 0 to start...
kb
kevinbutler- Posts : 1
Join date : 2008-10-16
Permissions in this forum:
You cannot reply to topics in this forum
|
|