Sign in to follow this  
HuwFulcher

C, C# or C++?

Recommended Posts

Okay I want to learn a few game programming languages to get a head start in Uni but I'm not sure which of the three in the topic is best to start out with. Once I have a good knowledge of one or two of the above languages I will move onto Python and Java to cover all the bases :P

Share this post


Link to post
Share on other sites
Start with C# and make some simple programs (stuff that reads in a text file, a calculator, an organiser etc).

Then add in the XNA framework. There's some really clear setup and installation instructions on the XNA website on how to get started. There are also a few good tutorials to get you started making some simple games. It's free to make games for Windows and if you find yourself getting interested you can purchase a creators club membership for about £80 which allows you to publish for Xbox 360.

That should easily keep you busy for the next few months.

I would only move on to C++ once you are competent with object oriented principles (Classes, Abstraction, Encapsulation, etc) and data structures (stacks, queues, lists, etc).

[quote name='Huwtrosky' timestamp='1302444655' post='4796675']
Does Python have similar syntax? I've made a little application with C# before so it should be easier to get to grips with :)
[/quote]

Once you are adept at C#, python will seem incredibly easy to get to grips with. The only reason I would advise learning C# first is that it prepares you for learning C++ which will help you get into the games industry (which based on your previous threads; I am assuming is your goal)

Share this post


Link to post
Share on other sites
I may be a bit stuffy regarding that topic (or like reinventing the wheel) but I suggest using C++ if you really want to learn something. If you just want to "make game" use C# and XNA.
I don't want to start a C# discussion, but I know a lot (often younger) people who use C#, .net + Frameworks and consider themselves to be superior but in fact don't even know basic stuff. For example using linked lists etc. without knowing what it is. My two cents.:P
If your only goal is to be prepared for Uni use Java.

Share this post


Link to post
Share on other sites
In general, many concepts you learn with any programming language are going to be applicable to any other language. The kind of things I'm thinking about here include data types, flow control, data structures, etc. At your stage I think these are going to be of most immediate benefit to you, and will give you a decent head-start on your course. So pick the language that you feel most comfortable with right now, and exercise yourself a little on that. Try to push the boundaries of your knowledge.

If you want to get into games - aside from perhaps game logic scripting - you absolutely [i]must[/i] have more knowledge of what goes on "under the covers" than languages like C#, Python or Java provide. You need to know a lot of ugly details about pointers, memory architectures, algorithmic efficiency, and so on. I'd say don't bother with these for now; they'll only confuse you, or at worst put you off. But do bear them in mind as an avenue that you're going to have to explore at some time.

The same applies to C++/STL - it contains a lot of nice containers for handling common data structures, but unless you know what's going on behind the scenes with them you'll only end up using them inefficiently or inappropriately, and writing O(n[sup]2[/sup]) algorithms everywhere. You need - IMO - to know how to write, for example, a linked list yourself before you start using a pre-canned container. That way you know the correct access patterns to use for it, you know the incorrect access patterns, and - more importantly - you know [i]why[/i] they're correct and incorrect.

Share this post


Link to post
Share on other sites
If you're getting started in Uni soon so you know where you'll actually be going, I'd say take a look at their computer science department's web page or find some of their recent syllabi or talk to someone currently attending to find out what languages they're teaching right now. And go ahead and get the ball rolling in the same language.




If you don't know where you'll be going (like if things aren't lined up yet as it's too far in the future), then out of the 3 you offered as choices, I'd say C#. It's simpler to pick up than C or C++. And knowing it will ease a later transition into learning C++.

Share this post


Link to post
Share on other sites
[quote name='starvinmarvin' timestamp='1302458312' post='4796746']
I may be a bit stuffy regarding that topic (or like reinventing the wheel) but I suggest using C++ if you really want to learn something. If you just want to "make game" use C# and XNA.
I don't want to start a C# discussion, but I know a lot (often younger) people who use C#, .net + Frameworks and consider themselves to be superior but in fact don't even know basic stuff. For example using linked lists etc. without knowing what it is. My two cents.:P
If your only goal is to be prepared for Uni use Java.
[/quote]

Sorry but I think you might be missing the goal of software development. The goal is always to produce something. Languages are just tools. Do you have to know how to make or use a linked list to be a good developer? Not at all. Use the best tool to get the job done. If you are making a device driver, I would say, use c/c++. If you are making a basic windows app or indie game C# does the job just fine.

This whole "this language is the best" idea is just utter garbage.

Share this post


Link to post
Share on other sites
Common Lisp or maybe even Scheme. Primarily because they have a lot of good material for people new to programming in general. C and C++ don't, really. Also C# is more Java than C or C++. Maybe C# has good introductory material. I don't know. I thought the O'Reilly XNA book was pretty worthless.

The other advantage with starting with CL or Scheme is that a lot of the really interesting idea from those transfer really easily to something like Lua, and apparently Python and Ruby as well though I don't really know those.

The problem with starting in C++, I think, isn't so much that C++ is hard, but that a lot of the pedagogy and theory about it is either bad or flat-out wrong. I don't know much about C beginner materials. It might be better.

Share this post


Link to post
Share on other sites
To be honest, I would start with C++ then C# and would leave C alone first.
Why?
Many C# or Java Programmers going over to C++ have a bad habit in using new for everything, but never delete. I see this on various forums all day.
C Programmers going over to C++ have the bad habbit in writing C with Classes and ignoring C++ Features like Vectors, Strings etc and pack everything and their mother into Arrays and void-pointers, giving up typesafety of C++.

Thats very zynical, I know. But is the daily truth to some degree. May not fit upon you, but fits on many other people :D.
You can see "C with Classes" a lot when students from University are posting Threads with the tasks from their professors. :lol::cool:

Share this post


Link to post
Share on other sites
Ive just completed the two 100 level computer science courses at my uni that are required to move on to 200 level. There are two variations, two with java and two with c++. I did the C++ version, and really its just c (someone called it better c). posting questions on the cplusplus site the response was "why arent you using x feature of c++. Anyway what I got from the conversation that followed was that, first I wasnt using c++ second, that its standard for students to start with c in order to learn the basics and how things work before having the language do it for you, ie arrays vs vectors (roll your own lists before using the built in ones) or cstrings over strings (roll your own character handling before using the languages). My recommendation after coming out of the first year courses would then definitely learn c, as well as classes and structures.

I wouldnt recommended java first because the profs have told me that c++ is gaming standard and AFAIK this is correct. Also the higher courses are primarily c++, java is offered for those taking intro comp sci as a requisite for another program.

Just my two cents. But Im really a phil major so who knows lol.

Edit: check out [url="http://www.cplusplus.com/reference/"]http://www.cplusplus.com/reference/[/url]. This site has literally been my textbook. Id start with the c library and work down. The most important parts for me were cmath, cstring, cstdio, and maybe ctime for random number generation. The projects we did were all console based, and the final projects were a connect 4 in the console and icebreaker in the console. Small projects revolved around getting to know the language. Hope it helps.

Share this post


Link to post
Share on other sites
[quote name='MeshGearFox' timestamp='1302506108' post='4796970']
I think C++ is better regarded as C with self-referential structs and Haskell-esque metaprogramming.[/quote]You took that quote completely out of it's context there to the point of it being meaningless to quote it....He wasn't regarding C++ as "C with classes" in the slightest.

Share this post


Link to post
Share on other sites
It is better to learn one language and master it than to learn 10 languages and google everything more advanced :)
I suggest C++ - it is not so difficult and it is usable on every platform...
When you master C++ every other language will be easy for you.

C# without .NET framework can do nothing, also Python and Java need a lot of stuff around them.
If you start with Java/C# you receive bad habitats and later you shall have problems with memory allocs etc.

I hope you do NOT think about such languages as C/Pascal -> those are nor for professionals!

Share this post


Link to post
Share on other sites
[quote name='TSlappy' timestamp='1302508847' post='4796990']I hope you do NOT think about such languages as C/Pascal -> those are nor for professionals!
[/quote]
Doesn't Linus Torvald's use C? I understand he not only likes to not use C++, but also likes to not use C++ programmers.;)

Share this post


Link to post
Share on other sites
[quote]
It is better to learn one language and master it than to learn 10 languages and google everything more advanced [/quote]
While you should certainly master at least one language, you should also learn many languages. These will teach you to think outside the box your language of choice puts you in.

[quote]
When you master C++ every other language will be easy for you.[/quote]
Definitely not true. It won't help in the slightest for languages with vastly different paradigms like Prolog, Haskell or Erlang.

[quote]
C# without .NET framework can do nothing, also Python and Java need a lot of stuff around them.[/quote]
Irrelevant. C without the runtime is pretty limited. You couldn't allocate dynamic memory, manipulate files or read/write from standard input. Even with the C runtime, you are pretty limited in that there is no standard support for threading, graphics, sound and many other parts of a computer.

[quote]
If you start with Java/C# you receive bad habitats and later you shall have problems with memory allocs etc.[/quote]
[i]Bullshit[/i]. If you start with [i]any[/i] language you can learn habits that could be considered "bad" in the context of a different language, i.e. that they won't translate directly into said language. It doesn't make the habits themselves poor. It is like saying that learning idioms in spoken language is poor practise because you won't be able to use them in other languages.

[quote]
I hope you do NOT think about such languages as C/Pascal -> those are nor for professionals! [/quote]
You'd be surprised. C is still a viable tool for the modern professional. Pascal is rarer, but legacy support has a long tail.

Share this post


Link to post
Share on other sites
From my experience with university and self taught programming, I'd strongly recommend that you start by learning C. I mean pure C, not C++. This way you start with a simpler, structural language and without the overhead of oop you can focus on learning how to use a language properly in its simplest form and also how to be reasonably efficient and save in regards to memory handling. As a lower level langauge than C# or Java or even C++ (in some ways) C also forces you to learn more about how compilers work and what they actually do to the code you write and how to make the most of their capabilities. I wouldn't recommend using C for anything practical, apart from some training, instead - think of it as if it was Latin - a dead language (not true in case of C, but just bear with me :)), but also the foundation of most of European languages. You can't really chat up foreigners with it, but it will make it easier for you to learn any modern, European language. In case of C - modern oop languages, of course.

Once you get there, jump over to C# or Java. I'd recommend C# for a variety of reasons, but it is my personal choice - some people prefer the latter. C# is definately a good language for learning oop, easy to get into and manipulate, enjoyable and most of all it is ready for production - grab XNA (or SlimDX or whatever) and you can start writing games. If that fulfills all your needs, I'd stick with i - If it ain't broke, don't fix it. If that's not the case (you want more efficiency, use only C++ compatible engines etc.) only then progress to C++.

However, as proven by a number of replies, there are different schools of thought on the subject. You will probably end up finding your own way, just remember not to be sceptical about anything - some people will tell you that C# and Java or Z [input another modern programming language of choice here] are rubbish, for X and Y reasons. In the same manner, C programmers used to bash C++ and C was loathed in its time, as well. Just give whatever interests you a go and don't get disencouraged, because of other people's opinions - sure, they might turn out to be right, but they may also turn out to be simply ignorant, arrogant or both.

Share this post


Link to post
Share on other sites
Pascal also has a relatively modern OO implementation in Delphi which was quite widely used not too long ago, and likely still is in certain quarters. Expressing language elitism and snobbery establishes nothing other than that you're a language elitist and a snob.

Learn concepts, not languages. So long as the paradigm isn't too wildly different, knowledge of the concepts will enable you to pick up and meaningfully use any new language in a very short time indeed.

Share this post


Link to post
Share on other sites
If I were starting over I would begin with Python. It's a beautiful language, and you'll certainly get results much quicker than with something like C or C++ (can't speak for C# -- haven't used it yet). As a beginner, I stubbornly refused to learn anything other than C++, thinking that doing so would be sacrificing power & control. But being able to finish a project in a reasonable timeframe turns out to be amazingly powerful, and C/C++ are not best suited for that.

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1302507122' post='4796979']
He wasn't regarding C++ as "C with classes" in the slightest.
[/quote]



I know.


[quote name='Domx' timestamp='1302521522' post='4797053']
I wouldn't recommend using C for anything practical, apart from some training, instead - think of it as if it was Latin - a dead language (not true in case of C, but just bear with me :)), but also the foundation of most of European languages. You can't really chat up foreigners with it, but it will make it easier for you to learn any modern, European language. In case of C - modern oop languages, of course.

[/quote]

Latin is the foundation of the modern Romance languages which are a sub-family of the Italic languages (everything non-Romance being extinct AFAIK). It is NOT the foundation of any other Indo-European language families. Furthermore, most of the modern Romance languages are pretty distant from Latin. Only Romanian really retains the case system and that's had such a huge influence from the Slavic languages in terms of vocabulary that Latin wouldn't really help with that much.

Similarly if you learn C, you'll probably have an okay time with anything that's deliberately C like, and a decidedly non-okay time with, say, J.

Share this post


Link to post
Share on other sites
Man, these threads get out of control quickly. In a broad sense, it doesn't matter what you pick. My recommendation is C#, with Python being a close second. These languages are easier to manage, in the sense that you can get a working program done more quickly/directly than other languages. This lets you focus on programming concepts, rather than entangling those concepts with syntax that can be highly language-specific.

But whatever you choose, you're going to be fine. You mentioned that you'll be going to University soon, where you'll be getting formal training in computer science and programming and several languages (I assume, that's a pretty standard curriculum). I would still pick something that will get you going quickly and (relatively) easily, like C# or Python. But don't fret about what you start with right now.

Share this post


Link to post
Share on other sites
[quote]
Latin is the foundation of the modern Romance languages which are a sub-family of the Italic languages (everything non-Romance being extinct AFAIK). It is NOT the foundation of any other Indo-European language families. Furthermore, most of the modern Romance languages are pretty distant from Latin. Only Romanian really retains the case system and that's had such a huge influence from the Slavic languages in terms of vocabulary that Latin wouldn't really help with that much.
[/quote]

Indeed, that's a bit of an oversimplification on my part. However, despite Latin only being the foundation of French, Italian, Spanish and other Romance languages, its influence had a great impact on both Germanic and Slavic languages (not sure about the Ugro-Finnic family though) and there plenty of shared words and phrases that you can understand knowing Latin, but not necessarily the given language. I'm no expert, as you seem to be, MeshGearfox, but as an English and Polish speaker (with a little Latin training) I can easily see the overlaps, which sometimes really prove helpful...

[quote]
Similarly if you learn C, you'll probably have an okay time with anything that's deliberately C like, and a decidedly non-okay time with, say, J.
[/quote]

..and I think this also applies to C. Plenty of languages are based on it directly or indirectly or were influenced by it in a relatively strong way. Functional languages are a definite exception, but apart from them, most languages used in game development inherit from C. According to wiki, programming languages influenced by C include: AMPL, AWK, csh, C++, C-- , C#, Objective-C, BitC, D, Go, Java, JavaScript, Limbo, LPC, Perl, PHP, Pike, Processing, Python.
Knowing C, you can pick up most, if not all, of these quite easily.

Share this post


Link to post
Share on other sites
[quote name='MeshGearFox' timestamp='1302506108' post='4796970']
[quote]C with Classes[/quote]

I think C++ is better regarded as C with self-referential structs and Haskell-esque metaprogramming.


[/quote]

The title of C with Classes goes to Objective-C, with the addendum "and a suicide inducing syntax"

Anyway, I'll clear up a few myths here and now.

1) C++ is not the superior, be all end all language. It's a powerful one, a widely used one, and a useful one for game development, but not inherently "better" than other languages. Computer languages are tools, and they perform different tasks. C++ is kind of like a chainsaw, you can cut down trees with it, you can cut boards with it, you can cut your own foot off with it, you can even carve an elegant statue with it if you're good enough, but it won't do you a damn bit of good if you just need a screwdriver.

2) There is no right or wrong language to learn first. Hell, I don't even think there's a best language to learn first. Learning language X first is not going to screw you over by forming Y bad habbits. Yeah, a novice learning C# might have bad or non-existent memory management skills, but I can guarantee you that a novice learning C++ will have shit-tastic memory management skills, too. The difference there is that C# will keep chugging along with its garbage collector, while C++ will just kind of roll over and die, which can be a frustrating and confusing experience for someone just starting off. You're going to make mistakes and have to re-learn stuff no matter which language you start with. That's just a part of learning a new skill.

3) C++ is not nearly as hard and scary as people make it out to be. Honestly. I was totally surprised when I started learning C++ only after several years of programming other languages. I was expecting that I'd have to pore over tomes both ominous and arcane in nature for years, but quickly discovered it was basically like every other OO language out there with some extra quirks and manual memory management. Not a big deal.

Now, I'll talk about some advantages and disadvantages to picking up various languages first.

1) Python: A very simple scripting language that's loads of fun to work with. It has a c-ish syntax, so it will get you used to that. It's really easy to pick up and learn, with a very bare minimum of boilerplate code (long, repetitious code needed to perform even simple tasks) and eliminates most barriers between you and programming. The limitation here is that you're not going to be writing the next Crysis in Python. It's definitely not a throwaway language, knowing scripting languages is really useful for game programmers and Python's used out in the wild.

2) C#: A really cool language that's powerful and has a clean syntax. It's like Java, but with a lot of the bullshit removed. You can do some pretty serious work with C#, and it will set you up to work your way into XNA, a great library for developing games that's quite powerful. C# will also introduce you to serious Object-Oriented programming, which is absolutely critical to learn as a programmer. It does have its limitations, however, being that it trades usability and ease of use for the extreme degree of control that C++ gives you.

3) C: A classic, very clean language. It's not OO, so you'll be limited there, but it does introduce you to very important concepts like manual memory management and pointers that are abstracted away in a higher level language like C#. This language is, and probably will forever be, useful, and I strongly believe every programmer should learn C at some point. I cut my teeth on C taking a course programming games for the Gameboy Advance, which was super super fun. I'd advise you not jump out the gate making GBA games, though, since it does require some intermediate knowledge of programming.

4) C++: An extremely powerful and useful language that has broad application to game development. You can't go wrong here, and probably will have to learn C++ at some point (you really should). You can learn it as a first language, but it's not as friendly as C# or Python or even C. The syntax can get messy (in my opinion) and you will have to deal with some of the more tedious and confusing aspects of programming that C# and Python do for you. Still, this is valuable stuff to learn and C++ can scale down very well, approaching C-like levels of simplicity and cleanliness. A good book or tutorials can guide you safely through C++ as a first language.

I think the above are all really solid picks for first languages. Personally, my progression when I learned to program was Python->Java/C#->C->C++ (with like, 20 other miscellaneous langauges strewn about along the way). This certainly worked well for me, but I wish I'd gotten around to C++ a bit sooner.

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