I like C

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Apr 30, 2003 at 17:15

I like C. I prefer it over C++, or rather I like more of C than C++. Although I do use a mixture, It’s mostly C code. Anyone else?

52 Replies

Please log in or register to post a reply.

Fdbdc4176840d77fe6a8deca457595ab
0
dk 158 Apr 30, 2003 at 18:49

actually I like C++ more than C. C++ is my beloved language :)

49921baa7439fb1e91e02caf0a925cfe
0
DarkLight 101 Apr 30, 2003 at 19:28

I think object oriented languages are better for Game developing
I like object oriented languages more than procedural ones
Hence I like C++ more than C

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 May 01, 2003 at 17:18

that’s the only part of C++ I use - classes, for organisation. I don’t however use the more advanced OO things, like polymorphism etc. I can see how they would be useful. I definitely couldn’t write in pure C++ though unless I was being paid to

49921baa7439fb1e91e02caf0a925cfe
0
DarkLight 101 May 01, 2003 at 20:09

in one book of Game programming is written, that in game programming you should not ise these advanced things but keep code simple. However, I use classes and methods but I rarely use virtual ones

590e8bdac8129bd87b188df15e62d0e5
0
CyraX 101 May 02, 2003 at 11:17

I like to use C++ - for organization.
I would NEVER dare to use Polymorphism - slows down the code. Inheritance - Building hte parent classes before my beloved class is instantiated.
C is more mature than C++. You need C++ ONLY for enterprise applications where speed is secondary. In gamez we have speed as the primary thing.
Anyone else feels that same?
I dont use “new” rather use malloc.
Everything that dear Bjarn Stroustrup said was for enterprises… not for us game developers :rolleyes:

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 May 02, 2003 at 13:54

i object that speed is the primary concern in games. it might have been but times have changed and clean and easy to understand code has become more and more important as games and engines grow more and more complex. one good example is the nebula device from radonlabs. the virtual filesystem they created was only possible with oop. it’s just amazing to have every object, every texture, every mesh and shader accessible through the console ( look at it if you don’t know it, it’s a great engine ).
so, c++ is my prefered language. my general aproach when designing my code is to seperate it into two catogories.

  1. the code that is not speed sensitive, like loading resources, etc. here i use all the features that c++ gives me to write the cleanest code possible.
  2. parts of the game/engine where speed is important, here i still use c++ but try to minimize the use of polymorphism, virtual functions, etc.

in fact i believe that if you write good c++ code the speed problem is totally irelevant 90% of the time. if you are passing down 5000 triangles in one vertex buffer that one virtual function call won’t hurt you but will gvie you an easy way to abstract the gfx api you are using.

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 May 02, 2003 at 17:11

anubis: I think you may be missing the point. You don’t have to use all of C++’s features to write OO code. Simply classes and most likely inheritance. That’s all

CyraX: I don’t know why, but I find that for more complicated memory allocation commands new is easier than malloc. Just my opinion though

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 May 02, 2003 at 22:47

baldurk : i was just making a point that things that once were useful only in enterprise applications become more important in game development, too.

Baaecfb3a09127d5bc5045f89025e49e
0
UnknownStranger 101 May 03, 2003 at 08:20

Speed will always be a matter(that’s why asm is still used…)…
But today, it’s mostly much more important to have a clean, flexible code and short development times(that’s why asm is only used for single, easy to overview functions… :D )…

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 May 03, 2003 at 09:27

as i said. you have to find out were to use what.

Baaecfb3a09127d5bc5045f89025e49e
0
UnknownStranger 101 May 03, 2003 at 09:31

Oops…maybe I should read former posts, before just posting my own opinion… B)

590e8bdac8129bd87b188df15e62d0e5
0
CyraX 101 May 05, 2003 at 14:08

I accept that clean code is very important.
that was exactly why I said - I USE C++ classes… nothing else is required.
Did you ever try playing Q ]I[ on a system that sucks? Perhaps that is when you would realise that speed is important. Without speed your game play goes for a toss. Without Game play - well err… I guess everyone understands.
I never said C++ sux or otherwise… I only said C style coding is good.

F4c5cc867a73ee7eb1fd0b0caa5571c1
0
hanzac 101 Jul 26, 2003 at 10:46

i like c as well … i can do whatever i want to do even oop

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Jul 27, 2003 at 08:38

OO in pure C? I’d like to see that.

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Jul 27, 2003 at 12:55

oop is nothing magic. its simply much nicer to do in c++ than in c..

but if you want to use templates, you would have to code a preprocessor to preprocess your files before c to implement it..

there is no way to do them in c, except writing the code manually for all different possible types:D

and oop is not slow actually. really not. compilers are aware that people will use it and that they want it fast..:D

F4c5cc867a73ee7eb1fd0b0caa5571c1
0
hanzac 101 Jul 27, 2003 at 13:23

davepermen:
i have the same feeling with you,
actually when i want to do something like template in c, i just use the pointer
and give the number of bytes and pass the pointer. maybe it is not a convenient way. i like it, and i am just trying to learn.

maybe in real project i will choose c++ or above. :rolleyes:

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Jul 27, 2003 at 13:41

the pointer is less efficient in some situations (ints,floats,etc..), and does not give the same power at all that templates give you:D

F4c5cc867a73ee7eb1fd0b0caa5571c1
0
hanzac 101 Jul 27, 2003 at 14:08

maybe i have another advantage:

it is dynamic and the template is static once it is compiled. :D

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Jul 27, 2003 at 15:20

just depends on what you need.. but templates can generate your “dynamic code” as well:D just give them in a pointer:D

9275cef0ad2f15ec1813d63b0c5b0fad
0
rogerdv 101 Jul 28, 2003 at 12:11

@baldurk

anubis: I think you may be missing the point. You don’t have to use all of C++’s features to write OO code. Simply classes and most likely inheritance. That’s all

I remember a fake interview to Bjorn Stroustrup a couple of years ago. The fake Bjorn said that most C++ programmers insist EVERY oop feature available, just because it was there and somebody told them in the C++ course that it was * a good programming practice*. Personally, I know one who respect those *good practices* as a Holy Bible. Produces a nice code, indeed, but mostly unreadable for mere mortals like me.

Baaecfb3a09127d5bc5045f89025e49e
0
UnknownStranger 101 Jul 28, 2003 at 12:30

Hmm…just remembered this old joke about the programmer who renamed all his *.c files into *.cpp ones…

When he was asked, why he has done that, he said, that he wants to code OO… :lol:

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Jul 28, 2003 at 12:42

hehe:D

btw.. you know why they’re called “good coding practises”?

because they help you to make the compiler detect your own errors when you forget them. because they help you to make your system not crash just because you made a logic error in your program. etc.

and mainly because they help saving repetitive typing.

9275cef0ad2f15ec1813d63b0c5b0fad
0
rogerdv 101 Jul 28, 2003 at 22:22

Lets put it this way: what is the advantage of hiding all members and accessing them using functions? It is highly recommended, anyway I think the app will run keeping all member public and accessing directly like in the old structs.
Certainly, good programming practices helps a lot, but excesively good practices can make a clear sky become a storm day. Like Bjorn said: In C is easy to shot yourself in the foot. C++ makes it harder, but when you do it, you blow your whole leg.

4851117d61425bafb6c034e0f595d517
0
DrunkenCoder 101 Jul 30, 2003 at 06:07

Ok, nitpick but he’s not named Bjorn but Bjarne don’t belive me look here

as for the quote you can find his explenation here

also keep in mind that C++ isn’t an OOP languate it’s multiparadigm

hope that clearifies things a bit.

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Jul 30, 2003 at 06:22

as i stated on gamedev yesterday i think on the question “has C any use today?”

as always first: if its the only option (except for example asm) on a platform, use it (or the asm, if it fits your needs bether:D)..
what ever fits your needs

on every platform where there is a c++ compiler available (and thats about all the big ones today..), there is NO need to use C anymore.

the C language got a bit cleaned up in c++ (no stupid typedef struct _name {} name, and similar), and got a lot of additional features, the c++ part namely.

the C programming paradigms are still useful. functions, procedural programming. that all fits well into the c++ world as well.

but there is NO need to use straight C anymore. today c++ is “in”, too, so you get much bether support and much faster c++ compilers, too :D

4851117d61425bafb6c034e0f595d517
0
DrunkenCoder 101 Jul 30, 2003 at 07:06

And even if no “C++ Compiler” is availible for your platform you can always use the EDG C++ Frontend that can (among other things) translate C++ into C, the stuff that down your compilers throat and send angry e-mails to whoever is responsible for not giving you a proper compiler in the first place.

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Jul 30, 2003 at 08:17

good to know!

40da7e74fdca33768b6714646853b3f5
0
TheLionKing 101 Aug 19, 2003 at 03:19

I love C++ :yes: .

I think C++ is like an addon to C. It just improves the features available in C.

I love C++ since it sounds a bit crazier then C.

I think lots of people use C++ :yes: .

As a matter of fact, :rolleyes: I think C++ is the standard language for game programming.

F699ebb187331fdf7f7875320e3e7e3e
0
starboarder2001 101 Nov 20, 2003 at 23:59

Anyone programmed in C#? I am going to try it pretty soon. I programmed in pure C until I completely understood OO programming. Pretty much anything I write from now on is going to be written in C++…. or maybe C#. ;7

2562953b4e8e2602a8bfc24b1123a341
0
EvilSmile 101 Nov 21, 2003 at 03:59

I’ve only recently begun to learn cpp and I love it.
I find that it is far easier to produce cleaner code in cpp than in c.

as for teh speed issue- I really don’t think it matters anymore. Unless you are *really* good you can’t make sure that you put in all the features you want and also take care of OOPing your code and deliver on the same deadline using C. (but that could only be my opinion though…)

(in very simple words, my vote is for cpp)

22b3033832c5c699c856814b0cf80cb1
0
bladder 101 Nov 21, 2003 at 04:01

@starboarder2001

Anyone programmed in C#? I am going to try it pretty soon. I programmed in pure C until I completely understood OO programming. Pretty much anything I write from now on is going to be written in C++…. or maybe C#. ;7

yeah, Ive tried C#. Its pretty much like java, only….probably has a few more features and you get a really nice IDE :)

I think C# would be perfect for programming tools to use in your game. And the performance hit when using managed DirectX is not really that significant. It’s supposed to be just a 5% performance hit at worst on average.

I say go for it. C# is great to work with, slick and clean.

Ae694d3c74ebfebda4db06cdb9db7730
0
Mihail1212 101 Nov 21, 2003 at 09:18

I honestly like C more than CPP but i have reasons for that. First of all the code produced by CPP is NOT clean. Don’t believe me? Disassemble the source and loop for yourself. It is also MUCH MUCH slower than C(look at the ASM again). Those compilers are wasting billions of ticks(costs a lot even on the DEL workstations with dual Opterons) while trying to resolve the class connections,parentness and all other things relative with CPP. Yes it makes the code easier to write but is it worth it? I think not!

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Nov 22, 2003 at 01:20

mihail. your statements about the performance are completely wrong, as every todays c compiler is actually just the c++ compiler as well. there is no difference. and c++ isn’t slower normally at all.

and then again. why do all always first ask “is it fast?” if they compare languages? a language can not be fast. the produced code can. and it could be fast, or slow, for any language. it doesn’t mather.

2b97deded6213469bcd87b65cce5d014
0
Mihail121 102 Nov 22, 2003 at 10:33

@davepermen

mihail. your statements about the performance are completely wrong, as every todays c compiler is actually just the c++ compiler as well. there is no difference. and c++ isn’t slower normally at all. and then again. why do all always first ask “is it fast?” if they compare languages? a language can not be fast. the produced code can. and it could be fast, or slow, for any language. it doesn’t mather.

True my friend! The speed of the code is important. And it does depend if the compiler is doing simple function call with 3 or with 3000. And by the way, there is no sence in using the C++ compiler for C code. I think that the C++ is based on C compiler. Anyway somethings are important. If u need something quick do it with C or better yet with ASM!

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Nov 22, 2003 at 14:12

mihail. you got me wrong: EVERY TODAYS C COMPILER IS THE SAME AS THE C++ COMPILER.

you run in debugmode if you have those issues. C is NOT faster at all than c++, because all C can can be done in c++ EQUALLY. just rename your file from .C to .CPP and you can compile it again, and the compiler will spit out the 100% exact same asm again.

and speed is never the main most important thing. its the LAST thing.

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Nov 22, 2003 at 17:58

I’m pretty sure that gcc is a pure C compiler - ie. you’d need to use g++ to compile C++ code.

4851117d61425bafb6c034e0f595d517
0
DrunkenCoder 101 Nov 23, 2003 at 09:34

Ok, really do you think they would write scientific compution programs in C++ (to increase speed over specialized FORTRAN compilers) if it was slower than C?
Nope they do it because it’s faster.

Just because you can’t use the language right doesn’t mean it’s slow.
Sure there are features in C++ that cost clock cycles but if that is a big concern then simply don’t use them.

Equvivalent C and C++ code will be just as fast the C++ code being a bit more readable. You’re simply talking out of your ass with really nothing that argues your point. You simply can’t compare printf to cout and classes with virtual functions to calling a staticly bound function you’ll have to simulate them in C to get a fair comparison. Heck calling member functions is SLOWER in C than in C++ because the C++ got native support for it. In MSVC++ this translates to that in C you have to manually push a pointer to the struct you’re working on onto the stack wheras in C++ the same pointer is stored in a register.

Please grow up do some real research (no asking you’r 1337 h4x0r friends doesn’t count)

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Nov 23, 2003 at 14:40

DrunkenCoder : relax :)

baldurk : nope… g++ is gcc. it’s the same compiler :) g++ is just calling gcc with a few extra parameters.

oh boy i thought that this kind of discussion died out years ago. are we really still in the stone ages ? sure the whole industry codes in c++. of course they do that because it is slower and inferior to c.

i’m down with the casual inline assembly but i’m not going to make a fire using a flint when i have a lighter in my pocket ;)

4851117d61425bafb6c034e0f595d517
0
DrunkenCoder 101 Nov 23, 2003 at 15:16

@anubis

DrunkenCoder : relax :)

I guess I just have an issue with people not knowing what they’re talking about posting crap as facts.

The key to writing efficent code in any language is understanding the underlying thoughts and design decisions built into the language. And that is simpler todo with C because it’s basicly a highl level assembler (and that’s actually one of its design goals) C++ is designed in quite a diffrent way and people not using it the right way end shooting themself in the foot constantly blame the language without even trying to understand how things work.

C++ is not a simple language but it’s every bit as flexible and efficent as C.
Sometimes I actually wonder it it wouldn’t have been better if the legacy from C hadn’t been as strong :/ the language wouldn’t been as widespread but maybe just maybe people that don’t care about actually learning a new language wouldn’t have migrated and then claimed C++ to be C with classes…

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Nov 23, 2003 at 18:28

@anubis

oh boy i thought that this kind of discussion died out years ago. are we really still in the stone ages ?

hehe, yeah.. the ages of C style languages is gone long ago..

till christmas, right, anubis?:D

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Nov 23, 2003 at 20:34

hehe… actually i was talking about the c - c++ war…
but yes you are right till christmas everything will have changed… :)

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Nov 23, 2003 at 22:24

i know what you where talking about..:D

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Nov 23, 2003 at 22:33

hmmm, only one month left till world domination… and i still don’t have any clothes for that event…
what are you going to wear on christmas eve ?

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Nov 24, 2003 at 15:35

you mean you only have the emperors clothes? shit, i wanted to wear them..

well then, i’ll wear my normal outfit then:D

2b97deded6213469bcd87b65cce5d014
0
Mihail121 102 Nov 25, 2003 at 10:41

You guys are bad! I’m gonna tell mom…. Uaaaaaaaaaaaaa.

P.S.
By teh lay C ROKS!!!\~!1

P.S.S
Ok that was stupid. Everyone has his/shes own taste.

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Nov 25, 2003 at 14:28

well, there are tastes that are based on good reasons and there are tasted that are based on bad reasons..

hype is a bad reason. most c++ and c programmers have this reason to use the language, and hail it. marketing hype. now, the same goes on with c#.

1c524bd2186804f828ea3e1a3216a294
0
alia 101 Nov 26, 2003 at 02:09

@davepermen

well, there are tastes that are based on good reasons and there are tasted that are based on bad reasons.. hype is a bad reason. most c++ and c programmers have this reason to use the language, and hail it. marketing hype. now, the same goes on with c#.

Hmm in that case im probably staying away from vb and c# for bad reasons… (well c# anyway - ive used vb and find it very stoopid).. ie m$ft.. *shrug* i guess ill try it when i need to use it.. untill then ill stick to perl/c/c++

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Nov 26, 2003 at 07:29

i had to use VB on a job once. VBA to be precice. a real nightmare that was….

2b97deded6213469bcd87b65cce5d014
0
Mihail121 102 Nov 26, 2003 at 10:37

I was coding the last night the source for my soft render tut 2 and i realized that there ain’t really no need to be going back to stone age. That’s why i decided to use classes where needed too. But i still continue to think that true code is NOT based only on classes or procedures. One has to use combination of both.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Nov 26, 2003 at 11:59

no arguement about that…
just use what suits the situation best

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Nov 26, 2003 at 16:41

I’d personally say that if you use the style of coding/language that suits you best, that’s almost always the best option.

I use a mix of C/C++. If I was to code in pure either, I’d be slower for the same task.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Nov 26, 2003 at 17:00

well, that’s a matter of training and adhering to certain patterns though