• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
SLaYaH

C or C++ or C#

47 posts in this topic

I am stuck trying to decide, originally I was only deciding between C or C++ but now theres C# and I'm not sure what to do. If at all possible I'd like to know pros and cons of each and whcih you would suggest to learn coding for an ALL AROUND programmer, not just for gaming but may be part in gaming. Thanks in advanced.
0

Share this post


Link to post
Share on other sites
C: Sucks (But used a lot in operating systems, or embedded stuff)
C++: A pain in the ass.
C#: Nice and easy to use.

The best thing to do? Learn all of them.
I'd suggest starting with C# though.
0

Share this post


Link to post
Share on other sites
A lot depends on what your goals are but I am a big fan of C# now days.

C is mainly used for legacy stuff, micro-controllers and some driver work.

C++ lots of code, examples and tutorials out there. Also a lot of people working in it, so lots of advice. A lot to learn just to get the basics down.

C#, still the new kid of the block, a lot less typing then C++ to get the same thing done. Memory management is taken care of for you. Good libraries.

theTroll
0

Share this post


Link to post
Share on other sites
I'd agree with learn all of them.

C - I don't mind so much. It takes a bit to get comfortable with pointers and memory management, but once you get it you're all set.

C++ - I think of this as a necessary evil. I like a lot of the OO features in C++, but I hate some of the dumb notation (cout << "Hello World"; looks strange with the << compared to C's printf("Hello World!");). It's all preference though.

C# - I LOVE C#. I use XNA and .NET for all my primary programming. I recently started working with C# in OS X too because I liked it so much.

So I'd say learn C# first because it has a little bit easier learning curve. Then take on C because it'll probably be useful at some point to know it. Then learn C++. C++ builds a bit on C so knowing C will help you a lot with C++.
0

Share this post


Link to post
Share on other sites
C# is the easiest beginner language of the three

C++ you'll need to get a job in the game biz

C is good to know

-me
0

Share this post


Link to post
Share on other sites
I agree with everyone - C# is a great language to start with

Quote:
Original post by TheTroll
C++ lots of code, examples and tutorials out there. Also a lot of people working in it, so lots of advice. A lot to learn just to get the basics down.


While this is true an enormous number of tutorials on the internet are complete crap and teach terrible habits. For some reason there is more misinformation about C++ floating around the net than most other langauges.

0

Share this post


Link to post
Share on other sites
Personally i found c++'s extra challenge over c# interesting (pointers, memory management), but it's a matter of taste. Especially if you know c++, it will be really easy to learn the other 2. The same holds for c# to some extend. I really can't think of a reason to stick to pure c when c++'s oop features make your life so much easier, so my suggestion is: Try c# and c++ and pick the one you like most. Then learn the other one too if you want; it will be easy.
0

Share this post


Link to post
Share on other sites
It depends on what you want to get from your learning experience. C# is probably the easiest to learn, in part because the .net framework (its standard library) is very thorough and its API reflects its RAD (Rapid Application Development) origins. You feel very productive with C#.

On the other hand, C is a great language to learn how the computer works as a machine, because it provides no high-level abstractions of its own and essentially frees the programmer to do whatever they wish (Hardware/OS restrictions aside.) You can, for example, impliment features in C that are commonly found in OO languages like C++ or C#, such as polymorphism. C can give you a window into the workings of things that you might take for granted in another language. Another plus is that C is a much smaller language than, for example, C++ (in both the number of keywords and the scope of its built-in features) so you can get your head around it more quickly.

C++ is, to a certain extent, the oft-maligned industry standard. Realistically speaking, C++ is the language you must know to develop games (and most other software) professionally, at least for now. Its not a bad language, but its not a great one either. In the years since (and some would even say prior to) it's creation, more practical and elegant solutions have been devised to many of the issues it was created to address. There are certainly better Object-oriented languages than C++. There are certainly better Procedural, Functional and Aspect-Oriented languages as well. Where those languages typically "fail", is that they support one paradigm really well at the expense of the others -- C++, on the other hand, is generally considered to be a multi-paradigm language: It doesn't reign over any one paradigm, but it can do them all with varying levels of effort and success.

Its a bit like you're going on a trip abroad and need to hire a translator. If you're just visiting France, it makes sense to hire someone fluent in French -- but if you're taking a trip across Europe, it makes more sense to hire a translator who, while not fluent any one of the languages in question, speaks them all well enough. Sometimes you can't, for various reasons, hire a new translator for every region you visit. The same is often true in the professional software world -- most of the time you can't choose the best language for the job with each new project. This, combined with easy migration from C, is why C++ is the dominant language today, in my opinion.


Which language is best for a beginner though? Its hard to say. I'll go out on a very short limb and say that its not C++. Its simply not a language which has a scope that's fit for a beginner. Personally, I went from C to C++, and had prior experience with various BASIC dialects. This was a fit for me because I'm the type of person who likes to learn from the bottom up. For those more inclined to the top-down approach, C# will probably provide more immediate satisfaction. In either case, C++ will have to be learned down the road if you intend to pursue programming professionally. Even if you don't end up using it as your primary language, its position as a very popular, multi-paradigm language has essentially made it the language of the masses, so even if you do not write it, you still must be able to read and understand it.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by ravyne2001
On the other hand, C is a great language to learn how the computer works as a machine


No it isn't. C is an abstraction like every other language and has very to do with how the computer works as a machine. There have been numerous posts by myself an others about this misconception. There is one language that will help you learn how the computer works as a machine and it's the appropriate assembly language.

C is useful because there is a C compiler on virtually every platform you can imagine and because its runtime is very small. Very few other languages can make this claim (Forth comes to mind).
0

Share this post


Link to post
Share on other sites
Okay from what I have read, and thank EVERYONE that has replied for their replys again I really appreciate your time.

I should learn C# for the time being because it is the easiest language to start out with, then move on to C++ for game dev, and knowing some C would be good on the side.

What would be the preferred C# compiler?
Should I start learning C# from the workshop you guys have here ?

Thanks in advanced again.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by cshowe
There is one language that will help you learn how the computer works as a machine and it's the appropriate assembly language.
Well, no. Assembly is a bit better than C in terms of exposing you to the details, but there's still so much that is hidden from direct view that simply learning to write assembly is woefully inadequate.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by cshowe
Quote:
Original post by ravyne2001
On the other hand, C is a great language to learn how the computer works as a machine

No it isn't. C is an abstraction like every other language and has very [little] to do with how the computer works as a machine. There have been numerous posts by myself an others about this misconception. There is one language that will help you learn how the computer works as a machine and it's the appropriate assembly language.

Stop being argumentative just for the sake of it :P
You're not seeing the woods for the trees...

C is *closer* to machine level than higher level languages like C# (i.e. it has raw pointers, can be freely mixed with assembly code, etc...).
Everyone (including ravyne) knows C isn't machine level, but it's C L O S E R.

e.g. #1 Learning how to deal with strings correctly in C will teach you a lot more about "how the computer works as a machine" compared to using a C++/C#/Java/etc string class.

e.g. #2 You can write a program in C that accepts an arbitrary hexadecimal value from the user and tries to read 17 bytes from that memory address (which may well cause a seg-fault etc...). Higher languages such as C#/Java won't let you do silly low-level things like this because they are *more abstracted*.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Promit
Quote:
Original post by cshowe
There is one language that will help you learn how the computer works as a machine and it's the appropriate assembly language.
Well, no. Assembly is a bit better than C in terms of exposing you to the details, but there's still so much that is hidden from direct view that simply learning to write assembly is woefully inadequate.


Yeah that's a good point actually. I'm so used to thinking of assembly only in ring 0 that I forgot that it's easy to learn it without all the architecture stuff.

0

Share this post


Link to post
Share on other sites
Quote:
Original post by SLaYaH
Okay from what I have read, and thank EVERYONE that has replied for their replys again I really appreciate your time.

I should learn C# for the time being because it is the easiest language to start out with, then move on to C++ for game dev, and knowing some C would be good on the side.

What would be the preferred C# compiler?
Should I start learning C# from the workshop you guys have here ?

Thanks in advanced again.


The workshop's probably a good idea. Otherwise you can grab a cheap C# book for probably less than $20.

As for compilers, there's really only two that are used: Microsoft Visual C# (you can download Visual C# Express for free) and the Mono Project. Being that you're likely on Windows, get Visual C#. Mono is great if you're doing C# on Mac or Linux, but on Windows there's really no point. Go download Visual C# Express and that'll be everything you need. (Edit: You might also want to download Visual C# Express SP1)
0

Share this post


Link to post
Share on other sites
I prefer using C. There are some newer games programmed in C (e.g.: Halo, City of Heroes/Villains)

Also, John Carmack used C for every id project up to (but not including) Doom 3.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Hodgman
good points


I'm not sure I really agree. As you state there are two things that C allows you to do that managed languages don't One is pointers and direct access to "memory", the other is integration with assembly.

The first is really just another (huge) abstraction. Even in managed languages there is some sense that you have 4GB of memory to allocate and that it's stored in memory some place and that you can refer to these things by addresses (both C# and Java have references). On the other hand even in C you're living in a flat address space by yourself - an abstraction that is very far from the actuality of the machine. So I'm not sure that pointers actually teach you that much more about the machine.

I think that people tend to associate C with understanding the computer because it's traditionally used in operating system programming, device drivers, and other truly low level programming. Here the interface with assembly is essential to actually making things work. But learning hello world in C and hello world in C# teaches you exactly the same amount about computers. Just because a program is written in C doesn't mean that it's teaching you about low level machine architecture (as Promit pointed out neither does assembly). But telling beginners that they'll come to great understanding about the way the computer works by learning C is not accurate or particularly helpful - they'll understand how a computer works by studying systems architecture and not by learning a language.

All that said I do agree that C is slightly less abstracted than C# so maybe I'm just nitpicking and derailing the thread

0

Share this post


Link to post
Share on other sites
Quote:
Original post by cshowe
Quote:
Original post by ravyne2001
On the other hand, C is a great language to learn how the computer works as a machine


No it isn't. C is an abstraction like every other language and has very to do with how the computer works as a machine. There have been numerous posts by myself an others about this misconception. There is one language that will help you learn how the computer works as a machine and it's the appropriate assembly language.

C is useful because there is a C compiler on virtually every platform you can imagine and because its runtime is very small. Very few other languages can make this claim (Forth comes to mind).


do you really not believe that C is a good approximation of the VIRTUAL MACHINE that most other development is built upon? People don't design a language like ruby out of the available pieces of assembly language for a particular system like PowerPC or PDP-11, they design it abstractly, then map it back to the C abstraction (or something sitting on top of it).

C is and has been the near-universal lowest-level programming "machine" for cross-platform development since at least the late 80s. Sure there are others and always have and will be. Sure some people need raw assembly language - primarily as an optimization of the implementation of something, NOT to design with.

P.S. Sorry for hijacking the thread.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Hodgman
C is *closer* to machine level than higher level languages like C# (i.e. it has raw pointers, can be freely mixed with assembly code, etc...).

No it can't. Certain implementations of C offer inline assembly. How "freely" the two can be mixed is highly variable. And C# has pointers, and at least one C# compiler supports inline MSIL assembly. So, you're wrong all around, basically.
Quote:

e.g. #1 Learning how to deal with strings correctly in C will teach you a lot more about "how the computer works as a machine" compared to using a C++/C#/Java/etc string class.

No, it'll teach you about how C-style strings work. Given that they work the same on all implementations of C, even when running on machines with wildly differing architectures, that should be a clue that string handling doesn't reveal the secrets of "how the computer works as a machine".
Quote:

e.g. #2 You can write a program in C that accepts an arbitrary hexadecimal value from the user and tries to read 17 bytes from that memory address (which may well cause a seg-fault etc...). Higher languages such as C#/Java won't let you do silly low-level things like this because they are *more abstracted*.

C# will let you do silly things like that, not that it matters. The ability to crash your program by probing random memory addresses does not make a language "closer to the metal". BASIC allowed you to probe random memory addresses, yet it was, in many ways, "higher level" than C.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by cshowe
they'll understand how a computer works by studying systems architecture and not by learning a language.

You hit the nail on the head there.

Learning to use C without understanding how the OS works probably just creates more voodoo/cargo-cult coders ;)
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Xai
do you really not believe that C is a good approximation of the VIRTUAL MACHINE that most other development is built upon?

No. C is an abstraction of machines that were cutting edge several decades ago. Most modern programs are developed on machines where C's view of the world just isn't applicable. "C the language" doesn't understand that many computers have more than one processor, or that memory is arranged in a heirarchy of caches, amongst other things.

A language which was actually designed to represent the realities of modern computer hardware would contain explicit language-level support for multiprocessing and cache-aware memory control.
0

Share this post


Link to post
Share on other sites
@Nathan Baum
I don't like your tone mate, can you keep it civil eh?

Quote:
Original post by Nathan Baum
Quote:
Original post by Hodgman
C is *closer* to machine level than higher level languages like C# (i.e. it has raw pointers, can be freely mixed with assembly code, etc...).

No it can't. Certain implementations of C offer inline assembly. How "freely" the two can be mixed is highly variable. And C# has pointers, and at least one C# compiler supports inline MSIL assembly. So, you're wrong all around, basically.

Are you really trying to argue that C isn't less abstracted than C#? That's all I was saying... Again, can't see the woods for the trees...

Generally speaking, if you have a "certain implementation of C", like the MSVS version that is in wide use, you can include inline assembly in your C files. Also, all pointers in C are "raw" (as opposed to C# which includes "managed" pointers).
If both of those general statements are true, then how am I "wrong all round"?

You're not even arguing against my point (that C is less abstracted) - you're trying to find specific cases where my statements are also true for C# (in effect, trying to argue that C# is not more abstracted than C).

Quote:
Original post by Nathan Baum
Quote:

e.g. #1 Learning how to deal with strings correctly in C will teach you a lot more about "how the computer works as a machine" compared to using a C++/C#/Java/etc string class.

No, it'll teach you about how C-style strings work. Given that they work the same on all implementations of C, even when running on machines with wildly differing architectures, that should be a clue that string handling doesn't reveal the secrets of "how the computer works as a machine".

Again, you're not arguing against my point - I didn't say that it would "reveal the secrets", I was trying to illustrate that using lower level constructs teaches you more about the machine than using higher level constructs.
Do you dispute this point, or are you just being argumentative without reason?

C-style strings involve manually dealing with pointers/arrays/null-termination, which are all low-level concepts. In contrast, C++/C#/Java strings involve using a simple high-level API.
Therefore learning to use C-style strings will require more low-level knowledge, which in turn reveals a thinner abstraction to "how the computer works as a machine".

Quote:
Original post by Nathan Baum
Quote:

e.g. #2 You can write a program in C that accepts an arbitrary hexadecimal value from the user and tries to read 17 bytes from that memory address (which may well cause a seg-fault etc...). Higher languages such as C#/Java won't let you do silly low-level things like this because they are *more abstracted*.

C# will let you do silly things like that, not that it matters. The ability to crash your program by probing random memory addresses does not make a language "closer to the metal". BASIC allowed you to probe random memory addresses, yet it was, in many ways, "higher level" than C.

Ok, I'm not that experienced with C# so scratch it from my quote. My point still stands though - AFAIK, Java's version of 'pointers' ('references') can't be assigned to arbitrary memory addresses - the language's abstraction of memory is "more abstract" than C's abstraction of memory.
0

Share this post


Link to post
Share on other sites
Quote:
Ok, I'm not that experienced with C# so scratch it from my quote. My point still stands though - AFAIK, Java's version of 'pointers' ('references') can't be assigned to arbitrary memory addresses - the language's abstraction of memory is "more abstract" than C's abstraction of memory.


Well since "C the language" doesn't define the behavior of doing such things the only difference is that in one the compiler checks it and issues a error message and in the other it doesn't, in fact since it's undefined a smart enough C compiler can issue an error message at compile time if it wants (although I don't know of any that do).
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Julian90
***nitpicking***

That's not the point (and this hypothetical smart compiler could only catch that error in specific cases).
C pointers are numbers, Java pointers are numbers in bubble-wrap.
Hence, to learn low-level computing concepts, C is probably more appropriate than Java.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Hodgman
@Nathan Baum
I don't like your tone mate, can you keep it civil eh?

I'm confused. Where has he been anything but civil? Normally we're a bit abrasively blunt, but I'm not even seeing anything I'd qualify as that in his posting (to my suprise!)

Quote:
Are you really trying to argue that C isn't less abstracted than C#?


C attempts to be a complete abstraction of assembly, just like C# is to bytecode (assembly or otherwise). The fact that it's such a leaky one in it's attempt isn't in it's favor -- it's just leaky enough to be a pain in the ass without actually uncovering anything at all useful whatsoever. That takes skill... or in this case, legacy.

Quote:
Generally speaking, if you have a "certain implementation of C", like the MSVS version that is in wide use, you can include inline assembly in your C files. Also, all pointers in C are "raw" (as opposed to C# which includes "managed" pointers).


Actually, C# managed references are going to use the exact same patterns as C++ ones, the C# environment just knows that it's allowed to take advantage of that information too for GC. C# can also use C++ style "raw" pointers with the use of the unsafe keyword. Unlike C++, it teaches a fundamental computing truth: Full manual all the time is a bad idea (tm) because programmers are fallible humans.

Quote:
Quote:
Original post by Nathan Baum
Quote:

e.g. #1 Learning how to deal with strings correctly in C will teach you a lot more about "how the computer works as a machine" compared to using a C++/C#/Java/etc string class.

No, it'll teach you about how C-style strings work. Given that they work the same on all implementations of C, even when running on machines with wildly differing architectures, that should be a clue that string handling doesn't reveal the secrets of "how the computer works as a machine".

Again, you're not arguing against my point - I didn't say that it would "reveal the secrets", I was trying to illustrate that using lower level constructs teaches you more about the machine than using higher level constructs.


No, it teaches you more about just those "low level" concepts. Are those concepts useful to programming, or actually teach you anything about how computers work? No. They'll show you a sliver of how they worked on a 286, but modern hardware merely emulates that model for backwards compatibility.

Hell, even x86 is a bit of a sham now. Modern CPUs merely decode it into their own internal microformats for actual execution.

Quote:
C-style strings involve manually dealing with pointers/arrays/null-termination, which are all low-level concepts. In contrast, C++/C#/Java strings involve using a simple high-level API.

Which will give you more time to read a book on how computers actually work, with information actually relevant to modern programming, some of which Nathan mentioned -- such as knowing the effects of the various cache layers on your code.

Or, for example, reading why null termination is horribly inefficient. Note that C's strlen/strcpy/strcat all abstract away the reason behind this just as much as those higher level APIs would if they were as broken as C is in their choice of preferred string format.

Quote:
Quote:
Original post by Nathan Baum
Quote:

e.g. #2 You can write a program in C that accepts an arbitrary hexadecimal value from the user and tries to read 17 bytes from that memory address (which may well cause a seg-fault etc...). Higher languages such as C#/Java won't let you do silly low-level things like this because they are *more abstracted*.

C# will let you do silly things like that, not that it matters. The ability to crash your program by probing random memory addresses does not make a language "closer to the metal". BASIC allowed you to probe random memory addresses, yet it was, in many ways, "higher level" than C.

Ok, I'm not that experienced with C# so scratch it from my quote. My point still stands though - AFAIK, Java's version of 'pointers' ('references') can't be assigned to arbitrary memory addresses - the language's abstraction of memory is "more abstract" than C's abstraction of memory.


I thought we were talking about C#, not Java. I mean, it's just in the freakin' thread title. Yes, there are HLLs that will forcibly abstract things even higher, we generally don't have much love for Java around here.

Forcibly deabstracting things like C does, however, is also the wrong answer. With flexibility comes the ability to do whatever you want whenever it's appropriate. Telling a beginner to use a language that's unsafe by default in it's very design, before mastering even the most basic of concepts of programming -- even the simplest things such as the flow of execution -- is not appropriate.

And, given a choice between forcibly abstracting or deabstracting, for a beginner, I'd go with forcibly abstracting. Abstraction is fundamental to good programming -- especially defensive programming. Deabstraction is only fundamental to http://worsethanfailure.com/'s existance.
0

Share this post


Link to post
Share on other sites
Quote:

Quote:

Quote:

e.g. #1 Learning how to deal with strings correctly in C will teach you a lot more about "how the computer works as a machine" compared to using a C++/C#/Java/etc string class.

No, it'll teach you about how C-style strings work. Given that they work the same on all implementations of C, even when running on machines with wildly differing architectures, that should be a clue that string handling doesn't reveal the secrets of "how the computer works as a machine".

Again, you're not arguing against my point - I didn't say that it would "reveal the secrets", I was trying to illustrate that using lower level constructs teaches you more about the machine than using higher level constructs.


They are C concepts, not low level concepts. Strings dont need any null termination. Pointers are used ALOT in low level programming, but only as dereferencing addresses and address arithmetic.

C is an abstraction of assembly language.

assembly language is an abstraction of machine language.

machine language is an abstraction of microcode.

microcode is either stored in via EEPROM (The BIOS, for example); or hardwired in.

With that done, I think this is getting a bit offtopic...[wink]
0

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0