C vs. C++...

henryj
Unregistered
 
Post: #16
Quote:Originally posted by Tycho
I think saying any language is "the best" is asking for a flamewar.


Not if you admit that I'm right.
Quote this message in a reply
Member
Posts: 131
Joined: 2004.10
Post: #17
Either is fine for what ever you want to do.

Personally I prefer C mainly because there is a lot less to know. Just take the manuals for each of the the languages. C is almost like a brochure compared to the tolstoy that is C++.

My opinion, whatever you can do in C you can automatically do in C++ (seeing that C++ is a superset so this is a given.) and conversely anything you can do in C++ you can do in C. The converse case will mean that you will have to organize the code better and may involve more coding on your part but it's all possible.

My preference is on the C side mainly because when I stated C++ wasn't available or just starting out. It's only recently it's been a viable option as the crossplatform issues have mostly been resolved. Early C++ compilers on various platforms were terrible in terms of compatibility of features. So I'm way more comfortable in C than C++. Go with what you are comfortable and fast in.

With C++ you have a nice library available, STL. This will save you oodles of time not having to recreate data structures that STL provides. It lets you get on with programming the important bits. There isn't really a C equivalent but is it possible to write a 'wrapper' around STL to let C programs have access to this library in an albeit limited fashion.

If you are starting then take your pick. Either is fine. Which do you feel is the language that will give you the most value in the long run. Go with that.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #18
Quote:Originally posted by Tycho
Stolen from the OpenGL Programming Guide:

Drats Tycho, I posted the same thing, you're too quick for me!

I'd like to add $.02. I personally think C++ is overkill for most stuff.
Quote this message in a reply
B Rob
Unregistered
 
Post: #19
I can look at well written C code and understand it rather easily, but C++ and Obj-C provoke a "what the hell is that" kind of reaction. Of course, I need to learn C++ and Obj-C before I make a final judgment.
Quote this message in a reply
Mars_999
Unregistered
 
Post: #20
Quote:Originally posted by skyhawk
well... I am a masochist because I use Obj-C++... I like the Obj-C system calls and such, but when it comes to making my own classes, I find it easier to use C++ classes. I don't do anything funky with these classes other than using them to encapsulate data and having the functions being a part of the structure to use the data.

Ditto
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #21
What about cross-platform compatibility? Obviously ObjC won't work in Windows. C and C++ are probably the same though, but would it take longer to port C++ than C? Since the only things that need to be ported are from the system API's and frameworks, it probably doesn't make much of a difference.
Quote this message in a reply
Member
Posts: 131
Joined: 2004.10
Post: #22
Quote:Originally posted by Nevada
What about cross-platform compatibility? Obviously ObjC won't work in Windows. C and C++ are probably the same though, but would it take longer to port C++ than C? Since the only things that need to be ported are from the system API's and frameworks, it probably doesn't make much of a difference.


I work at a company that used to develop for Sun Solaris, Sun OS, SGI Irix, and Windows. C++ compilers on each of these platforms were very different and making comptible code for all platforms was some serious voodoo. C, due to it's simplicity, didn't have half of these issues. But yeah, lately I don't see this being as big of an issue as it was so it may not be a concern anymore. So porting should be the same which ever you choose.

I don't know if ObjC is on the windows side but I'm sure GCC might allow for it. Other then that I don't know of anyone using it on the windows side. Most have opted for C++ if anything.

Yes, mostly it will be OS specific that you'll get into cross platform headaches. Then it's probably best to use a lib that is cross platform to avoid these headaches. I always concern myself with cross platform worries even if I will never build for the other platform. I just like to keep the options open. Smile But if you don't care for any other platform and only intend to support just one then this isn't an issue.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #23
GCC should be able to compile Objective C on Windows, though you won't have access to Cocoa (unless the GNUstep team has made rapid progress Rasp).

For C++, Microsoft's C++ compiler is pretty incompatible with GCC. It's much easier to port from GCC to MSVC++ than the other way around Smile

For other languages, it's mostly API differences which you'll have to deal with regardless of language. For games, SDL is a great way to avoid these problems.
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #24
Ok. So if I do most of the programming (Like game logic, physics, etc.) in plain C++, then have separate functions specifically for, say, file I/O, input, or other system specific calls, then I would only really have to port those particular functions on the different platforms. So that should be a very small amount of code. And, I'm going to use OpenGL (GLUT) for the graphics so I should have no problem there(?). Are C++ compilers really that different on different platforms? If so, then I guess that would be a reason to get CodeWarrior right?
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #25
Quote:Originally posted by OneSadCookie
GCC should be able to compile Objective C on Windows, though you won't have access to Cocoa (unless the GNUstep team has made rapid progress Rasp).

For C++, Microsoft's C++ compiler is pretty incompatible with GCC. It's much easier to port from GCC to MSVC++ than the other way around Smile

For other languages, it's mostly API differences which you'll have to deal with regardless of language. For games, SDL is a great way to avoid these problems.


Hmm, I thought ObjC was Mac only. Anyway, what exactly is SDL? I'd really like to make my programs easy to port so I don't make a huge project that ends up being for Carbon only and take forever to port.

Also, if I were to get a PC specifically for porting purposes would it include a compiler which would accept GCC code? (Or at least be easy to port) Or should I reconsider the whole CodeWarrior thing?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #26
ObjC is a language. It can't be tied to one platform.

Cocoa is an API. Currently, there's really only one implementation of it, done by Apple and running exclusively on Mac OS X. The GNUstep folks are bringing it to Linux (fairly quickly) and Windows (fairly slowly). Before Apple, of course, Cocoa belonged to NeXT...

SDL is a cross-platform library that takes care of windowing, graphics, setting up opengl, input (including gamepads and joysticks), sound, and threading. There are also a few libraries that generally go hand-in-hand with SDL, notably SDL_net (for networking) and SDL_image (for loading image files). All these libraries work on Mac OS X, Windows and Linux nearly Wink identically.

Your Windows PC won't come with dev tools. If you install Linux on it you can use GCC of course, and there are a few free C++ compilers for Windows, but if you want Microsoft's Visual C++ (which is very much the standard on Windows no matter how undeserving Wink) you'll have to pay through the nose.
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #27
Cool. How but how is it able to behave the same on different platforms? Does it check the operating system and use the appropriate functions? So that would mean porting would be (almost) as easy as copy/paste to different compilers. Sure makes my life easier.Smile Anyway, now back to trying to understand classesBlink (Using a book almost as old as I am).
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #28
There's a completely different implementation of SDL for each platform it runs on (there are two or three completely different implementations for the Mac Rasp).

You never have to concern yourself with that, though. The point of SDL is that it's all hidden, and that the same source code should work identically on all platforms.

GLUT works much the same.
Quote this message in a reply
Mars_999
Unregistered
 
Post: #29
MSVC++ compiler is cheap $99. I use MSVC++ 6.0 and it works great under windows. But you will have more headaches than which compiler to use when you port code. Endianess, OpenGL ext on PC are called in a different way than Mac. I would suggest you use SDL and if your big thing is cross platform and use C or C++ with OpenGL. Their I said it OSC should be happy use C. WINDOZE is wrote using C. Hahhahh now thats a slam!Grin Na it's not C's fault its the coders fault. Happy now.Rasp
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #30
Well, given Mac OS X and Linux are written in C, I'd hope it's nothing to do with the language Rasp
Quote this message in a reply
Post Reply