Archived

This topic is now archived and is closed to further replies.

ServantOfGlaaki

C/C++ Learning

Recommended Posts

Hi there all, I''ve spent the last 3 years or so learning and programming in Java, and I''ve realised that if I want to do applications, C/C++ is the way to go. The thing is, I don''t know much. Don''t worry, I''m not asking for a tutorial, but I would like to know what the differences are between C and C++, and which one I should learn. p.s. On some coverdisc I have a full copy of Borland CBuilder, version 5 (I think). Is this good, or should I invest in something better?

Share this post


Link to post
Share on other sites
Java is a lot like C++. However, a couple of the low level parts of C++ will throw you off (pointers, memory management, et cetera). C is basically C++ without most of the easy-to-use OO features and lots of little things. Learning C would be more difficult for someone who started in Java, but it''s something you should look into for the future (C is still very widely used, so it can''t hurt to know).

BCB is pretty good, and should do fine. It has a lot of features aimed at RAD GUI based programs which you probably won''t need for a while. If you don''t like it, you should try one of the many free compilers and/or IDE''s available on the internet before spending money on one.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Null and Void, I''m shocked, I usually agree with you.

Since when are OO features easy to use, have you read these
forums?!

But everything else you say is true.

Share this post


Link to post
Share on other sites
there''s actually a great beginner tutorial in the forums here on gamedev.net which talks about the difference about c/c++. and of course since it''s a tutorial it''ll help you with learning c/c++.

This is the Tutorial: http://www.gamedev.net/community/forums/forum.asp?forum_id=33

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Null and Void, I''m shocked, I usually agree with you.

Since when are OO features easy to use, have you read these
forums?!



Java is object-oriented, too, so learning C++ (which is object oriented) would be easier than learning C (which isn''t) if the person learning already uses Java.

Get it?

------------------------------
Simple DirectMedia Layer:

Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net''s Tutorials - (Here)

OpenGL:

Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)

Share this post


Link to post
Share on other sites
NullAndVoid:

In your first post, are you trying to say that I should begin with C++, and move on to C, and that C is better? Surely this can''t be true, as (the way I see it, which is almost certainly wrong ) C++ is a more advanced version of C. Can C do GUI-type-stuff (i.e. with a RAD)?

Can both C and C++ use such advanced things as DirectX, OpenGL, various parts of the Windows API, networking, etc.?

Sorry about all the questions by the way...

Share this post


Link to post
Share on other sites
quote:
Original post by ServantOfGlaaki
are you trying to say that I should begin with C++, and move on to C, and that C is better? Surely this can''t be true, as (the way I see it, which is almost certainly wrong ) C++ is a more advanced version of C.


Neither is really better than the other. It''s a matter of opinion. C++ is object oriented, more like Java, therefore it would be easier for you to learn. C is not object oriented, so it''s not as complex as C++, but it''s different from Java, so it would be like learning something totally new, whereas learning C++ would be easy because it is similar to Java, which you know already.

quote:

Can both C and C++ use such advanced things as DirectX, OpenGL, various parts of the Windows API, networking, etc.?



Yes.



------------------------------
Simple DirectMedia Layer:

Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net''s Tutorials - (Here)

OpenGL:

Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)

Share this post


Link to post
Share on other sites
In C++, you can technically do anything you could in C (with a few exceptions). You probably already heard this, which is why you may be confused as to how C could be so different.

C++ is focused more towards OOP, like Java. An object oriented program written in C++ will be designed much differently than a procedural program written in C. Both languages require a different mindset, so you can''t just think of C++ as an extension to C.

My suggestion would be to learn C++. It would probably be easier since you already know Java.

Share this post


Link to post
Share on other sites
quote:
Original post by Drizzt DoUrden
Neither is really better than the other. It''s a matter of opinion.



What are you talking about? C++ is so much better than C it''s not even funny.

DON''T learn C(unless you have to for a job or something), it will distract you from doing more productive things with more advanced languages.

C++ offers everything you could ever want from C, and so much more.

Share this post


Link to post
Share on other sites
*sigh*

Some people strive for simplicity. C++ doesn''t offer that, at least, not as well as C does.

------------------------------
Simple DirectMedia Layer:

Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net''s Tutorials - (Here)

OpenGL:

Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)

Share this post


Link to post
Share on other sites
Ahh, but therein lies the beauty of C++; if you don''t want to use OO techiniques, you don''t have to.

C++ allows you to write programs in many different styles. You can use OO techiniques, if you want to, with full-blown multiple inheritence. Or you can use a subset of those with single inheretence. Or you can use generic programming techiniques with templates and the STL. Or you can use procedural programming techniques, like C. You can write structured programs, or have spaghetti GOTO logic.

In short, even if you used C++ to program as you would in C, you would still be better off because of strong type checking, const/inline functions instead of macros, better string(no char* pointer madness), and all the other cool little things that c++ provides.

Consider teaching a new C user how to read in a string from the keyboard and print it out. You have to mess with low-level memory, and it fails on inputs that are too large, and all these other little things.

In C++, however:

string s;
cin>>s;
cout<
It''s much more readable and conducive to learning.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Since when are OO features easy to use, have you read these forums?!

That''s not quite what I meant. I meant that it makes it easier to use OO features, but not that it is easy to use OO in general. It''s probably more a matter of opinion on whether or not OO is easy to use. Considering he''s coming from Java, OOP is probably ingrained in him. It''s kind of hard to explain what I meant, but it''s not what you think I said .
quote:
Original post by SilentCoder
In your first post, are you trying to say that I should begin with C++, and move on to C, and that C is better? Surely this can''t be true, as (the way I see it, which is almost certainly wrong ) C++ is a more advanced version of C. Can C do GUI-type-stuff (i.e. with a RAD)?

I think everyone should know how to use both C++ and C. They''re not very different, and being able to use both can''t hurt. If you''re wondering about functionality: anything you can do in C you can do in C++ and vise versa. If you ever have to program for a platform that doesn''t have a C++ compiler (the exist ) or company that doesn''t want to use C++ (lots of these exist), then knowing how to work without the features C++ adds would be a huge advantage . This is also hard to explain, I''m probably doing a poor job, heh.

Share this post


Link to post
Share on other sites
Okay, so C++ seems the better choice I think . One other thing: I know for a fact that Microsoft Visual C++ can use the DirectX API (as an example) in a Windows app. Would CBuilder be able to do the same? What I am trying to get at is are some things such as DX designed for a certain IDE/RAD (i.e. MS VC++), or are they like java packages in that I just have to include the compiled files, import them (in a C++ like way), and then use them? In other words, can some IDEs/RADs use APIs that others can''t?

Share this post


Link to post
Share on other sites
Yes, C++ probably is the better choice for a Java programmer. Just keep C in mind.

No, API''s and libraries aren''t designed for only a single IDE. However, sometimes the way they''re designed can limit them to a single compiler and/or linker. BCB comes with some tools (implib, et cetera) to help you convert the MSVC-formatted libraries to BCB-formatted libraries. However, since DirectX''s libraries are pretty weird, this may not work for some of them (I think DirectInput is the part everyone has problems with, D3DX is another).

You can download pre-BCB-formatted libraries for DirectX somewhere (try a search engine) but Microsoft no longer releases them.

Share this post


Link to post
Share on other sites