Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / C and C++ - Which do you prefer?

Author
Message
Clbembry
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Minnesota
Posted: 25th Sep 2008 06:10
Which of the two do you prefer and why?
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Sep 2008 06:15
C++, because it's C, but better. End of story.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Satchmo
19
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 25th Sep 2008 06:20
Quote: "C++, because it's C, but better. End of story. "


And slower.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Sep 2008 06:22 Edited at: 25th Sep 2008 06:26
Quote: "And slower."


Sorry, but that's all but a lie. Seriously, basically anything you do in C can be done just as efficiently in C++.

EDIT: Read this. Note that the one negative argument given for C++ (lack of efficient compilers) no longer applies as VC++ is amazing at optimizing C++ code.

http://unthought.net/c++/c_vs_c++.html

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Uncle Sam
19
Years of Service
User Offline
Joined: 23rd Jul 2005
Location: West Coast, USA
Posted: 25th Sep 2008 09:18
Quote: "Sorry, but that's all but a lie."


If it's all but a lie then it's not a lie.

Mr Z
17
Years of Service
User Offline
Joined: 27th Oct 2007
Location:
Posted: 25th Sep 2008 11:23
What I thought C++ was slower, if you use things like polymorphism. If you skip OOP, it is just as fast as C. But that is what I have heard, have not done or seen any benchmark about it.

There is no greater virtue, then the ability to face oneself.
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 25th Sep 2008 11:37
Quote: "What I thought C++ was slower, if you use things like polymorphism."


Really? I heard cars go much faster than planes, when you remove the plane's engines that is. Oh wait, this isn't a valid comparison so ignore me.

NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 25th Sep 2008 12:15
I use C all over because I don't understand how polymorphism etc. works. So might as well recoup the speed.

Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 25th Sep 2008 13:48
In terms of programming tools available, such as the OO support that C++ has over C, I think that C++ is better and I swear by it for any viable project that can use OO.

TheSturgeon(playing me at chess) : I will use my powers of the horse and pwnzor you.
Clbembry
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Minnesota
Posted: 25th Sep 2008 14:17
I've heard from people OO isn't always such a good thing.
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 25th Sep 2008 14:42
Well, It is only a bad thing if you do not use it properly. It is not suited to all types of applications, however the applications that it is suited towards are made much easier by using OO.

TheSturgeon(playing me at chess) : I will use my powers of the horse and pwnzor you.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 25th Sep 2008 15:50
OOP is the best thing that ever happened to me, and that includes being born, staying in a big house, all my holidays, etc. Seriously, if you think OOP is bad, then you probably just don't know how to use it.


In the end of the day, there's a reason why C++ is used more than C, and that reason is OOP (obviously). Let the crowds decide!

Roxas
19
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 25th Sep 2008 16:19
I tried C but it was meh. C++ all the way

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Sep 2008 16:56 Edited at: 25th Sep 2008 16:56
Quote: "If it's all but a lie then it's not a lie."


Hmm.... you're right. It is a lie.

Quote: "I use C all over because I don't understand how polymorphism etc. works. So might as well recoup the speed."


There is no point in using C over C++ just because you aren't using OOP. There are other improvements to the language.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 25th Sep 2008 17:53
I highly doubt anyone here will notice a speed difference between C and C++, much less find it a hindering factor

Most commercial games are made with C++ nowadays if that matters.


monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 25th Sep 2008 18:01
As mentioned above, object orientated programming is a major leap forward. If used properly, it can decrease development time dramatically. C is still widely used for things like programming PICs.

My liver is evil, I must kill it!
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 25th Sep 2008 18:49 Edited at: 25th Sep 2008 18:50
You will notice the speed difference if you are coding a World of Sand clone for the DS. (49152 pixels to process per frame, 66mHz ARM RISC microprocessor?) Otherwise, it's negligable.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Sep 2008 19:54
Quote: "You will notice the speed difference if you are coding a World of Sand clone for the DS. (49152 pixels to process per frame, 66mHz ARM RISC microprocessor?) Otherwise, it's negligable."


It's a 66Mhz ARM9. Having programmed the GBA's 33Mhz ARM7TDMI, I'm here to say that there isn't a difference in speed between C and C++. The little that might arise would be from

a) The usage of the code (the exact same code won't be any different in speed).

b) The GCC compilers custom tailored for DS and GBA development are usually outdated, and most likely are not as well optimized for C++. In VC++, C++ will always be as fast as C.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 25th Sep 2008 19:59
http://www.youtube.com/watch?v=uljdrj7Vxzk

Heavily optimised with pretty much only pointers, it runs 50-60fps with C and 45-60 with C++. Not much difference, but sometimes lightweight code is the way forwards.

The DS and GBA are mighty nice to program for though, must say.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Sep 2008 20:03
Quote: "Heavily optimised with pretty much only pointers, it runs 50-60fps with C and 45-60 with C++."


Exact same code?

Also, like I said, the older GCC builds do not do as well with C++, I imagine. And what optimization options are you using?

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 25th Sep 2008 20:06
Uh.. dunno, it was rewritten from a "Hello World" project because I admit to having not the foggiest how the whole makefile system etc. works. The code was exactly the same. I really don't know what I'm doing when it comes to setting up environments.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Sep 2008 20:16
Quote: "Uh.. dunno, it was rewritten from a "Hello World" project because I admit to having not the foggiest how the whole makefile system etc. works. The code was exactly the same. I really don't know what I'm doing when it comes to setting up environments."


Hmmm.... well, C vs. C++ aside, what tutorial are you using? The one I found for GBA wasn't all that great, and I'd like to continue learning how to program for it.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 25th Sep 2008 20:23
The one in the "examples" folder that comes with DevKitPro. I think it's called ansi-console.

optical r
22
Years of Service
User Offline
Joined: 23rd Oct 2002
Location: Prime
Posted: 25th Sep 2008 20:42
C++ all the way, any day!

I use it daily in the games company I work for. Everyday, you seem to pick something new up - even if doing it for 3 years at uni wasn't enough!

I disagree about there being a speed advantage with C++. However, I suppose there are a lot of potential optimizations, that can be achieved in C++ if you know how to do them correctly.
Conversely, its a matter of how well you know a high-level language in order to achieve a gain in speed, and what you are developing for.

The OOP Paradigm, imo, is by far the best practice a programming language has developed into


Professional WebDesigns on request! designrjs.com
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Sep 2008 20:54
Quote: "The one in the "examples" folder that comes with DevKitPro. I think it's called ansi-console."


So you aren't using a full-on tutorial?

If a little assembly doesn't scare you (trust me, it's way easier than x86), look for the GbaGuy's NES tutorial. It's awesome to use.

Quote: "I disagree about there being a speed advantage with C++."


Though you may have meant to type "C", I wasn't saying there was an advantage in speed, simply a lack of disadvantage.

Quote: "The OOP Paradigm, imo, is by far the best practice a programming language has developed into"


Definitely.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
optical r
22
Years of Service
User Offline
Joined: 23rd Oct 2002
Location: Prime
Posted: 25th Sep 2008 21:37
Quote: "Though you may have meant to type "C", I wasn't saying there was an advantage in speed, simply a lack of disadvantage.
"


Indeed, i was meant to, lol


Professional WebDesigns on request! designrjs.com
Benji
18
Years of Service
User Offline
Joined: 17th Dec 2005
Location: Mount Doom
Posted: 25th Sep 2008 21:45
Meh, who needs C++.

C# + XNA Game Studio, now there's a quality language.

My signature is empty.
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Sep 2008 22:46
Quote: "The one in the "examples" folder that comes with DevKitPro. I think it's called ansi-console."


I forgot how much I dislike DevKitPro. The other GBA kit I found, though based on an older version of GCC, it much easier to use. Not sure what it's called.

The easiest console kit I've found is the assembler for the NES.

It's surprising simple to use: just one command-line exe.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 25th Sep 2008 22:52
ngine.de HAM? I like that a lot, although I noticed its slowness.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Sep 2008 23:21
Quote: "ngine.de HAM? I like that a lot, although I noticed its slowness."


Just checked: devkitadv

It's much easier to use, though it doesn't come with a library (which removes all the fun ).

I still prefer NES programming, though. All the crazy old-school C-style things you have to do for GBA (while maintaining efficiency) ruin it for me.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Clbembry
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Minnesota
Posted: 26th Sep 2008 00:34
I never said OOP was a bad thing. I personally like it a lot. It's just that some people have a hard time grasping it like my cousin.
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 26th Sep 2008 02:32
Quote: "You will notice the speed difference if you are coding a World of Sand clone for the DS"


Uh, okay. You may also see a speed increase if you program it in assembly, or even more in machine code


Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 26th Sep 2008 02:47 Edited at: 26th Sep 2008 02:48
Quote: "Uh, okay. You may also see a speed increase if you program it in assembly, or even more in machine code "


Lol.

Though he's being sarcastic, he has a point (though I don't think it applies with C vs. C++ ).

Assembly is ridiculously fast when required (1.79 Mhz NES CPU ).

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
ionstream
20
Years of Service
User Offline
Joined: 4th Jul 2004
Location: Overweb
Posted: 26th Sep 2008 04:57
I don't think people understand what they mean when they say "C++ is slower." In what respect? Calling a function? Adding a two numbers?

I believe this myth comes from C++'s classes. Classes are slower than I structs in C, but that comes with the obvious advantage of being able to use object oriented programming. Of course classes are not required to be used in C++, so if you were to write a program in C++ that used absolutely no object oriented techniques, it would certainly be as fast as an equivalently written program in C.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 26th Sep 2008 05:10
^Exactly.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 26th Sep 2008 06:12
Yes, C++ is almost 100% backwards compatible with C (obviously in C you can use the class keyword, etc.), so you're not likely to see a speed decrease by copying your C code as-is.


Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 26th Sep 2008 06:24
Quote: "so you're not likely to see a speed decrease by copying your C code as-is."


At most, the compiler will point out any awful usage of C code that's just plain sloppy.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
General Reed
18
Years of Service
User Offline
Joined: 24th Feb 2006
Location:
Posted: 26th Sep 2008 10:13
Quote: "I've heard from people OO isn't always such a good thing. "
- Well peeps who dont know how to use oo in the proper manner would say that, just like peeps who dont have the specs to run vista say its crap. But OO is sooo usefull, makes everything more organised, and makes extending code or reusing code so much easier. Like it should be.

CPU: AMD X2 6000+ 3.0ghz GFX: NVIDIA BFG Geforce 8800GTS 640MB OC-550mhz core RAM: 2048mb

NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 26th Sep 2008 11:18
I might look into assembler; although it is a bit beyond me as of now.

Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 26th Sep 2008 13:08 Edited at: 26th Sep 2008 13:10
Quote: "Assembly is ridiculously fast when required (1.79 Mhz NES CPU )."

Why do you keep mentioning the NES? Either way, the way compilers optimize code now you'd have to be very good to write more efficient assembly than a C++ compiler can.

Oh and I'm with Jeku, you won't notice a speed difference between C and C++. Unless of course you have some stupidly long-winded use of OO in a tight loop that needs as much speed as possible, but then if you have common sense you'll know not to do this.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Sep 2008 15:48
Quote: "I believe this myth comes from C++'s classes. Classes are slower than I structs in C"

I've no interest in persuading people to use C++ or not, but at least the decision should be based on facts.

If you actually follow that up with code that you can use to prove that, I reckon that I can show you how you can code the C++ side in a natural way so that it is at least as fast.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 26th Sep 2008 19:41 Edited at: 26th Sep 2008 19:44
Quote: "Why do you keep mentioning the NES? "


We were on the topic of Nintendo homebrew and I've been working on NES homebrew a lot. Sorry.

Quote: "I might look into assembler; although it is a bit beyond me as of now."


It seems overwhelming at first, but it's just a matter of getting used to it. GbaGuy has a tutorial on GBA assembly. It should be easier than NES for you since you know about the GBA registers already.

http://patater.com/gbaguy/gbaasm.htm

EDIT: Also, don't run any GBA ROM's on your DS until you've gotten farther into the tutorials. Just use VisualBoyAdvance to run them.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
kaedroho
17
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 26th Sep 2008 19:44 Edited at: 26th Sep 2008 19:44
I prefer C because you can program PIC Microcontrollers with it.

But for games, definately C++.
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 26th Sep 2008 20:54
Quote: "since you know about the GBA registers already."


Urm... nope. DevKitPro takes a lot of the work away. It's the easiest system I've coded for.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 26th Sep 2008 20:57
Quote: "Urm... nope. DevKitPro takes a lot of the work away. It's the easiest system I've coded for."


You mean you're only using the DevKitPro library?

But that takes all the fun out of it. . .

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 26th Sep 2008 21:08
No, it makes it easier for a n00b such as myself who can code but struggles to apply code to systems. I just don't get it all. When I try to program for Windows, all I see is a page of meaningless gibberish with the occasional freestanding letter such as "L". If it wasn't for DKP, I wouldn't have achieved anything. I'm not cut out for programming, that much is clear which is why I am trying to get into the art side of software development.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 26th Sep 2008 21:32
Quote: "When I try to program for Windows, all I see is a page of meaningless gibberish with the occasional freestanding letter such as "L"."


Don't use raw Win32 API: it sucks to use. Look up WTL (Windows Template Library). It's a C++ OOP wrapper for the API.

Quote: "If it wasn't for DKP, I wouldn't have achieved anything. I'm not cut out for programming, that much is clear which is why I am trying to get into the art side of software development."


I can understand that. I guess I just like having true control; it makes optimizing it fun/easier.

But I suck at art.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 26th Sep 2008 22:10 Edited at: 26th Sep 2008 22:13
Quote: "Classes are slower than I structs in C"


Classes ARE structs - behind the scenes the compiler cobbles together classes using structs, there's practically no difference between them (In fact, you can exchange any class to be a struct, and it will work pretty much exactly the same. The only difference being between them that structs have default member access as public rather than private)


09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
optical r
22
Years of Service
User Offline
Joined: 23rd Oct 2002
Location: Prime
Posted: 26th Sep 2008 22:11
Quote: "I prefer C because you can program PIC Microcontrollers with it."


Mikro C is a really useful compiler to take a high-level approach to PIC programming. Personally, I still prefer asm for that stuff - seems more satisfying!


Professional WebDesigns on request! designrjs.com
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 26th Sep 2008 22:16
I always wanted to code PICs with ASM in Electronics, but as most couldn't write a dice program using a flowchart... well, nobody got higher than a D in Electronics that year.

Login to post a reply

Server time is: 2024-11-20 16:24:52
Your offset time is: 2024-11-20 16:24:52