Jump to content

  • Log In with Google      Sign In   
  • Create Account

Portable game engine - C or C++?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
15 replies to this topic

#1 meeshoo   Members   -  Reputation: 508

Like
0Likes
Like

Posted 01 September 2010 - 06:05 AM

Hello guys,

I've begun research for coding a cross-platform, portable game engine (rendering engine at first). Before you ask, this engine is not because I want to build a specific game with it, it is more of an exercise, a general purpose rendering engine and then game engine that can be used on a multitude of platforms.

When I'm thinking about portable, I don't just want it to be for Windows/Linux/Mac, but also for portable devices like IPhone, Android and other known and well established platforms.

The problem is that I recently read a book (an OpenGL ES programming guide) released in 2008 in which it states that C++ is not supported very well on a multitude of mobile platforms, and it is better to choose C as a programming language for them.

I worked using both of them for more than 10 years now and I'm experienced with both, that is not an issue, however, writing a full blown game engine in C can be a difficult task, and C++ looks much more fit for developing such a software package.

My question is: should I go on with C++, hoping that more and more platforms will support it fully or go with C, and which are the arguments behind your advice?

Thanks.

Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 13907

Like
0Likes
Like

Posted 01 September 2010 - 06:10 AM

I don't know of a relevant platform where C++ is not well supported. Even Arduino (a tiny microcontroller) can be programmed in C++.

#3 meeshoo   Members   -  Reputation: 508

Like
0Likes
Like

Posted 01 September 2010 - 06:21 AM

Well, in the opengl es 2.0 programming guide I've read about, on page 342, there are the following issues stated:

- lack of RTTI support on some
- lack of exceptions support on some
- some platforms don't have STL
- lack of multiple inheritance on some platforms

link to book: http://www.amazon.com/OpenGL-ES-2-0-Programming-Guide/dp/0321502795/ref=sr_1_1?ie=UTF8&s=books&qid=1283362309&sr=8-1

[Edited by - meeshoo on September 1, 2010 12:21:27 PM]

#4 Ed Welch   Members   -  Reputation: 485

Like
0Likes
Like

Posted 01 September 2010 - 07:41 AM

iPhone, Symbian and Android all have full c++ support (including exceptions and stl). In case of Android it's supported by an add-on, but still it works.

#5 Echkard   Members   -  Reputation: 100

Like
0Likes
Like

Posted 01 September 2010 - 07:43 AM

Most of that is stuff you probably wouldn't use on a mobile platform game engine anyway. Anyway, that's not the point. C++ is a superset of C. So you can choose to either use C, giving up all the benefits of C++, or you can use a limited implementation of C++, giving up only some of the benefits. Put in that light, which would you choose? In any case, mobile platform C++ implementations are improving all the time. Most have full support, and those that don't are rapidly getting it.

#6 Martins Mozeiko   Crossbones+   -  Reputation: 1422

Like
0Likes
Like

Posted 01 September 2010 - 08:11 AM

Quote:
Original post by meeshoo- lack of RTTI support on some
- lack of exceptions support on some
- some platforms don't have STL
- lack of multiple inheritance on some platforms

Mostly these features now-days works on most of embedded platforms, but very often people doesn't use them for some reasons - either performance or size of generated code, or something else (poor performance for standard library implementation, old cross-platform compiler versions with bugs, etc).

Really - how often do you need RTTI on small game engine (for iPhone, for example)? I've never used C++ RTTI myself even on desktop platform, except indirectly by third party library (LLVM, boost).

Vanilla C++ (think C + objects/inheritance) imho would be fine for such game engine. Just don't rely on RTTI/exceptions and you will be fine.

#7 meeshoo   Members   -  Reputation: 508

Like
0Likes
Like

Posted 01 September 2010 - 09:02 AM

Thanks for all your replies, it was very helpful. I will continue then with C/C++ combo that always works best, leaving fancy C++ stuff aside, but benefiting from objects, polymorphism, encapsulation and so on.

Thanks again.

#8 yckx   Prime Members   -  Reputation: 1291

Like
0Likes
Like

Posted 01 September 2010 - 05:59 PM

Quote:
Original post by Echkard
C++ is a superset of C.

This isn't strictly true. Rather, C++ was designed with the aim to be compatible with C code, but it's not a perfect compatibility--there are subtle differences. Approaching C++ as if it were C with classes will ultimately lead you astray.

Edit: Here's some material on the subject.

#9 meeshoo   Members   -  Reputation: 508

Like
0Likes
Like

Posted 01 September 2010 - 07:40 PM

Don't worry about it, I have a lot of experience with both (ranging from Windows drivers to desktop applications). Giving up some features of C++ in order to maintain compatibility won't hurt that much.

#10 phresnel   Members   -  Reputation: 949

Like
0Likes
Like

Posted 02 September 2010 - 04:29 AM

Quote:
Original post by yckx
Quote:
Original post by Echkard
C++ is a superset of C.

This isn't strictly true. Rather, C++ was designed with the aim to be compatible with C code, but it's not a perfect compatibility--there are subtle differences. Approaching C++ as if it were C with classes will ultimately lead you astray.

Edit: Here's some material on the subject.


Here's a more dedicated link, some of you will be shocked: Are You Ready For C99?

Excerpt:

Variadic Macros
void realdprintf (char const *file, int line, char const *fmt, ...); 
#define dprintf(...) realdprintf(__FILE__, __LINE__, __VA_ARGS__)

(taken from here)

Variable Length Arrays
void foo (int x) {
int frob[x];
}


Named Initialization (two years before C#, heh)
typedef struct {
int alpha;
int bravo;
} Foo;

Foo foo = { .bravo = 1, .alpha = 5 };


"Struct Hack" Support
See this.

And some more.


And to lead "C++ is a superset of C" ad absurdum in a freaking glimpse: You can't use "class" as an identifier for a variable in C++ :D

#11 Echkard   Members   -  Reputation: 100

Like
0Likes
Like

Posted 02 September 2010 - 04:44 AM

Quote:
C++ is a superset of C.
Quote:

Approaching C++ as if it were C with classes will ultimately lead you astray.
That's interesting, as Bjarne Stroustrup -- whom I once met -- said that was exactly his goal when designing C++, to make it "C with Classes". Yes, there are some mostly trivial differences, but I've succesfully compiled many a C project under a C++ compiler with little to no changes.

#12 phresnel   Members   -  Reputation: 949

Like
0Likes
Like

Posted 02 September 2010 - 04:57 AM

Quote:
Original post by Echkard
Quote:
C++ is a superset of C.
Quote:

Approaching C++ as if it were C with classes will ultimately lead you astray.
That's interesting, as Bjarne Stroustrup -- whom I once met -- said that was exactly his goal when designing C++, to make it "C with Classes". Yes, there are some mostly trivial differences, but I've succesfully compiled many a C project under a C++ compiler with little to no changes.


I would no longer call them trivial as for above mentioned C99 features. And not all C99 features will also be supported in C++0x.

That is not to say, of course, that most C is also C++. But a significant amount is not.

#13 meeshoo   Members   -  Reputation: 508

Like
0Likes
Like

Posted 02 September 2010 - 05:03 AM

I think C++ 0x has a quite a long road before it will be approved, because i think they had 2010 as a deadline and they didn't make it.

Btw, how about SIMD support on mobile processors?

#14 M2tM   Members   -  Reputation: 948

Like
0Likes
Like

Posted 02 September 2010 - 06:41 AM

Quote:
Original post by Echkard
Quote:
C++ is a superset of C.
Quote:

Approaching C++ as if it were C with classes will ultimately lead you astray.
That's interesting, as Bjarne Stroustrup -- whom I once met -- said that was exactly his goal when designing C++, to make it "C with Classes". Yes, there are some mostly trivial differences, but I've succesfully compiled many a C project under a C++ compiler with little to no changes.


Funny how years and years of language development and learning can change an outdated original goal, isn't it? I don't think he would consider C++ "C with Classes" today, and indeed, he spends a lot of time trying to explain to educators that C++ is its own language and needs to be taught differently than learning C features and then C++ features.

Learning Standard C++ As A New Language

#15 RobTheBloke   Crossbones+   -  Reputation: 2341

Like
0Likes
Like

Posted 02 September 2010 - 07:16 AM

Quote:
Original post by meeshoo
I think C++ 0x has a quite a long road before it will be approved, because i think they had 2010 as a deadline and they didn't make it.


As I understand it, the deadline is March 2011. Mind you some compilers already support it.

Quote:
Original post by meeshoo
Btw, how about SIMD support on mobile processors?


This has got nothing to do with C++, and everything to do with the CPU manufacturers.

#16 meeshoo   Members   -  Reputation: 508

Like
0Likes
Like

Posted 02 September 2010 - 07:20 AM

I know it hasn't have anything to do with C++, but still it is about portability, and I know too little about what kind of CPUs are on the majority of the phones. I know ARM architecture is very popular, but are there any others that I should care about?






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS