Sign in to follow this  
Edo

c#, c++, what's the difference?

Recommended Posts

Hello everybody. As you've probably guessed by the fact that I'm posting in the beginners section, I am a complete noob at programming. I have made an effort though, and I have learnt the basics of virtual basic 2005 express, And understand the gist of it. But I am thinking of spending my time with the c++ language instead, as the general consensus appears to be that although it is harder, in the long term it is a better place to start from, particularily in the case of game development, which is a line I wish to pursue. I have encountered a problem though, and that is which of the 'c' languages to use. This has probably been posted hundreds of times here before but I would still like an answer. However, there is another 'c' language I found on the mdn website, which is c#. This was there, presumably in the place of normal c. Am I correct in thinking this is the next version of c? Also, some general advice on which of the three c's to use wouldn't be amiss. This may seem quite a noobish question, but we've all got to learn somewhere, so I'd be very gratefull for any answers. Thanks

Share this post


Link to post
Share on other sites
C# is a completely different language from C or C++ that runs on .NET. It's roughly like VB .NET with a more C-like syntax. It's not really a vesion of C in any sense.

If you want to start with either C#, C or C++ then I would suggest C# first, especially since you have a VB .NET background. Also, if your goal is to eventually use C++ then I would suggest skipping learning C entirely and go right to C++ whenever you decide to do leave the .NET languages.

Share this post


Link to post
Share on other sites
You'll find that when you leave the .NET languages, you'll start having to do more work for yourself, either writing the routine yourself or looking for a suitable component on the internet. Either way, moving from VB.NET to C# will only require you to learn a new syntax, while moving from VB.NET to C++ will require a new syntax and a new set of APIs to work with. Either way stay away from C, which has all the limitations of C++ without any of the benefits.

On a side note, I disagree with what SiCrane said, that C# is a completely different language. Sure, the APIs you use differ drastically, but the syntax is very similar. When I think of a language, I think of its syntax. Other things don't matter as much, because something you can accomplish in one language can almost always be accomplished in another language. Going from C++ to C# was easy for me, while even looking at a few lines of VB code makes me want to puke.

Share this post


Link to post
Share on other sites
C# is a very modern programming language largely inspired by C++, with an extensive framework (libraries with functionality you can use out-of-the-box). C++ on the other hand is starting to age, but there is a lot of code available for it as it has been considered the 'standard' for high-end game development for years and still is.

C++ is compiled directly to executable code, whereas C# is compiled to byte code. It is further compiled to executable code when the application is started. This has the advantage that C# code can run on different platforms (operating systems and processors), but also that there's a (typically minor) performance penalty compared to C++. For cutting edge game development direct access to the system is preferred, for which C++ is the only option.

However, for a beginning programmer C# is an excellent choice. It's a very clean language and doesn't have many of the pitfalls C++ has. Once you master C#, it's easy to learn C++ if you really need it.

So where does plain C fit in? It's a legacy language with no bells and whisles at all. It's easy to learn but hard to use for a large project because it has little structure compared to object-oriented languages like C++ and C#, and you have to do truely everything yourself (which on the other hand makes it easy to understand because nothing happens behind your back). Anyway, you can still write pure C code in C++ as well, so except on platforms where there is no C++ compiler there's little reason to write a project in C nowadays. But it's not a bad idea though to spend a few days writing C applications so you'll learn some very fundamental programming aspects. But don't stick with it for too long or you will have learned bad habits when you enter the object-oriented world.

So my suggestion is to have a look at some C tutorials just to get the fundamental concepts, and then quickly go to C# for a clean, modern and powerful programming language. You won't need the ultimate power (and ultimate difficulty) of C++ for years so try to avoid it.

Share this post


Link to post
Share on other sites
Quote:
Original post by ussnewjersey4
On a side note, I disagree with what SiCrane said, that C# is a completely different language. Sure, the APIs you use differ drastically, but the syntax is very similar. When I think of a language, I think of its syntax. Other things don't matter as much, because something you can accomplish in one language can almost always be accomplished in another language. Going from C++ to C# was easy for me, while even looking at a few lines of VB code makes me want to puke.

Thinking about a language solely in terms of syntax is a flawed point of view. For example C, C++ and C# have all different, and largely incompatible, mechanisms and idioms for making sure resources don't leak in case of an error condition. Just because you understand a language's syntax doesn't mean you understand the language.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this